diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 480eb784..2914c6d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,12 +7,17 @@ on: - 'integrated/**' - 'stl-preview-head/**' - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/finch-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 @@ -35,6 +40,7 @@ jobs: timeout-minutes: 10 name: test runs-on: ${{ github.repository == 'stainless-sdks/finch-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ad42ef71..6bec2480 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.2.0" + ".": "7.3.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index 2493b56b..1889fe28 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-944a0f9d35f3b8ec2ba62fa12e551cf89f0b845f8ed1e3c7f67a9fb80b32d96f.yml -openapi_spec_hash: 37c849e7b5dd941c011385b49467e077 -config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-f7e741bc6e0175fd96a9db5348092b90a77b0985154c0814bb681ad5dccdf19a.yml +openapi_spec_hash: b348a9ef407a8e91dd770fcb219d4ac5 +config_hash: 5146b12344dae76238940989dac1e8a0 diff --git a/CHANGELOG.md b/CHANGELOG.md index bc506e14..5a1dac19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,44 @@ # Changelog +## 7.3.0 (2025-07-02) + +Full Changelog: [v7.2.0...v7.3.0](https://github.com/Finch-API/finch-api-java/compare/v7.2.0...v7.3.0) + +### Features + +* **api:** api update ([ba2711a](https://github.com/Finch-API/finch-api-java/commit/ba2711a7466433c91cafd023ab09a29dda400322)) +* **api:** api update ([85f964f](https://github.com/Finch-API/finch-api-java/commit/85f964f88bf80872817b2eff4e8a1017a9fabb4e)) +* **api:** api update ([d06d641](https://github.com/Finch-API/finch-api-java/commit/d06d641383d5b756ed558ce9dc23382995855b97)) +* **api:** api update ([ad3d78f](https://github.com/Finch-API/finch-api-java/commit/ad3d78f6515a72e9bc485e5eb9a5dfd98e8cd3d9)) +* **client:** add a `withOptions` method ([a6d2027](https://github.com/Finch-API/finch-api-java/commit/a6d2027c37a9dcf2582041bfa003b3d52a2699f4)) +* **client:** implement per-endpoint base URL support ([9b313e8](https://github.com/Finch-API/finch-api-java/commit/9b313e857a753068e492ffc9fd8a2a9022664ac9)) + + +### Bug Fixes + +* **ci:** release-doctor — report correct token name ([9ec953f](https://github.com/Finch-API/finch-api-java/commit/9ec953ffd3bc6c481f8b426db00fdee0364f737f)) +* **client:** `hasNextPage` impl for some classes ([1d74258](https://github.com/Finch-API/finch-api-java/commit/1d74258cd7af29bab12fa98e22201fdd736ff70e)) +* **client:** bump max requests per host to max requests (5 -> 64) ([c2130c2](https://github.com/Finch-API/finch-api-java/commit/c2130c25fe4053c6d85800dbf4e00935b85ff293)) +* **client:** don't close client on `withOptions` usage when original is gc'd ([f16754f](https://github.com/Finch-API/finch-api-java/commit/f16754fba73202a310517fafa12da662f70030e2)) +* **client:** fix PayStatementResponse body ([6e3128c](https://github.com/Finch-API/finch-api-java/commit/6e3128c15c5554728a0a1ab30f52458031d52f6c)) +* **client:** remove `@MustBeClosed` for future returning methods ([17cef16](https://github.com/Finch-API/finch-api-java/commit/17cef164e3b1da2ee49ed2c8e134bc3b2ff22e18)) +* **client:** update pagination ([d6b79ed](https://github.com/Finch-API/finch-api-java/commit/d6b79edb8319349a9b1141eb686f1e72b45929aa)) +* missing baseUrl call ([2040de9](https://github.com/Finch-API/finch-api-java/commit/2040de9e68d7b36faf74855e99b3e6d2d960cf7b)) + + +### Chores + +* **ci:** enable for pull requests ([d88d4b3](https://github.com/Finch-API/finch-api-java/commit/d88d4b39718a89f914aa89ad944d67eabb833f7a)) +* **ci:** only run for pushes and fork pull requests ([65d0eb9](https://github.com/Finch-API/finch-api-java/commit/65d0eb99b3b44fca36f3b1598911b242f1405ef0)) +* **docs:** grammar improvements ([ec2fe8b](https://github.com/Finch-API/finch-api-java/commit/ec2fe8b45c5898aee580617acbce9364802647be)) +* **internal:** codegen related update ([ec234c1](https://github.com/Finch-API/finch-api-java/commit/ec234c1c781c1453c7cea59e897420e0b820a15b)) +* **tests:** skip endpoints with basic auth ([6c2f07f](https://github.com/Finch-API/finch-api-java/commit/6c2f07f7ce293abdf78dd6584111eb1fcb6b7b52)) + + +### Refactors + +* **internal:** minor `ClientOptionsTest` change ([459de5c](https://github.com/Finch-API/finch-api-java/commit/459de5c5529c89b73febf0d0b30c12d46d314460)) + ## 7.2.0 (2025-05-16) Full Changelog: [v7.1.0...v7.2.0](https://github.com/Finch-API/finch-api-java/compare/v7.1.0...v7.2.0) diff --git a/README.md b/README.md index bdb48061..54f2db3a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.2.0) -[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.2.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.2.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.3.0) +[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.3.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.3.0) @@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.2.0). +The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.3.0). @@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.tryfinch.com](https://deve ### Gradle ```kotlin -implementation("com.tryfinch.api:finch-java:7.2.0") +implementation("com.tryfinch.api:finch-java:7.3.0") ``` ### Maven @@ -35,7 +35,7 @@ implementation("com.tryfinch.api:finch-java:7.2.0") com.tryfinch.api finch-java - 7.2.0 + 7.3.0 ``` @@ -114,6 +114,21 @@ See this table for the available options: > Don't create more than one client in the same application. Each client has a connection pool and > thread pools, which are more efficient to share between requests. +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: + +```java +import com.tryfinch.api.client.FinchClient; + +FinchClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + ## Requests and responses To send a request to the Finch API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. diff --git a/SECURITY.md b/SECURITY.md index b6499508..1e432e1e 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -16,11 +16,11 @@ before making any information public. ## Reporting Non-SDK Related Security Issues If you encounter security issues that are not directly related to SDKs but pertain to the services -or products provided by Finch please follow the respective company's security reporting guidelines. +or products provided by Finch, please follow the respective company's security reporting guidelines. ### Finch Terms and Policies -Please contact founders@tryfinch.com for any questions or concerns regarding security of our services. +Please contact founders@tryfinch.com for any questions or concerns regarding the security of our services. --- diff --git a/bin/check-release-environment b/bin/check-release-environment index 5e7c517a..3a6a7b4a 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,19 +3,19 @@ errors=() if [ -z "${SONATYPE_USERNAME}" ]; then - errors+=("The FINCH_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${SONATYPE_PASSWORD}" ]; then - errors+=("The FINCH_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${GPG_SIGNING_KEY}" ]; then - errors+=("The FINCH_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${GPG_SIGNING_PASSWORD}" ]; then - errors+=("The FINCH_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi lenErrors=${#errors[@]} diff --git a/build.gradle.kts b/build.gradle.kts index 003509c6..8faba707 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.tryfinch.api" - version = "7.2.0" // x-release-please-version + version = "7.3.0" // x-release-please-version } subprojects { diff --git a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt index 21e1d896..ea6fc295 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 @@ -189,13 +189,7 @@ class FinchOkHttpClient private constructor() { fun build(): FinchClient = FinchClientImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } 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 ecfb663d..158818cc 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 @@ -189,13 +189,7 @@ class FinchOkHttpClientAsync private constructor() { fun build(): FinchClientAsync = FinchClientAsyncImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } 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 be523572..9d66fadb 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 @@ -2,7 +2,6 @@ package com.tryfinch.api.client.okhttp import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.Timeout -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 @@ -17,7 +16,6 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -28,8 +26,7 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient -private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { @@ -140,11 +137,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun HttpRequest.toUrl(): String { - url?.let { - return it - } - - val builder = baseUrl.newBuilder() + val builder = baseUrl.toHttpUrl().newBuilder() pathSegments.forEach(builder::addPathSegment) queryParams.keys().forEach { key -> queryParams.values(key).forEach { builder.addQueryParameter(key, it) } @@ -194,12 +187,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { - private var baseUrl: HttpUrl? = null private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) @@ -214,8 +204,12 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .writeTimeout(timeout.write()) .callTimeout(timeout.request()) .proxy(proxy) - .build(), - checkRequired("baseUrl", baseUrl), + .build() + .apply { + // We usually make all our requests to the same host so it makes sense to + // raise the per-host limit to the overall limit. + dispatcher.maxRequestsPerHost = dispatcher.maxRequests + } ) } } 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 4d6662df..b1026a74 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 @@ -3,6 +3,7 @@ package com.tryfinch.api.client import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.AccessTokenService import com.tryfinch.api.services.blocking.AccountService import com.tryfinch.api.services.blocking.ConnectService @@ -13,6 +14,7 @@ import com.tryfinch.api.services.blocking.ProviderService import com.tryfinch.api.services.blocking.RequestForwardingService import com.tryfinch.api.services.blocking.SandboxService import com.tryfinch.api.services.blocking.WebhookService +import java.util.function.Consumer /** * A client for interacting with the Finch REST API synchronously. You can also switch to @@ -43,6 +45,13 @@ interface FinchClient { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FinchClient + fun accessTokens(): AccessTokenService fun hris(): HrisService @@ -109,6 +118,13 @@ interface FinchClient { /** A view of [FinchClient] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FinchClient.WithRawResponse + fun accessTokens(): AccessTokenService.WithRawResponse fun hris(): HrisService.WithRawResponse 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 d829a593..df116b22 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 @@ -3,6 +3,7 @@ package com.tryfinch.api.client import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.AccessTokenServiceAsync import com.tryfinch.api.services.async.AccountServiceAsync import com.tryfinch.api.services.async.ConnectServiceAsync @@ -14,6 +15,7 @@ import com.tryfinch.api.services.async.RequestForwardingServiceAsync import com.tryfinch.api.services.async.SandboxServiceAsync import com.tryfinch.api.services.async.WebhookServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer /** * A client for interacting with the Finch REST API asynchronously. You can also switch to @@ -44,6 +46,13 @@ interface FinchClientAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FinchClientAsync + fun accessTokens(): AccessTokenServiceAsync fun hris(): HrisServiceAsync @@ -110,6 +119,13 @@ interface FinchClientAsync { /** A view of [FinchClientAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FinchClientAsync.WithRawResponse + fun accessTokens(): AccessTokenServiceAsync.WithRawResponse fun hris(): HrisServiceAsync.WithRawResponse 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 23a0f4e0..5f8e59fb 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 @@ -37,6 +37,7 @@ import com.tryfinch.api.services.async.WebhookServiceAsync import com.tryfinch.api.services.async.WebhookServiceAsyncImpl import java.net.URLEncoder import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClientAsync { @@ -99,6 +100,9 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie override fun withRawResponse(): FinchClientAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FinchClientAsync = + FinchClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun accessTokens(): AccessTokenServiceAsync = accessTokens override fun hris(): HrisServiceAsync = hris @@ -136,6 +140,7 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("auth", "token") .body( json( @@ -166,7 +171,7 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie .httpClient(clientOptions.httpClient) .jsonMapper(clientOptions.jsonMapper) .clock(clientOptions.clock) - .baseUrl(clientOptions.baseUrl) + .baseUrl(clientOptions.baseUrl()) .accessToken(accessToken) .clientId(clientOptions.clientId()) .clientSecret(clientOptions.clientSecret()) @@ -235,6 +240,13 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie ConnectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FinchClientAsync.WithRawResponse = + FinchClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun accessTokens(): AccessTokenServiceAsync.WithRawResponse = accessTokens override fun hris(): HrisServiceAsync.WithRawResponse = hris 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 766d1631..efa56805 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 @@ -36,6 +36,7 @@ import com.tryfinch.api.services.blocking.SandboxServiceImpl import com.tryfinch.api.services.blocking.WebhookService import com.tryfinch.api.services.blocking.WebhookServiceImpl import java.net.URLEncoder +import java.util.function.Consumer class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { @@ -88,6 +89,9 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { override fun withRawResponse(): FinchClient.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FinchClient = + FinchClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun accessTokens(): AccessTokenService = accessTokens override fun hris(): HrisService = hris @@ -125,6 +129,7 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("auth", "token") .body( json( @@ -155,7 +160,7 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { .httpClient(clientOptions.httpClient) .jsonMapper(clientOptions.jsonMapper) .clock(clientOptions.clock) - .baseUrl(clientOptions.baseUrl) + .baseUrl(clientOptions.baseUrl()) .accessToken(accessToken) .clientId(clientOptions.clientId()) .clientSecret(clientOptions.clientSecret()) @@ -224,6 +229,13 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { ConnectServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FinchClient.WithRawResponse = + FinchClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun accessTokens(): AccessTokenService.WithRawResponse = accessTokens override fun hris(): HrisService.WithRawResponse = hris 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 cfdb5e56..e63f1d29 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 @@ -25,7 +25,7 @@ private constructor( @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor, @get:JvmName("clock") val clock: Clock, - @get:JvmName("baseUrl") val baseUrl: String, + private val baseUrl: String?, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, @@ -43,6 +43,8 @@ private constructor( } } + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + fun accessToken(): Optional = Optional.ofNullable(accessToken) fun clientId(): Optional = Optional.ofNullable(clientId) @@ -78,7 +80,7 @@ private constructor( private var jsonMapper: JsonMapper = jsonMapper() private var streamHandlerExecutor: Executor? = null private var clock: Clock = Clock.systemUTC() - private var baseUrl: String = PRODUCTION_URL + private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false @@ -108,7 +110,9 @@ private constructor( webhookSecret = clientOptions.webhookSecret } - fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility @@ -122,7 +126,10 @@ private constructor( fun clock(clock: Clock) = apply { this.clock = clock } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -233,8 +240,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun baseUrl(): String = baseUrl - fun fromEnv() = apply { System.getenv("FINCH_BASE_URL")?.let { baseUrl(it) } System.getenv("FINCH_CLIENT_ID")?.let { clientId(it) } @@ -287,13 +292,11 @@ private constructor( return ClientOptions( httpClient, - PhantomReachableClosingHttpClient( - RetryingHttpClient.builder() - .httpClient(httpClient) - .clock(clock) - .maxRetries(maxRetries) - .build() - ), + RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build(), checkJacksonVersionCompatibility, jsonMapper, streamHandlerExecutor 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 c75e9fb9..ab9b11c1 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 @@ -6,7 +6,7 @@ import com.tryfinch.api.core.toImmutable class HttpRequest private constructor( @get:JvmName("method") val method: HttpMethod, - @get:JvmName("url") val url: String?, + @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("pathSegments") val pathSegments: List, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @@ -16,7 +16,7 @@ private constructor( fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = - "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" companion object { @JvmStatic fun builder() = Builder() @@ -25,7 +25,7 @@ private constructor( class Builder internal constructor() { private var method: HttpMethod? = null - private var url: String? = null + private var baseUrl: String? = null private var pathSegments: MutableList = mutableListOf() private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() @@ -34,7 +34,7 @@ private constructor( @JvmSynthetic internal fun from(request: HttpRequest) = apply { method = request.method - url = request.url + baseUrl = request.baseUrl pathSegments = request.pathSegments.toMutableList() headers = request.headers.toBuilder() queryParams = request.queryParams.toBuilder() @@ -43,7 +43,7 @@ private constructor( fun method(method: HttpMethod) = apply { this.method = method } - fun url(url: String) = apply { this.url = url } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } @@ -136,7 +136,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( checkRequired("method", method), - url, + checkRequired("baseUrl", baseUrl), pathSegments.toImmutable(), headers.build(), queryParams.build(), 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 2d9f9c47..b7429b6f 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 @@ -6,13 +6,10 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.tryfinch.api.core.Enum import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.core.checkKnown -import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -21,7 +18,7 @@ import kotlin.jvm.optionals.getOrNull class BenefitFeaturesAndOperations private constructor( - private val supportedFeatures: JsonField, + private val supportedFeatures: JsonField, private val supportedOperations: JsonField, private val additionalProperties: MutableMap, ) { @@ -30,7 +27,7 @@ private constructor( private constructor( @JsonProperty("supported_features") @ExcludeMissing - supportedFeatures: JsonField = JsonMissing.of(), + supportedFeatures: JsonField = JsonMissing.of(), @JsonProperty("supported_operations") @ExcludeMissing supportedOperations: JsonField = JsonMissing.of(), @@ -40,7 +37,7 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun supportedFeatures(): Optional = + fun supportedFeatures(): Optional = supportedFeatures.getOptional("supported_features") /** @@ -58,7 +55,7 @@ private constructor( */ @JsonProperty("supported_features") @ExcludeMissing - fun _supportedFeatures(): JsonField = supportedFeatures + fun _supportedFeatures(): JsonField = supportedFeatures /** * Returns the raw JSON value of [supportedOperations]. @@ -93,7 +90,7 @@ private constructor( /** A builder for [BenefitFeaturesAndOperations]. */ class Builder internal constructor() { - private var supportedFeatures: JsonField = JsonMissing.of() + private var supportedFeatures: JsonField = JsonMissing.of() private var supportedOperations: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -104,17 +101,17 @@ private constructor( additionalProperties = benefitFeaturesAndOperations.additionalProperties.toMutableMap() } - fun supportedFeatures(supportedFeatures: BenefitFeature) = + fun supportedFeatures(supportedFeatures: SupportedBenefit) = supportedFeatures(JsonField.of(supportedFeatures)) /** * Sets [Builder.supportedFeatures] to an arbitrary JSON value. * - * You should usually call [Builder.supportedFeatures] with a well-typed [BenefitFeature] + * You should usually call [Builder.supportedFeatures] with a well-typed [SupportedBenefit] * value instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun supportedFeatures(supportedFeatures: JsonField) = apply { + fun supportedFeatures(supportedFeatures: JsonField) = apply { this.supportedFeatures = supportedFeatures } @@ -194,923 +191,6 @@ private constructor( (supportedFeatures.asKnown().getOrNull()?.validity() ?: 0) + (supportedOperations.asKnown().getOrNull()?.validity() ?: 0) - class BenefitFeature - private constructor( - private val annualMaximum: JsonField, - private val catchUp: JsonField, - private val companyContribution: JsonField>, - private val description: JsonField, - private val employeeDeduction: JsonField>, - private val frequencies: JsonField>, - private val hsaContributionLimit: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("annual_maximum") - @ExcludeMissing - annualMaximum: JsonField = JsonMissing.of(), - @JsonProperty("catch_up") - @ExcludeMissing - catchUp: JsonField = JsonMissing.of(), - @JsonProperty("company_contribution") - @ExcludeMissing - companyContribution: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("employee_deduction") - @ExcludeMissing - employeeDeduction: JsonField> = JsonMissing.of(), - @JsonProperty("frequencies") - @ExcludeMissing - frequencies: JsonField> = JsonMissing.of(), - @JsonProperty("hsa_contribution_limit") - @ExcludeMissing - hsaContributionLimit: JsonField> = JsonMissing.of(), - ) : this( - annualMaximum, - catchUp, - companyContribution, - description, - employeeDeduction, - frequencies, - hsaContributionLimit, - mutableMapOf(), - ) - - /** - * Whether the provider supports an annual maximum for this benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun annualMaximum(): Optional = annualMaximum.getOptional("annual_maximum") - - /** - * Whether the provider supports catch up for this benefit. This field will only be true for - * retirement benefits. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun catchUp(): Optional = catchUp.getOptional("catch_up") - - /** - * Supported contribution types. An empty array indicates contributions are not supported. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun companyContribution(): Optional> = - companyContribution.getOptional("company_contribution") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Supported deduction types. An empty array indicates deductions are not supported. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employeeDeduction(): Optional> = - employeeDeduction.getOptional("employee_deduction") - - /** - * The list of frequencies supported by the provider for this benefit - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun frequencies(): Optional> = - frequencies.getOptional("frequencies") - - /** - * Whether the provider supports HSA contribution limits. Empty if this feature is not - * supported for the benefit. This array only has values for HSA benefits. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hsaContributionLimit(): Optional> = - hsaContributionLimit.getOptional("hsa_contribution_limit") - - /** - * Returns the raw JSON value of [annualMaximum]. - * - * Unlike [annualMaximum], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("annual_maximum") - @ExcludeMissing - fun _annualMaximum(): JsonField = annualMaximum - - /** - * Returns the raw JSON value of [catchUp]. - * - * Unlike [catchUp], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("catch_up") @ExcludeMissing fun _catchUp(): JsonField = catchUp - - /** - * Returns the raw JSON value of [companyContribution]. - * - * Unlike [companyContribution], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("company_contribution") - @ExcludeMissing - fun _companyContribution(): JsonField> = companyContribution - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [employeeDeduction]. - * - * Unlike [employeeDeduction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employee_deduction") - @ExcludeMissing - fun _employeeDeduction(): JsonField> = employeeDeduction - - /** - * Returns the raw JSON value of [frequencies]. - * - * Unlike [frequencies], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("frequencies") - @ExcludeMissing - fun _frequencies(): JsonField> = frequencies - - /** - * Returns the raw JSON value of [hsaContributionLimit]. - * - * Unlike [hsaContributionLimit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hsa_contribution_limit") - @ExcludeMissing - fun _hsaContributionLimit(): JsonField> = hsaContributionLimit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [BenefitFeature]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BenefitFeature]. */ - class Builder internal constructor() { - - private var annualMaximum: JsonField = JsonMissing.of() - private var catchUp: JsonField = JsonMissing.of() - private var companyContribution: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var employeeDeduction: JsonField>? = null - private var frequencies: JsonField>? = null - private var hsaContributionLimit: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(benefitFeature: BenefitFeature) = apply { - annualMaximum = benefitFeature.annualMaximum - catchUp = benefitFeature.catchUp - companyContribution = benefitFeature.companyContribution.map { it.toMutableList() } - description = benefitFeature.description - employeeDeduction = benefitFeature.employeeDeduction.map { it.toMutableList() } - frequencies = benefitFeature.frequencies.map { it.toMutableList() } - hsaContributionLimit = - benefitFeature.hsaContributionLimit.map { it.toMutableList() } - additionalProperties = benefitFeature.additionalProperties.toMutableMap() - } - - /** Whether the provider supports an annual maximum for this benefit. */ - fun annualMaximum(annualMaximum: Boolean?) = - annualMaximum(JsonField.ofNullable(annualMaximum)) - - /** - * Alias for [Builder.annualMaximum]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun annualMaximum(annualMaximum: Boolean) = annualMaximum(annualMaximum as Boolean?) - - /** Alias for calling [Builder.annualMaximum] with `annualMaximum.orElse(null)`. */ - fun annualMaximum(annualMaximum: Optional) = - annualMaximum(annualMaximum.getOrNull()) - - /** - * Sets [Builder.annualMaximum] to an arbitrary JSON value. - * - * You should usually call [Builder.annualMaximum] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun annualMaximum(annualMaximum: JsonField) = apply { - this.annualMaximum = annualMaximum - } - - /** - * Whether the provider supports catch up for this benefit. This field will only be true - * for retirement benefits. - */ - fun catchUp(catchUp: Boolean?) = catchUp(JsonField.ofNullable(catchUp)) - - /** - * Alias for [Builder.catchUp]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun catchUp(catchUp: Boolean) = catchUp(catchUp as Boolean?) - - /** Alias for calling [Builder.catchUp] with `catchUp.orElse(null)`. */ - fun catchUp(catchUp: Optional) = catchUp(catchUp.getOrNull()) - - /** - * Sets [Builder.catchUp] to an arbitrary JSON value. - * - * You should usually call [Builder.catchUp] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun catchUp(catchUp: JsonField) = apply { this.catchUp = catchUp } - - /** - * Supported contribution types. An empty array indicates contributions are not - * supported. - */ - fun companyContribution(companyContribution: List?) = - companyContribution(JsonField.ofNullable(companyContribution)) - - /** - * Alias for calling [Builder.companyContribution] with - * `companyContribution.orElse(null)`. - */ - fun companyContribution(companyContribution: Optional>) = - companyContribution(companyContribution.getOrNull()) - - /** - * Sets [Builder.companyContribution] to an arbitrary JSON value. - * - * You should usually call [Builder.companyContribution] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun companyContribution(companyContribution: JsonField>) = - apply { - this.companyContribution = companyContribution.map { it.toMutableList() } - } - - /** - * Adds a single [CompanyContribution] to [Builder.companyContribution]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCompanyContribution(companyContribution: CompanyContribution) = apply { - this.companyContribution = - (this.companyContribution ?: JsonField.of(mutableListOf())).also { - checkKnown("companyContribution", it).add(companyContribution) - } - } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** Supported deduction types. An empty array indicates deductions are not supported. */ - fun employeeDeduction(employeeDeduction: List?) = - employeeDeduction(JsonField.ofNullable(employeeDeduction)) - - /** - * Alias for calling [Builder.employeeDeduction] with `employeeDeduction.orElse(null)`. - */ - fun employeeDeduction(employeeDeduction: Optional>) = - employeeDeduction(employeeDeduction.getOrNull()) - - /** - * Sets [Builder.employeeDeduction] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeDeduction] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun employeeDeduction(employeeDeduction: JsonField>) = apply { - this.employeeDeduction = employeeDeduction.map { it.toMutableList() } - } - - /** - * Adds a single [EmployeeDeduction] to [Builder.employeeDeduction]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { - this.employeeDeduction = - (this.employeeDeduction ?: JsonField.of(mutableListOf())).also { - checkKnown("employeeDeduction", it).add(employeeDeduction) - } - } - - /** The list of frequencies supported by the provider for this benefit */ - fun frequencies(frequencies: List) = - frequencies(JsonField.of(frequencies)) - - /** - * Sets [Builder.frequencies] to an arbitrary JSON value. - * - * You should usually call [Builder.frequencies] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun frequencies(frequencies: JsonField>) = apply { - this.frequencies = frequencies.map { it.toMutableList() } - } - - /** - * Adds a single [BenefitFrequency] to [frequencies]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFrequency(frequency: BenefitFrequency) = apply { - frequencies = - (frequencies ?: JsonField.of(mutableListOf())).also { - checkKnown("frequencies", it).add(frequency) - } - } - - /** - * Whether the provider supports HSA contribution limits. Empty if this feature is not - * supported for the benefit. This array only has values for HSA benefits. - */ - fun hsaContributionLimit(hsaContributionLimit: List?) = - hsaContributionLimit(JsonField.ofNullable(hsaContributionLimit)) - - /** - * Alias for calling [Builder.hsaContributionLimit] with - * `hsaContributionLimit.orElse(null)`. - */ - fun hsaContributionLimit(hsaContributionLimit: Optional>) = - hsaContributionLimit(hsaContributionLimit.getOrNull()) - - /** - * Sets [Builder.hsaContributionLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.hsaContributionLimit] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun hsaContributionLimit(hsaContributionLimit: JsonField>) = - apply { - this.hsaContributionLimit = hsaContributionLimit.map { it.toMutableList() } - } - - /** - * Adds a single [HsaContributionLimit] to [Builder.hsaContributionLimit]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addHsaContributionLimit(hsaContributionLimit: HsaContributionLimit) = apply { - this.hsaContributionLimit = - (this.hsaContributionLimit ?: JsonField.of(mutableListOf())).also { - checkKnown("hsaContributionLimit", it).add(hsaContributionLimit) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BenefitFeature]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BenefitFeature = - BenefitFeature( - annualMaximum, - catchUp, - (companyContribution ?: JsonMissing.of()).map { it.toImmutable() }, - description, - (employeeDeduction ?: JsonMissing.of()).map { it.toImmutable() }, - (frequencies ?: JsonMissing.of()).map { it.toImmutable() }, - (hsaContributionLimit ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BenefitFeature = apply { - if (validated) { - return@apply - } - - annualMaximum() - catchUp() - companyContribution().ifPresent { it.forEach { it?.validate() } } - description() - employeeDeduction().ifPresent { it.forEach { it?.validate() } } - frequencies().ifPresent { it.forEach { it?.validate() } } - hsaContributionLimit().ifPresent { it.forEach { it?.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (annualMaximum.asKnown().isPresent) 1 else 0) + - (if (catchUp.asKnown().isPresent) 1 else 0) + - (companyContribution.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (employeeDeduction.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (frequencies.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (hsaContributionLimit.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) - - class CompanyContribution - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIXED = of("fixed") - - @JvmField val PERCENT = of("percent") - - @JvmStatic fun of(value: String) = 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 - PERCENT -> Value.PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - FIXED -> Known.FIXED - PERCENT -> Known.PERCENT - else -> throw FinchInvalidDataException("Unknown CompanyContribution: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): CompanyContribution = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CompanyContribution && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EmployeeDeduction - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIXED = of("fixed") - - @JvmField val PERCENT = of("percent") - - @JvmStatic fun of(value: String) = 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 - PERCENT -> Value.PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - FIXED -> Known.FIXED - PERCENT -> Known.PERCENT - else -> throw FinchInvalidDataException("Unknown EmployeeDeduction: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): EmployeeDeduction = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployeeDeduction && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - 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 { - - @JvmField val INDIVIDUAL = of("individual") - - @JvmField val FAMILY = of("family") - - @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 - FAMILY -> Value.FAMILY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - FAMILY -> Known.FAMILY - else -> throw FinchInvalidDataException("Unknown HsaContributionLimit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): HsaContributionLimit = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HsaContributionLimit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BenefitFeature && annualMaximum == other.annualMaximum && catchUp == other.catchUp && companyContribution == other.companyContribution && description == other.description && employeeDeduction == other.employeeDeduction && frequencies == other.frequencies && hsaContributionLimit == other.hsaContributionLimit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(annualMaximum, catchUp, companyContribution, description, employeeDeduction, frequencies, hsaContributionLimit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BenefitFeature{annualMaximum=$annualMaximum, catchUp=$catchUp, companyContribution=$companyContribution, description=$description, employeeDeduction=$employeeDeduction, frequencies=$frequencies, hsaContributionLimit=$hsaContributionLimit, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt deleted file mode 100644 index be8e05eb..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt +++ /dev/null @@ -1,918 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.tryfinch.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.tryfinch.api.core.Enum -import com.tryfinch.api.core.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.core.checkKnown -import com.tryfinch.api.core.toImmutable -import com.tryfinch.api.errors.FinchInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class BenefitListSupportedBenefitsResponse -private constructor( - private val annualMaximum: JsonField, - private val catchUp: JsonField, - private val companyContribution: JsonField>, - private val description: JsonField, - private val employeeDeduction: JsonField>, - private val frequencies: JsonField>, - private val hsaContributionLimit: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("annual_maximum") - @ExcludeMissing - annualMaximum: JsonField = JsonMissing.of(), - @JsonProperty("catch_up") @ExcludeMissing catchUp: JsonField = JsonMissing.of(), - @JsonProperty("company_contribution") - @ExcludeMissing - companyContribution: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("employee_deduction") - @ExcludeMissing - employeeDeduction: JsonField> = JsonMissing.of(), - @JsonProperty("frequencies") - @ExcludeMissing - frequencies: JsonField> = JsonMissing.of(), - @JsonProperty("hsa_contribution_limit") - @ExcludeMissing - hsaContributionLimit: JsonField> = JsonMissing.of(), - ) : this( - annualMaximum, - catchUp, - companyContribution, - description, - employeeDeduction, - frequencies, - hsaContributionLimit, - mutableMapOf(), - ) - - /** - * Whether the provider supports an annual maximum for this benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun annualMaximum(): Optional = annualMaximum.getOptional("annual_maximum") - - /** - * Whether the provider supports catch up for this benefit. This field will only be true for - * retirement benefits. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun catchUp(): Optional = catchUp.getOptional("catch_up") - - /** - * Supported contribution types. An empty array indicates contributions are not supported. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun companyContribution(): Optional> = - companyContribution.getOptional("company_contribution") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Supported deduction types. An empty array indicates deductions are not supported. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employeeDeduction(): Optional> = - employeeDeduction.getOptional("employee_deduction") - - /** - * The list of frequencies supported by the provider for this benefit - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun frequencies(): Optional> = frequencies.getOptional("frequencies") - - /** - * Whether the provider supports HSA contribution limits. Empty if this feature is not supported - * for the benefit. This array only has values for HSA benefits. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hsaContributionLimit(): Optional> = - hsaContributionLimit.getOptional("hsa_contribution_limit") - - /** - * Returns the raw JSON value of [annualMaximum]. - * - * Unlike [annualMaximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("annual_maximum") - @ExcludeMissing - fun _annualMaximum(): JsonField = annualMaximum - - /** - * Returns the raw JSON value of [catchUp]. - * - * Unlike [catchUp], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("catch_up") @ExcludeMissing fun _catchUp(): JsonField = catchUp - - /** - * Returns the raw JSON value of [companyContribution]. - * - * Unlike [companyContribution], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("company_contribution") - @ExcludeMissing - fun _companyContribution(): JsonField> = companyContribution - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [employeeDeduction]. - * - * Unlike [employeeDeduction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employee_deduction") - @ExcludeMissing - fun _employeeDeduction(): JsonField> = employeeDeduction - - /** - * Returns the raw JSON value of [frequencies]. - * - * Unlike [frequencies], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("frequencies") - @ExcludeMissing - fun _frequencies(): JsonField> = frequencies - - /** - * Returns the raw JSON value of [hsaContributionLimit]. - * - * Unlike [hsaContributionLimit], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("hsa_contribution_limit") - @ExcludeMissing - fun _hsaContributionLimit(): JsonField> = hsaContributionLimit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BenefitListSupportedBenefitsResponse]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BenefitListSupportedBenefitsResponse]. */ - class Builder internal constructor() { - - private var annualMaximum: JsonField = JsonMissing.of() - private var catchUp: JsonField = JsonMissing.of() - private var companyContribution: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var employeeDeduction: JsonField>? = null - private var frequencies: JsonField>? = null - private var hsaContributionLimit: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - benefitListSupportedBenefitsResponse: BenefitListSupportedBenefitsResponse - ) = apply { - annualMaximum = benefitListSupportedBenefitsResponse.annualMaximum - catchUp = benefitListSupportedBenefitsResponse.catchUp - companyContribution = - benefitListSupportedBenefitsResponse.companyContribution.map { it.toMutableList() } - description = benefitListSupportedBenefitsResponse.description - employeeDeduction = - benefitListSupportedBenefitsResponse.employeeDeduction.map { it.toMutableList() } - frequencies = - benefitListSupportedBenefitsResponse.frequencies.map { it.toMutableList() } - hsaContributionLimit = - benefitListSupportedBenefitsResponse.hsaContributionLimit.map { it.toMutableList() } - additionalProperties = - benefitListSupportedBenefitsResponse.additionalProperties.toMutableMap() - } - - /** Whether the provider supports an annual maximum for this benefit. */ - fun annualMaximum(annualMaximum: Boolean?) = - annualMaximum(JsonField.ofNullable(annualMaximum)) - - /** - * Alias for [Builder.annualMaximum]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun annualMaximum(annualMaximum: Boolean) = annualMaximum(annualMaximum as Boolean?) - - /** Alias for calling [Builder.annualMaximum] with `annualMaximum.orElse(null)`. */ - fun annualMaximum(annualMaximum: Optional) = - annualMaximum(annualMaximum.getOrNull()) - - /** - * Sets [Builder.annualMaximum] to an arbitrary JSON value. - * - * You should usually call [Builder.annualMaximum] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun annualMaximum(annualMaximum: JsonField) = apply { - this.annualMaximum = annualMaximum - } - - /** - * Whether the provider supports catch up for this benefit. This field will only be true for - * retirement benefits. - */ - fun catchUp(catchUp: Boolean?) = catchUp(JsonField.ofNullable(catchUp)) - - /** - * Alias for [Builder.catchUp]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun catchUp(catchUp: Boolean) = catchUp(catchUp as Boolean?) - - /** Alias for calling [Builder.catchUp] with `catchUp.orElse(null)`. */ - fun catchUp(catchUp: Optional) = catchUp(catchUp.getOrNull()) - - /** - * Sets [Builder.catchUp] to an arbitrary JSON value. - * - * You should usually call [Builder.catchUp] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun catchUp(catchUp: JsonField) = apply { this.catchUp = catchUp } - - /** - * Supported contribution types. An empty array indicates contributions are not supported. - */ - fun companyContribution(companyContribution: List?) = - companyContribution(JsonField.ofNullable(companyContribution)) - - /** - * Alias for calling [Builder.companyContribution] with `companyContribution.orElse(null)`. - */ - fun companyContribution(companyContribution: Optional>) = - companyContribution(companyContribution.getOrNull()) - - /** - * Sets [Builder.companyContribution] to an arbitrary JSON value. - * - * You should usually call [Builder.companyContribution] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun companyContribution(companyContribution: JsonField>) = - apply { - this.companyContribution = companyContribution.map { it.toMutableList() } - } - - /** - * Adds a single [CompanyContribution] to [Builder.companyContribution]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCompanyContribution(companyContribution: CompanyContribution) = apply { - this.companyContribution = - (this.companyContribution ?: JsonField.of(mutableListOf())).also { - checkKnown("companyContribution", it).add(companyContribution) - } - } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun description(description: JsonField) = apply { this.description = description } - - /** Supported deduction types. An empty array indicates deductions are not supported. */ - fun employeeDeduction(employeeDeduction: List?) = - employeeDeduction(JsonField.ofNullable(employeeDeduction)) - - /** Alias for calling [Builder.employeeDeduction] with `employeeDeduction.orElse(null)`. */ - fun employeeDeduction(employeeDeduction: Optional>) = - employeeDeduction(employeeDeduction.getOrNull()) - - /** - * Sets [Builder.employeeDeduction] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeDeduction] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun employeeDeduction(employeeDeduction: JsonField>) = apply { - this.employeeDeduction = employeeDeduction.map { it.toMutableList() } - } - - /** - * Adds a single [EmployeeDeduction] to [Builder.employeeDeduction]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { - this.employeeDeduction = - (this.employeeDeduction ?: JsonField.of(mutableListOf())).also { - checkKnown("employeeDeduction", it).add(employeeDeduction) - } - } - - /** The list of frequencies supported by the provider for this benefit */ - fun frequencies(frequencies: List) = - frequencies(JsonField.of(frequencies)) - - /** - * Sets [Builder.frequencies] to an arbitrary JSON value. - * - * You should usually call [Builder.frequencies] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun frequencies(frequencies: JsonField>) = apply { - this.frequencies = frequencies.map { it.toMutableList() } - } - - /** - * Adds a single [BenefitFrequency] to [frequencies]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFrequency(frequency: BenefitFrequency) = apply { - frequencies = - (frequencies ?: JsonField.of(mutableListOf())).also { - checkKnown("frequencies", it).add(frequency) - } - } - - /** - * Whether the provider supports HSA contribution limits. Empty if this feature is not - * supported for the benefit. This array only has values for HSA benefits. - */ - fun hsaContributionLimit(hsaContributionLimit: List?) = - hsaContributionLimit(JsonField.ofNullable(hsaContributionLimit)) - - /** - * Alias for calling [Builder.hsaContributionLimit] with - * `hsaContributionLimit.orElse(null)`. - */ - fun hsaContributionLimit(hsaContributionLimit: Optional>) = - hsaContributionLimit(hsaContributionLimit.getOrNull()) - - /** - * Sets [Builder.hsaContributionLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.hsaContributionLimit] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun hsaContributionLimit(hsaContributionLimit: JsonField>) = - apply { - this.hsaContributionLimit = hsaContributionLimit.map { it.toMutableList() } - } - - /** - * Adds a single [HsaContributionLimit] to [Builder.hsaContributionLimit]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addHsaContributionLimit(hsaContributionLimit: HsaContributionLimit) = apply { - this.hsaContributionLimit = - (this.hsaContributionLimit ?: JsonField.of(mutableListOf())).also { - checkKnown("hsaContributionLimit", it).add(hsaContributionLimit) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BenefitListSupportedBenefitsResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BenefitListSupportedBenefitsResponse = - BenefitListSupportedBenefitsResponse( - annualMaximum, - catchUp, - (companyContribution ?: JsonMissing.of()).map { it.toImmutable() }, - description, - (employeeDeduction ?: JsonMissing.of()).map { it.toImmutable() }, - (frequencies ?: JsonMissing.of()).map { it.toImmutable() }, - (hsaContributionLimit ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BenefitListSupportedBenefitsResponse = apply { - if (validated) { - return@apply - } - - annualMaximum() - catchUp() - companyContribution().ifPresent { it.forEach { it?.validate() } } - description() - employeeDeduction().ifPresent { it.forEach { it?.validate() } } - frequencies().ifPresent { it.forEach { it?.validate() } } - hsaContributionLimit().ifPresent { it.forEach { it?.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (annualMaximum.asKnown().isPresent) 1 else 0) + - (if (catchUp.asKnown().isPresent) 1 else 0) + - (companyContribution.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (employeeDeduction.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (frequencies.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (hsaContributionLimit.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) - - class CompanyContribution - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIXED = of("fixed") - - @JvmField val PERCENT = of("percent") - - @JvmStatic fun of(value: String) = 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 - PERCENT -> Value.PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - FIXED -> Known.FIXED - PERCENT -> Known.PERCENT - else -> throw FinchInvalidDataException("Unknown CompanyContribution: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): CompanyContribution = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CompanyContribution && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EmployeeDeduction @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIXED = of("fixed") - - @JvmField val PERCENT = of("percent") - - @JvmStatic fun of(value: String) = 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 - PERCENT -> Value.PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - FIXED -> Known.FIXED - PERCENT -> Known.PERCENT - else -> throw FinchInvalidDataException("Unknown EmployeeDeduction: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EmployeeDeduction = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployeeDeduction && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - 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 { - - @JvmField val INDIVIDUAL = of("individual") - - @JvmField val FAMILY = of("family") - - @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 - FAMILY -> Value.FAMILY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - FAMILY -> Known.FAMILY - else -> throw FinchInvalidDataException("Unknown HsaContributionLimit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): HsaContributionLimit = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HsaContributionLimit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BenefitListSupportedBenefitsResponse && annualMaximum == other.annualMaximum && catchUp == other.catchUp && companyContribution == other.companyContribution && description == other.description && employeeDeduction == other.employeeDeduction && frequencies == other.frequencies && hsaContributionLimit == other.hsaContributionLimit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(annualMaximum, catchUp, companyContribution, description, employeeDeduction, frequencies, hsaContributionLimit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BenefitListSupportedBenefitsResponse{annualMaximum=$annualMaximum, catchUp=$catchUp, companyContribution=$companyContribution, description=$description, employeeDeduction=$employeeDeduction, frequencies=$frequencies, hsaContributionLimit=$hsaContributionLimit, additionalProperties=$additionalProperties}" -} 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 27b2ed15..b8526345 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 @@ -21,6 +21,8 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< companion object { + @JvmField val _457 = of("457") + @JvmField val _401K = of("401k") @JvmField val _401K_ROTH = of("401k_roth") @@ -31,58 +33,56 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< @JvmField val _403B_ROTH = of("403b_roth") - @JvmField val _457 = of("457") - @JvmField val _457_ROTH = of("457_roth") - @JvmField val S125_MEDICAL = of("s125_medical") - - @JvmField val S125_DENTAL = of("s125_dental") + @JvmField val COMMUTER = of("commuter") - @JvmField val S125_VISION = of("s125_vision") + @JvmField val CUSTOM_POST_TAX = of("custom_post_tax") - @JvmField val HSA_PRE = of("hsa_pre") + @JvmField val CUSTOM_PRE_TAX = of("custom_pre_tax") - @JvmField val HSA_POST = of("hsa_post") + @JvmField val FSA_DEPENDENT_CARE = of("fsa_dependent_care") @JvmField val FSA_MEDICAL = of("fsa_medical") - @JvmField val FSA_DEPENDENT_CARE = of("fsa_dependent_care") + @JvmField val HSA_POST = of("hsa_post") - @JvmField val SIMPLE_IRA = of("simple_ira") + @JvmField val HSA_PRE = of("hsa_pre") - @JvmField val SIMPLE = of("simple") + @JvmField val S125_DENTAL = of("s125_dental") - @JvmField val COMMUTER = of("commuter") + @JvmField val S125_MEDICAL = of("s125_medical") - @JvmField val CUSTOM_POST_TAX = of("custom_post_tax") + @JvmField val S125_VISION = of("s125_vision") - @JvmField val CUSTOM_PRE_TAX = of("custom_pre_tax") + @JvmField val SIMPLE = of("simple") + + @JvmField val SIMPLE_IRA = of("simple_ira") @JvmStatic fun of(value: String) = BenefitType(JsonField.of(value)) } /** An enum containing [BenefitType]'s known values. */ enum class Known { + _457, _401K, _401K_ROTH, _401K_LOAN, _403B, _403B_ROTH, - _457, _457_ROTH, - S125_MEDICAL, - S125_DENTAL, - S125_VISION, - HSA_PRE, - HSA_POST, - FSA_MEDICAL, - FSA_DEPENDENT_CARE, - SIMPLE_IRA, - SIMPLE, COMMUTER, CUSTOM_POST_TAX, CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, } /** @@ -95,25 +95,25 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + _457, _401K, _401K_ROTH, _401K_LOAN, _403B, _403B_ROTH, - _457, _457_ROTH, - S125_MEDICAL, - S125_DENTAL, - S125_VISION, - HSA_PRE, - HSA_POST, - FSA_MEDICAL, - FSA_DEPENDENT_CARE, - SIMPLE_IRA, - SIMPLE, COMMUTER, CUSTOM_POST_TAX, CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, /** An enum member indicating that [BenefitType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -127,25 +127,25 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< */ fun value(): Value = when (this) { + _457 -> Value._457 _401K -> Value._401K _401K_ROTH -> Value._401K_ROTH _401K_LOAN -> Value._401K_LOAN _403B -> Value._403B _403B_ROTH -> Value._403B_ROTH - _457 -> Value._457 _457_ROTH -> Value._457_ROTH - S125_MEDICAL -> Value.S125_MEDICAL - S125_DENTAL -> Value.S125_DENTAL - S125_VISION -> Value.S125_VISION - HSA_PRE -> Value.HSA_PRE - HSA_POST -> Value.HSA_POST - FSA_MEDICAL -> Value.FSA_MEDICAL - FSA_DEPENDENT_CARE -> Value.FSA_DEPENDENT_CARE - SIMPLE_IRA -> Value.SIMPLE_IRA - SIMPLE -> Value.SIMPLE COMMUTER -> Value.COMMUTER CUSTOM_POST_TAX -> Value.CUSTOM_POST_TAX CUSTOM_PRE_TAX -> Value.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Value.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Value.FSA_MEDICAL + HSA_POST -> Value.HSA_POST + HSA_PRE -> Value.HSA_PRE + S125_DENTAL -> Value.S125_DENTAL + S125_MEDICAL -> Value.S125_MEDICAL + S125_VISION -> Value.S125_VISION + SIMPLE -> Value.SIMPLE + SIMPLE_IRA -> Value.SIMPLE_IRA else -> Value._UNKNOWN } @@ -159,25 +159,25 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< */ fun known(): Known = when (this) { + _457 -> Known._457 _401K -> Known._401K _401K_ROTH -> Known._401K_ROTH _401K_LOAN -> Known._401K_LOAN _403B -> Known._403B _403B_ROTH -> Known._403B_ROTH - _457 -> Known._457 _457_ROTH -> Known._457_ROTH - S125_MEDICAL -> Known.S125_MEDICAL - S125_DENTAL -> Known.S125_DENTAL - S125_VISION -> Known.S125_VISION - HSA_PRE -> Known.HSA_PRE - HSA_POST -> Known.HSA_POST - FSA_MEDICAL -> Known.FSA_MEDICAL - FSA_DEPENDENT_CARE -> Known.FSA_DEPENDENT_CARE - SIMPLE_IRA -> Known.SIMPLE_IRA - SIMPLE -> Known.SIMPLE COMMUTER -> Known.COMMUTER CUSTOM_POST_TAX -> Known.CUSTOM_POST_TAX CUSTOM_PRE_TAX -> Known.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Known.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Known.FSA_MEDICAL + HSA_POST -> Known.HSA_POST + HSA_PRE -> Known.HSA_PRE + S125_DENTAL -> Known.S125_DENTAL + S125_MEDICAL -> Known.S125_MEDICAL + S125_VISION -> Known.S125_VISION + SIMPLE -> Known.SIMPLE + SIMPLE_IRA -> Known.SIMPLE_IRA else -> throw FinchInvalidDataException("Unknown BenefitType: $value") } 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 7e1b5ca6..a2c22053 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 @@ -68,7 +68,7 @@ private constructor( fun manual(): Optional = body.manual() /** - * The number of minutes until the session expires (defaults to 43,200, which is 30 days) + * The number of minutes until the session expires (defaults to 129,600, which is 90 days) * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -297,7 +297,7 @@ private constructor( fun manual(manual: JsonField) = apply { body.manual(manual) } /** - * The number of minutes until the session expires (defaults to 43,200, which is 30 days) + * The number of minutes until the session expires (defaults to 129,600, which is 90 days) */ fun minutesToExpire(minutesToExpire: Double?) = apply { body.minutesToExpire(minutesToExpire) @@ -586,7 +586,7 @@ private constructor( fun manual(): Optional = manual.getOptional("manual") /** - * The number of minutes until the session expires (defaults to 43,200, which is 30 days) + * The number of minutes until the session expires (defaults to 129,600, which is 90 days) * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -847,7 +847,7 @@ private constructor( fun manual(manual: JsonField) = apply { this.manual = manual } /** - * The number of minutes until the session expires (defaults to 43,200, which is 30 + * The number of minutes until the session expires (defaults to 129,600, which is 90 * days) */ fun minutesToExpire(minutesToExpire: Double?) = 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 bd97abad..e95ca383 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 @@ -207,7 +207,6 @@ private constructor( private constructor( private val id: JsonField, private val classCode: JsonField, - private val customFields: JsonField>, private val department: JsonField, private val employment: JsonField, private val employmentStatus: JsonField, @@ -221,10 +220,11 @@ private constructor( private val middleName: JsonField, private val startDate: JsonField, private val title: JsonField, - private val workId: JsonField, + private val customFields: JsonField>, private val income: JsonField, private val incomeHistory: JsonField>, private val sourceId: JsonField, + private val workId: JsonField, private val additionalProperties: MutableMap, ) { @@ -234,9 +234,6 @@ private constructor( @JsonProperty("class_code") @ExcludeMissing classCode: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField> = JsonMissing.of(), @JsonProperty("department") @ExcludeMissing department: JsonField = JsonMissing.of(), @@ -270,7 +267,9 @@ private constructor( @ExcludeMissing startDate: JsonField = JsonMissing.of(), @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - @JsonProperty("work_id") @ExcludeMissing workId: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField> = JsonMissing.of(), @JsonProperty("income") @ExcludeMissing income: JsonField = JsonMissing.of(), @JsonProperty("income_history") @ExcludeMissing @@ -278,10 +277,10 @@ private constructor( @JsonProperty("source_id") @ExcludeMissing sourceId: JsonField = JsonMissing.of(), + @JsonProperty("work_id") @ExcludeMissing workId: JsonField = JsonMissing.of(), ) : this( id, classCode, - customFields, department, employment, employmentStatus, @@ -295,10 +294,11 @@ private constructor( middleName, startDate, title, - workId, + customFields, income, incomeHistory, sourceId, + workId, mutableMapOf(), ) @@ -318,15 +318,6 @@ private constructor( */ fun classCode(): Optional = classCode.getOptional("class_code") - /** - * Custom fields for the individual. These are fields which are defined by the employer in - * the system. Custom fields are not currently supported for assisted connections. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customFields(): Optional> = customFields.getOptional("custom_fields") - /** * The department object. * @@ -427,12 +418,13 @@ private constructor( fun title(): Optional = title.getOptional("title") /** - * This field is deprecated in favour of `source_id` + * Custom fields for the individual. These are fields which are defined by the employer in + * the system. Custom fields are not currently supported for assisted connections. * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - @Deprecated("deprecated") fun workId(): Optional = workId.getOptional("work_id") + fun customFields(): Optional> = customFields.getOptional("custom_fields") /** * The employee's income as reported by the provider. This may not always be annualized @@ -460,6 +452,14 @@ private constructor( */ fun sourceId(): Optional = sourceId.getOptional("source_id") + /** + * This field is deprecated in favour of `source_id` + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun workId(): Optional = workId.getOptional("work_id") + /** * Returns the raw JSON value of [id]. * @@ -474,16 +474,6 @@ private constructor( */ @JsonProperty("class_code") @ExcludeMissing fun _classCode(): JsonField = classCode - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField> = customFields - /** * Returns the raw JSON value of [department]. * @@ -588,14 +578,14 @@ private constructor( @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title /** - * Returns the raw JSON value of [workId]. + * Returns the raw JSON value of [customFields]. * - * Unlike [workId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. */ - @Deprecated("deprecated") - @JsonProperty("work_id") + @JsonProperty("custom_fields") @ExcludeMissing - fun _workId(): JsonField = workId + fun _customFields(): JsonField> = customFields /** * Returns the raw JSON value of [income]. @@ -621,6 +611,16 @@ private constructor( */ @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId + /** + * Returns the raw JSON value of [workId]. + * + * Unlike [workId], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("work_id") + @ExcludeMissing + fun _workId(): JsonField = workId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -642,7 +642,6 @@ private constructor( * ```java * .id() * .classCode() - * .customFields() * .department() * .employment() * .employmentStatus() @@ -656,7 +655,6 @@ private constructor( * .middleName() * .startDate() * .title() - * .workId() * ``` */ @JvmStatic fun builder() = Builder() @@ -667,7 +665,6 @@ private constructor( private var id: JsonField? = null private var classCode: JsonField? = null - private var customFields: JsonField>? = null private var department: JsonField? = null private var employment: JsonField? = null private var employmentStatus: JsonField? = null @@ -681,17 +678,17 @@ private constructor( private var middleName: JsonField? = null private var startDate: JsonField? = null private var title: JsonField? = null - private var workId: JsonField? = null + private var customFields: JsonField>? = null private var income: JsonField = JsonMissing.of() private var incomeHistory: JsonField>? = null private var sourceId: JsonField = JsonMissing.of() + private var workId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(unionMember0: UnionMember0) = apply { id = unionMember0.id classCode = unionMember0.classCode - customFields = unionMember0.customFields.map { it.toMutableList() } department = unionMember0.department employment = unionMember0.employment employmentStatus = unionMember0.employmentStatus @@ -705,10 +702,11 @@ private constructor( middleName = unionMember0.middleName startDate = unionMember0.startDate title = unionMember0.title - workId = unionMember0.workId + customFields = unionMember0.customFields.map { it.toMutableList() } income = unionMember0.income incomeHistory = unionMember0.incomeHistory.map { it.toMutableList() } sourceId = unionMember0.sourceId + workId = unionMember0.workId additionalProperties = unionMember0.additionalProperties.toMutableMap() } @@ -739,40 +737,6 @@ private constructor( */ fun classCode(classCode: JsonField) = apply { this.classCode = classCode } - /** - * Custom fields for the individual. These are fields which are defined by the employer - * in the system. Custom fields are not currently supported for assisted connections. - */ - fun customFields(customFields: List?) = - customFields(JsonField.ofNullable(customFields)) - - /** Alias for calling [Builder.customFields] with `customFields.orElse(null)`. */ - fun customFields(customFields: Optional>) = - customFields(customFields.getOrNull()) - - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun customFields(customFields: JsonField>) = apply { - this.customFields = customFields.map { it.toMutableList() } - } - - /** - * Adds a single [CustomField] to [customFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCustomField(customField: CustomField) = apply { - customFields = - (customFields ?: JsonField.of(mutableListOf())).also { - checkKnown("customFields", it).add(customField) - } - } - /** The department object. */ fun department(department: Department?) = department(JsonField.ofNullable(department)) @@ -990,23 +954,39 @@ private constructor( */ fun title(title: JsonField) = apply { this.title = title } - /** This field is deprecated in favour of `source_id` */ - @Deprecated("deprecated") - fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) + /** + * Custom fields for the individual. These are fields which are defined by the employer + * in the system. Custom fields are not currently supported for assisted connections. + */ + fun customFields(customFields: List?) = + customFields(JsonField.ofNullable(customFields)) - /** Alias for calling [Builder.workId] with `workId.orElse(null)`. */ - @Deprecated("deprecated") - fun workId(workId: Optional) = workId(workId.getOrNull()) + /** Alias for calling [Builder.customFields] with `customFields.orElse(null)`. */ + fun customFields(customFields: Optional>) = + customFields(customFields.getOrNull()) /** - * Sets [Builder.workId] to an arbitrary JSON value. + * Sets [Builder.customFields] to an arbitrary JSON value. * - * You should usually call [Builder.workId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.customFields] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @Deprecated("deprecated") - fun workId(workId: JsonField) = apply { this.workId = workId } + fun customFields(customFields: JsonField>) = apply { + this.customFields = customFields.map { it.toMutableList() } + } + + /** + * Adds a single [CustomField] to [customFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomField(customField: CustomField) = apply { + customFields = + (customFields ?: JsonField.of(mutableListOf())).also { + checkKnown("customFields", it).add(customField) + } + } /** * The employee's income as reported by the provider. This may not always be annualized @@ -1073,6 +1053,24 @@ private constructor( */ fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } + /** This field is deprecated in favour of `source_id` */ + @Deprecated("deprecated") + fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) + + /** Alias for calling [Builder.workId] with `workId.orElse(null)`. */ + @Deprecated("deprecated") + fun workId(workId: Optional) = workId(workId.getOrNull()) + + /** + * Sets [Builder.workId] to an arbitrary JSON value. + * + * You should usually call [Builder.workId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun workId(workId: JsonField) = apply { this.workId = workId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1101,7 +1099,6 @@ private constructor( * ```java * .id() * .classCode() - * .customFields() * .department() * .employment() * .employmentStatus() @@ -1115,7 +1112,6 @@ private constructor( * .middleName() * .startDate() * .title() - * .workId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1124,7 +1120,6 @@ private constructor( UnionMember0( checkRequired("id", id), checkRequired("classCode", classCode), - checkRequired("customFields", customFields).map { it.toImmutable() }, checkRequired("department", department), checkRequired("employment", employment), checkRequired("employmentStatus", employmentStatus), @@ -1138,10 +1133,11 @@ private constructor( checkRequired("middleName", middleName), checkRequired("startDate", startDate), checkRequired("title", title), - checkRequired("workId", workId), + (customFields ?: JsonMissing.of()).map { it.toImmutable() }, income, (incomeHistory ?: JsonMissing.of()).map { it.toImmutable() }, sourceId, + workId, additionalProperties.toMutableMap(), ) } @@ -1155,7 +1151,6 @@ private constructor( id() classCode() - customFields().ifPresent { it.forEach { it.validate() } } department().ifPresent { it.validate() } employment().ifPresent { it.validate() } employmentStatus().ifPresent { it.validate() } @@ -1169,10 +1164,11 @@ private constructor( middleName() startDate() title() - workId() + customFields().ifPresent { it.forEach { it.validate() } } income().ifPresent { it.validate() } incomeHistory().ifPresent { it.forEach { it?.validate() } } sourceId() + workId() validated = true } @@ -1194,7 +1190,6 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (classCode.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (department.asKnown().getOrNull()?.validity() ?: 0) + (employment.asKnown().getOrNull()?.validity() ?: 0) + (employmentStatus.asKnown().getOrNull()?.validity() ?: 0) + @@ -1208,37 +1203,33 @@ private constructor( (if (middleName.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (title.asKnown().isPresent) 1 else 0) + - (if (workId.asKnown().isPresent) 1 else 0) + + (customFields.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (income.asKnown().getOrNull()?.validity() ?: 0) + (incomeHistory.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (if (sourceId.asKnown().isPresent) 1 else 0) + (if (sourceId.asKnown().isPresent) 1 else 0) + + (if (workId.asKnown().isPresent) 1 else 0) - class CustomField + /** The department object. */ + class Department private constructor( private val name: JsonField, - private val value: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(name, value, mutableMapOf()) + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) /** + * The name of the department associated with the individual. + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun name(): Optional = name.getOptional("name") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun value(): Optional = value.getOptional("value") - /** * Returns the raw JSON value of [name]. * @@ -1246,13 +1237,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1267,24 +1251,30 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [CustomField]. */ + /** + * Returns a mutable builder for constructing an instance of [Department]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [CustomField]. */ + /** A builder for [Department]. */ class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(customField: CustomField) = apply { - name = customField.name - value = customField.value - additionalProperties = customField.additionalProperties.toMutableMap() + internal fun from(department: Department) = apply { + name = department.name + additionalProperties = department.additionalProperties.toMutableMap() } + /** The name of the department associated with the individual. */ fun name(name: String?) = name(JsonField.ofNullable(name)) /** Alias for calling [Builder.name] with `name.orElse(null)`. */ @@ -1299,36 +1289,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun value(value: Value?) = value(JsonField.ofNullable(value)) - - /** Alias for calling [Builder.value] with `value.orElse(null)`. */ - fun value(value: Optional) = value(value.getOrNull()) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Value] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofJsonValues(jsonValues)`. */ - fun valueOfJsonValues(jsonValues: List) = - value(Value.ofJsonValues(jsonValues)) - - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = value(Value.ofJson(json)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1352,23 +1312,29 @@ private constructor( } /** - * Returns an immutable instance of [CustomField]. + * Returns an immutable instance of [Department]. * * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomField = - CustomField(name, value, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Department = + Department(checkRequired("name", name), additionalProperties.toMutableMap()) + } - fun validate(): CustomField = apply { + private var validated: Boolean = false + + fun validate(): Department = apply { if (validated) { return@apply } name() - value().ifPresent { it.validate() } validated = true } @@ -1386,566 +1352,166 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + - (value.asKnown().getOrNull()?.validity() ?: 0) - - @JsonDeserialize(using = Value.Deserializer::class) - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val jsonValues: List? = null, - private val json: JsonValue? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) - - fun json(): Optional = Optional.ofNullable(json) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) + @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) - fun isString(): Boolean = string != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isJsonValues(): Boolean = jsonValues != null + return /* spotless:off */ other is Department && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun isJson(): Boolean = json != null + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + /* spotless:on */ - fun isNumber(): Boolean = number != null + override fun hashCode(): Int = hashCode - fun isBool(): Boolean = bool != null + override fun toString() = + "Department{name=$name, additionalProperties=$additionalProperties}" + } - fun asString(): String = string.getOrThrow("string") + /** The employment object. */ + class Employment + private constructor( + private val subtype: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + @JsonCreator + private constructor( + @JsonProperty("subtype") + @ExcludeMissing + subtype: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(subtype, type, mutableMapOf()) - fun asJson(): JsonValue = json.getOrThrow("json") + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subtype(): Optional = subtype.getOptional("subtype") - fun asNumber(): Double = number.getOrThrow("number") + /** + * The main employment type of the individual. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") - fun asBool(): Boolean = bool.getOrThrow("bool") + /** + * Returns the raw JSON value of [subtype]. + * + * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - jsonValues != null -> visitor.visitJsonValues(jsonValues) - json != null -> visitor.visitJson(json) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun validate(): Value = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - accept( - object : Visitor { - override fun visitString(string: String) {} + companion object { - override fun visitJsonValues(jsonValues: List) {} + /** + * Returns a mutable builder for constructing an instance of [Employment]. + * + * The following fields are required: + * ```java + * .subtype() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitJson(json: JsonValue) {} + /** A builder for [Employment]. */ + class Builder internal constructor() { - override fun visitNumber(number: Double) {} + private var subtype: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun visitBool(bool: Boolean) {} - } - ) - validated = true + @JvmSynthetic + internal fun from(employment: Employment) = apply { + subtype = employment.subtype + type = employment.type + additionalProperties = employment.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * The secondary employment type of the individual. Options: `full_time`, + * `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitJsonValues(jsonValues: List) = - jsonValues.size + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) - override fun visitJson(json: JsonValue) = 1 + /** Alias for calling [Builder.subtype] with `subtype.orElse(null)`. */ + fun subtype(subtype: Optional) = subtype(subtype.getOrNull()) - override fun visitNumber(number: Double) = 1 + /** + * Sets [Builder.subtype] to an arbitrary JSON value. + * + * You should usually call [Builder.subtype] with a well-typed [Subtype] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } - override fun visitBool(bool: Boolean) = 1 + /** The main employment type of the individual. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } - return /* spotless:off */ other is Value && string == other.string && jsonValues == other.jsonValues && json == other.json && number == other.number && bool == other.bool /* spotless:on */ + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, jsonValues, json, number, bool) /* spotless:on */ + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - jsonValues != null -> "Value{jsonValues=$jsonValues}" - json != null -> "Value{json=$json}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - companion object { - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic - fun ofJsonValues(jsonValues: List) = Value(jsonValues = jsonValues) - - @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - } - - /** - * An interface that defines how to map each variant of [Value] to a value of type - * [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitJsonValues(jsonValues: List): T - - fun visitJson(json: JsonValue): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of [Value] to a value of type [T]. - * - * An instance of [Value] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws FinchInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw FinchInvalidDataException("Unknown Value: $json") - } - } - - internal class Deserializer : BaseDeserializer(Value::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Value { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Value(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef>())?.let { - Value(jsonValues = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(bool = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(json = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants. - 0 -> Value(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.jsonValues != null -> generator.writeObject(value.jsonValues) - value.json != null -> generator.writeObject(value.json) - value.number != null -> generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomField && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomField{name=$name, value=$value, additionalProperties=$additionalProperties}" - } - - /** The department object. */ - class Department - private constructor( - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() - ) : this(name, mutableMapOf()) - - /** - * The name of the department associated with the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Department]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Department]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(department: Department) = apply { - name = department.name - additionalProperties = department.additionalProperties.toMutableMap() - } - - /** The name of the department associated with the individual. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Department]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Department = - Department(checkRequired("name", name), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Department = apply { - if (validated) { - return@apply - } - - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Department && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Department{name=$name, additionalProperties=$additionalProperties}" - } - - /** The employment object. */ - class Employment - private constructor( - private val subtype: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("subtype") - @ExcludeMissing - subtype: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(subtype, type, mutableMapOf()) - - /** - * The secondary employment type of the individual. Options: `full_time`, `part_time`, - * `intern`, `temp`, `seasonal` and `individual_contractor`. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subtype(): Optional = subtype.getOptional("subtype") - - /** - * The main employment type of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [subtype]. - * - * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Employment]. - * - * The following fields are required: - * ```java - * .subtype() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Employment]. */ - class Builder internal constructor() { - - private var subtype: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employment: Employment) = apply { - subtype = employment.subtype - type = employment.type - additionalProperties = employment.additionalProperties.toMutableMap() - } - - /** - * The secondary employment type of the individual. Options: `full_time`, - * `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`. - */ - fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) - - /** Alias for calling [Builder.subtype] with `subtype.orElse(null)`. */ - fun subtype(subtype: Optional) = subtype(subtype.getOrNull()) - - /** - * Sets [Builder.subtype] to an arbitrary JSON value. - * - * You should usually call [Builder.subtype] with a well-typed [Subtype] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun subtype(subtype: JsonField) = apply { this.subtype = subtype } - - /** The main employment type of the individual. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** @@ -2027,42 +1593,181 @@ private constructor( @JvmField val TEMP = of("temp") - @JvmField val SEASONAL = of("seasonal") + @JvmField val SEASONAL = of("seasonal") + + @JvmField val INDIVIDUAL_CONTRACTOR = of("individual_contractor") + + @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) + } + + /** An enum containing [Subtype]'s known values. */ + enum class Known { + FULL_TIME, + INTERN, + PART_TIME, + TEMP, + SEASONAL, + INDIVIDUAL_CONTRACTOR, + } + + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FULL_TIME, + INTERN, + PART_TIME, + TEMP, + SEASONAL, + INDIVIDUAL_CONTRACTOR, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FULL_TIME -> Value.FULL_TIME + INTERN -> Value.INTERN + PART_TIME -> Value.PART_TIME + TEMP -> Value.TEMP + SEASONAL -> Value.SEASONAL + INDIVIDUAL_CONTRACTOR -> Value.INDIVIDUAL_CONTRACTOR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FULL_TIME -> Known.FULL_TIME + INTERN -> Known.INTERN + PART_TIME -> Known.PART_TIME + TEMP -> Known.TEMP + SEASONAL -> Known.SEASONAL + INDIVIDUAL_CONTRACTOR -> Known.INDIVIDUAL_CONTRACTOR + else -> throw FinchInvalidDataException("Unknown Subtype: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Subtype = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Subtype && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The main employment type of the individual. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val EMPLOYEE = of("employee") - @JvmField val INDIVIDUAL_CONTRACTOR = of("individual_contractor") + @JvmField val CONTRACTOR = of("contractor") - @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - /** An enum containing [Subtype]'s known values. */ + /** An enum containing [Type]'s known values. */ enum class Known { - FULL_TIME, - INTERN, - PART_TIME, - TEMP, - SEASONAL, - INDIVIDUAL_CONTRACTOR, + EMPLOYEE, + CONTRACTOR, } /** - * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Subtype] can contain an unknown value in a couple of cases: + * An instance of [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 { - FULL_TIME, - INTERN, - PART_TIME, - TEMP, - SEASONAL, - INDIVIDUAL_CONTRACTOR, + EMPLOYEE, + CONTRACTOR, /** - * An enum member indicating that [Subtype] was instantiated with an unknown - * value. + * An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2076,12 +1781,8 @@ private constructor( */ fun value(): Value = when (this) { - FULL_TIME -> Value.FULL_TIME - INTERN -> Value.INTERN - PART_TIME -> Value.PART_TIME - TEMP -> Value.TEMP - SEASONAL -> Value.SEASONAL - INDIVIDUAL_CONTRACTOR -> Value.INDIVIDUAL_CONTRACTOR + EMPLOYEE -> Value.EMPLOYEE + CONTRACTOR -> Value.CONTRACTOR else -> Value._UNKNOWN } @@ -2096,13 +1797,9 @@ private constructor( */ fun known(): Known = when (this) { - FULL_TIME -> Known.FULL_TIME - INTERN -> Known.INTERN - PART_TIME -> Known.PART_TIME - TEMP -> Known.TEMP - SEASONAL -> Known.SEASONAL - INDIVIDUAL_CONTRACTOR -> Known.INDIVIDUAL_CONTRACTOR - else -> throw FinchInvalidDataException("Unknown Subtype: $value") + EMPLOYEE -> Known.EMPLOYEE + CONTRACTOR -> Known.CONTRACTOR + else -> throw FinchInvalidDataException("Unknown Type: $value") } /** @@ -2121,7 +1818,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Subtype = apply { + fun validate(): Type = apply { if (validated) { return@apply } @@ -2146,303 +1843,518 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Employment && subtype == other.subtype && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(subtype, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * The 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 { + + @JvmField val ACTIVE = of("active") + + @JvmField val DECEASED = of("deceased") + + @JvmField val LEAVE = of("leave") + + @JvmField val ONBOARDING = of("onboarding") + + @JvmField val PREHIRE = of("prehire") + + @JvmField val RETIRED = of("retired") + + @JvmField val TERMINATED = of("terminated") + + @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) + } + + /** An enum containing [EmploymentStatus]'s known values. */ + enum class Known { + ACTIVE, + DECEASED, + LEAVE, + ONBOARDING, + PREHIRE, + RETIRED, + TERMINATED, + } + + /** + * 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, + LEAVE, + ONBOARDING, + 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 + DECEASED -> Value.DECEASED + LEAVE -> Value.LEAVE + ONBOARDING -> Value.ONBOARDING + PREHIRE -> Value.PREHIRE + RETIRED -> Value.RETIRED + TERMINATED -> Value.TERMINATED + 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 + DECEASED -> Known.DECEASED + LEAVE -> Known.LEAVE + ONBOARDING -> Known.ONBOARDING + PREHIRE -> Known.PREHIRE + RETIRED -> Known.RETIRED + TERMINATED -> Known.TERMINATED + else -> throw FinchInvalidDataException("Unknown EmploymentStatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): EmploymentStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EmploymentStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The manager object representing the manager of the individual within the org. */ + class Manager + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - return /* spotless:off */ other is Subtype && value == other.value /* spotless:on */ - } + /** + * A stable Finch `id` (UUID v4) for an individual in the company. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - override fun toString() = value.toString() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** The main employment type of the individual. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Returns this class instance's raw value. + * Returns a mutable builder for constructing an instance of [Manager]. * - * 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. + * The following fields are required: + * ```java + * .id() + * ``` */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EMPLOYEE = of("employee") - - @JvmField val CONTRACTOR = of("contractor") + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + /** A builder for [Manager]. */ + class Builder internal constructor() { - /** An enum containing [Type]'s known values. */ - enum class Known { - EMPLOYEE, - CONTRACTOR, - } + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EMPLOYEE, - CONTRACTOR, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, + @JvmSynthetic + internal fun from(manager: Manager) = apply { + id = manager.id + additionalProperties = manager.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EMPLOYEE -> Value.EMPLOYEE - CONTRACTOR -> Value.CONTRACTOR - else -> Value._UNKNOWN - } + /** A stable Finch `id` (UUID v4) for an individual in the company. */ + fun id(id: String) = id(JsonField.of(id)) /** - * 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. + * Sets [Builder.id] to an arbitrary JSON value. * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun known(): Known = - when (this) { - EMPLOYEE -> Known.EMPLOYEE - CONTRACTOR -> Known.CONTRACTOR - else -> throw FinchInvalidDataException("Unknown Type: $value") - } + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): Type = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - known() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [Manager]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun build(): Manager = + Manager(checkRequired("id", id), additionalProperties.toMutableMap()) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + fun validate(): Manager = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + id() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Employment && subtype == other.subtype && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Manager && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(subtype, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Manager{id=$id, additionalProperties=$additionalProperties}" } - /** - * The detailed employment status of the individual. Available options: `active`, - * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. - */ - class EmploymentStatus - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class CustomField + private constructor( + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(name, value, mutableMapOf()) /** - * Returns this class instance's raw value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [value]. * - * 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. + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) companion object { - @JvmField val ACTIVE = of("active") + /** Returns a mutable builder for constructing an instance of [CustomField]. */ + @JvmStatic fun builder() = Builder() + } - @JvmField val DECEASED = of("deceased") + /** A builder for [CustomField]. */ + class Builder internal constructor() { - @JvmField val LEAVE = of("leave") + private var name: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val ONBOARDING = of("onboarding") + @JvmSynthetic + internal fun from(customField: CustomField) = apply { + name = customField.name + value = customField.value + additionalProperties = customField.additionalProperties.toMutableMap() + } - @JvmField val PREHIRE = of("prehire") + fun name(name: String?) = name(JsonField.ofNullable(name)) - @JvmField val RETIRED = of("retired") + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) - @JvmField val TERMINATED = of("terminated") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) - } + fun value(value: Value?) = value(JsonField.ofNullable(value)) - /** An enum containing [EmploymentStatus]'s known values. */ - enum class Known { - ACTIVE, - DECEASED, - LEAVE, - ONBOARDING, - PREHIRE, - RETIRED, - TERMINATED, - } + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional) = value(value.getOrNull()) - /** - * 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, - LEAVE, - ONBOARDING, - PREHIRE, - RETIRED, - TERMINATED, /** - * An enum member indicating that [EmploymentStatus] was instantiated with an - * unknown value. + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - _UNKNOWN, - } + fun value(value: JsonField) = apply { this.value = value } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - DECEASED -> Value.DECEASED - LEAVE -> Value.LEAVE - ONBOARDING -> Value.ONBOARDING - PREHIRE -> Value.PREHIRE - RETIRED -> Value.RETIRED - TERMINATED -> Value.TERMINATED - else -> Value._UNKNOWN + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofJsonValues(jsonValues)`. */ + fun valueOfJsonValues(jsonValues: List) = + value(Value.ofJsonValues(jsonValues)) + + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = value(Value.ofJson(json)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - DECEASED -> Known.DECEASED - LEAVE -> Known.LEAVE - ONBOARDING -> Known.ONBOARDING - PREHIRE -> Known.PREHIRE - RETIRED -> Known.RETIRED - TERMINATED -> Known.TERMINATED - else -> throw FinchInvalidDataException("Unknown EmploymentStatus: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [CustomField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomField = + CustomField(name, value, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false - fun validate(): EmploymentStatus = apply { + fun validate(): CustomField = apply { if (validated) { return@apply } - known() + name() + value().ifPresent { it.validate() } validated = true } @@ -2460,178 +2372,262 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val jsonValues: List? = null, + private val json: JsonValue? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { - return /* spotless:off */ other is EmploymentStatus && value == other.value /* spotless:on */ - } + fun string(): Optional = Optional.ofNullable(string) - override fun hashCode() = value.hashCode() + fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) - override fun toString() = value.toString() - } + fun json(): Optional = Optional.ofNullable(json) - /** The manager object representing the manager of the individual within the org. */ - class Manager - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isJsonValues(): Boolean = jsonValues != null + + fun isJson(): Boolean = json != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + + fun asJson(): JsonValue = json.getOrThrow("json") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + jsonValues != null -> visitor.visitJsonValues(jsonValues) + json != null -> visitor.visitJson(json) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + private var validated: Boolean = false - /** - * A stable Finch `id` (UUID v4) for an individual in the company. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + fun validate(): Value = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + accept( + object : Visitor { + override fun visitString(string: String) {} - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitJsonValues(jsonValues: List) {} - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitJson(json: JsonValue) {} - fun toBuilder() = Builder().from(this) + override fun visitNumber(number: Double) {} - companion object { + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of [Manager]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```java - * .id() - * ``` + * Used for best match union deserialization. */ - @JvmStatic fun builder() = Builder() - } + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 - /** A builder for [Manager]. */ - class Builder internal constructor() { + override fun visitJsonValues(jsonValues: List) = + jsonValues.size - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + override fun visitJson(json: JsonValue) = 1 - @JvmSynthetic - internal fun from(manager: Manager) = apply { - id = manager.id - additionalProperties = manager.additionalProperties.toMutableMap() - } + override fun visitNumber(number: Double) = 1 - /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: String) = id(JsonField.of(id)) + override fun visitBool(bool: Boolean) = 1 - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + override fun unknown(json: JsonValue?) = 0 + } + ) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + return /* spotless:off */ other is Value && string == other.string && jsonValues == other.jsonValues && json == other.json && number == other.number && bool == other.bool /* spotless:on */ } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, jsonValues, json, number, bool) /* spotless:on */ + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + jsonValues != null -> "Value{jsonValues=$jsonValues}" + json != null -> "Value{json=$json}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + companion object { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic + fun ofJsonValues(jsonValues: List) = Value(jsonValues = jsonValues) + + @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) } /** - * Returns an immutable instance of [Manager]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * An interface that defines how to map each variant of [Value] to a value of type + * [T]. */ - fun build(): Manager = - Manager(checkRequired("id", id), additionalProperties.toMutableMap()) - } + interface Visitor { - private var validated: Boolean = false + fun visitString(string: String): T - fun validate(): Manager = apply { - if (validated) { - return@apply + fun visitJsonValues(jsonValues: List): T + + fun visitJson(json: JsonValue): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws FinchInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw FinchInvalidDataException("Unknown Value: $json") + } } - id() - validated = true - } + internal class Deserializer : BaseDeserializer(Value::class) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Value(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(json = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValues != null -> generator.writeObject(value.jsonValues) + value.json != null -> generator.writeObject(value.json) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Manager && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CustomField && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, value, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Manager{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = + "CustomField{name=$name, value=$value, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -2639,17 +2635,17 @@ private constructor( return true } - return /* spotless:off */ other is UnionMember0 && id == other.id && classCode == other.classCode && customFields == other.customFields && department == other.department && employment == other.employment && employmentStatus == other.employmentStatus && endDate == other.endDate && firstName == other.firstName && isActive == other.isActive && lastName == other.lastName && latestRehireDate == other.latestRehireDate && location == other.location && manager == other.manager && middleName == other.middleName && startDate == other.startDate && title == other.title && workId == other.workId && income == other.income && incomeHistory == other.incomeHistory && sourceId == other.sourceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && id == other.id && classCode == other.classCode && department == other.department && employment == other.employment && employmentStatus == other.employmentStatus && endDate == other.endDate && firstName == other.firstName && isActive == other.isActive && lastName == other.lastName && latestRehireDate == other.latestRehireDate && location == other.location && manager == other.manager && middleName == other.middleName && startDate == other.startDate && title == other.title && customFields == other.customFields && income == other.income && incomeHistory == other.incomeHistory && sourceId == other.sourceId && workId == other.workId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, classCode, customFields, department, employment, employmentStatus, endDate, firstName, isActive, lastName, latestRehireDate, location, manager, middleName, startDate, title, workId, income, incomeHistory, sourceId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, classCode, department, employment, employmentStatus, endDate, firstName, isActive, lastName, latestRehireDate, location, manager, middleName, startDate, title, customFields, income, incomeHistory, sourceId, workId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "UnionMember0{id=$id, classCode=$classCode, customFields=$customFields, department=$department, employment=$employment, employmentStatus=$employmentStatus, endDate=$endDate, firstName=$firstName, isActive=$isActive, lastName=$lastName, latestRehireDate=$latestRehireDate, location=$location, manager=$manager, middleName=$middleName, startDate=$startDate, title=$title, workId=$workId, income=$income, incomeHistory=$incomeHistory, sourceId=$sourceId, additionalProperties=$additionalProperties}" + "UnionMember0{id=$id, classCode=$classCode, department=$department, employment=$employment, employmentStatus=$employmentStatus, endDate=$endDate, firstName=$firstName, isActive=$isActive, lastName=$lastName, latestRehireDate=$latestRehireDate, location=$location, manager=$manager, middleName=$middleName, startDate=$startDate, title=$title, customFields=$customFields, income=$income, incomeHistory=$incomeHistory, sourceId=$sourceId, workId=$workId, additionalProperties=$additionalProperties}" } class BatchError 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 dfc47dd0..672d1d92 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 @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitIndividualRetrieveManyBenefitsParams = throw IllegalStateException("Cannot construct next page params") 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 85f9ba74..22b85713 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 @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitIndividualRetrieveManyBenefitsParams = throw IllegalStateException("Cannot construct next page params") 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 fbcf2ff6..09ca0633 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 @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitListParams = throw IllegalStateException("Cannot construct next page params") 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 9cd78291..884830d5 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 @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitListParams = throw IllegalStateException("Cannot construct next page params") 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 3409c4b3..15f3d0c8 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 @@ -15,10 +15,10 @@ class HrisBenefitListSupportedBenefitsPage private constructor( private val service: BenefitService, private val params: HrisBenefitListSupportedBenefitsParams, - private val items: List, -) : Page { + private val items: List, +) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitListSupportedBenefitsParams = throw IllegalStateException("Cannot construct next page params") @@ -26,13 +26,13 @@ private constructor( override fun nextPage(): HrisBenefitListSupportedBenefitsPage = service.listSupportedBenefits(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): HrisBenefitListSupportedBenefitsParams = params /** The response that this page was parsed from. */ - override fun items(): List = items + override fun items(): List = items fun toBuilder() = Builder().from(this) @@ -57,7 +57,7 @@ private constructor( private var service: BenefitService? = null private var params: HrisBenefitListSupportedBenefitsParams? = null - private var items: Optional>? = null + private var items: Optional>? = null @JvmSynthetic internal fun from( @@ -74,9 +74,7 @@ private constructor( fun params(params: HrisBenefitListSupportedBenefitsParams) = apply { this.params = params } /** The response that this page was parsed from. */ - fun items(items: Optional>) = apply { - this.items = items - } + fun items(items: Optional>) = apply { this.items = items } /** * Returns an immutable instance of [HrisBenefitListSupportedBenefitsPage]. 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 3f3abf51..cdbc03ea 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 @@ -18,10 +18,10 @@ private constructor( private val service: BenefitServiceAsync, private val streamHandlerExecutor: Executor, private val params: HrisBenefitListSupportedBenefitsParams, - private val items: List, -) : PageAsync { + private val items: List, +) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitListSupportedBenefitsParams = throw IllegalStateException("Cannot construct next page params") @@ -29,14 +29,14 @@ private constructor( override fun nextPage(): CompletableFuture = service.listSupportedBenefits(nextPageParams()) - fun autoPager(): AutoPagerAsync = + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): HrisBenefitListSupportedBenefitsParams = params /** The response that this page was parsed from. */ - override fun items(): List = items + override fun items(): List = items fun toBuilder() = Builder().from(this) @@ -63,7 +63,7 @@ private constructor( private var service: BenefitServiceAsync? = null private var streamHandlerExecutor: Executor? = null private var params: HrisBenefitListSupportedBenefitsParams? = null - private var items: Optional>? = null + private var items: Optional>? = null @JvmSynthetic internal fun from( @@ -85,9 +85,7 @@ private constructor( fun params(params: HrisBenefitListSupportedBenefitsParams) = apply { this.params = params } /** The response that this page was parsed from. */ - fun items(items: Optional>) = apply { - this.items = items - } + fun items(items: Optional>) = apply { this.items = items } /** * Returns an immutable instance of [HrisBenefitListSupportedBenefitsPageAsync]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt index 823bce21..38a27d53 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt @@ -28,7 +28,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisCompanyPayStatementItemListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageAsync.kt index a39ed6ef..9ad7c8d2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageAsync.kt @@ -31,7 +31,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisCompanyPayStatementItemListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt index 580d9169..6e23fe25 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt @@ -28,7 +28,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisCompanyPayStatementItemRuleListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt index 1a083316..623b1a8a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt @@ -31,7 +31,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisCompanyPayStatementItemRuleListParams = throw IllegalStateException("Cannot construct next page params") 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 a4fb48cd..ac8306aa 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 @@ -27,7 +27,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisEmploymentRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") 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 91ccab5d..f00e98c9 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 @@ -30,7 +30,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisEmploymentRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") 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 ac6fca75..19d656c2 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 @@ -27,7 +27,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisIndividualRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") 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 efacc397..c9a0aeb5 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 @@ -30,7 +30,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisIndividualRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") 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 ce24980a..09c3d3b8 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 @@ -27,7 +27,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisPayStatementRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") 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 ff0099a3..df55d75d 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 @@ -30,7 +30,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisPayStatementRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") 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 9cf9d9a5..66eef149 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 @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisPaymentListParams = throw IllegalStateException("Cannot construct next page params") 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 ee77147a..e5164328 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 @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisPaymentListParams = throw IllegalStateException("Cannot construct next page params") 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 99e6b081..9a9fc1d3 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 @@ -13,6 +13,7 @@ import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.checkRequired import com.tryfinch.api.errors.FinchInvalidDataException +import java.time.LocalDate import java.util.Collections import java.util.Objects import java.util.Optional @@ -27,7 +28,7 @@ class Income private constructor( private val amount: JsonField, private val currency: JsonField, - private val effectiveDate: JsonField, + private val effectiveDate: JsonField, private val unit: JsonField, private val additionalProperties: MutableMap, ) { @@ -38,7 +39,7 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("effective_date") @ExcludeMissing - effectiveDate: JsonField = JsonMissing.of(), + effectiveDate: JsonField = JsonMissing.of(), @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), ) : this(amount, currency, effectiveDate, unit, mutableMapOf()) @@ -64,7 +65,7 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun effectiveDate(): Optional = effectiveDate.getOptional("effective_date") + fun effectiveDate(): Optional = effectiveDate.getOptional("effective_date") /** * The income unit of payment. Options: `yearly`, `quarterly`, `monthly`, `semi_monthly`, @@ -96,7 +97,7 @@ private constructor( */ @JsonProperty("effective_date") @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate + fun _effectiveDate(): JsonField = effectiveDate /** * Returns the raw JSON value of [unit]. @@ -138,7 +139,7 @@ private constructor( private var amount: JsonField? = null private var currency: JsonField? = null - private var effectiveDate: JsonField? = null + private var effectiveDate: JsonField? = null private var unit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -187,21 +188,21 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } /** The date the income amount went into effect. */ - fun effectiveDate(effectiveDate: String?) = + fun effectiveDate(effectiveDate: LocalDate?) = effectiveDate(JsonField.ofNullable(effectiveDate)) /** Alias for calling [Builder.effectiveDate] with `effectiveDate.orElse(null)`. */ - fun effectiveDate(effectiveDate: Optional) = + fun effectiveDate(effectiveDate: Optional) = effectiveDate(effectiveDate.getOrNull()) /** * Sets [Builder.effectiveDate] to an arbitrary JSON value. * - * You should usually call [Builder.effectiveDate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.effectiveDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun effectiveDate(effectiveDate: JsonField) = apply { + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } 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 c9badec1..137e061e 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 @@ -10,6 +10,7 @@ import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -38,10 +39,10 @@ private constructor( fun amount(): Optional = amount.getOptional("amount") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun currency(): Optional = currency.getOptional("currency") + fun currency(): String = currency.getRequired("currency") /** * Returns the raw JSON value of [amount]. @@ -71,15 +72,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Money]. */ + /** + * Returns a mutable builder for constructing an instance of [Money]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Money]. */ class Builder internal constructor() { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -143,8 +152,21 @@ private constructor( * Returns an immutable instance of [Money]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Money = Money(amount, currency, additionalProperties.toMutableMap()) + fun build(): Money = + Money( + checkRequired("amount", amount), + checkRequired("currency", currency), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false 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 608a9101..a5826485 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 @@ -12,11 +12,11 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects -import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayGroupListResponse @@ -39,27 +39,26 @@ private constructor( /** * Finch id (uuidv4) for the pay group * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun id(): Optional = id.getOptional("id") + fun id(): String = id.getRequired("id") /** * Name of the pay group * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun name(): Optional = name.getOptional("name") + fun name(): String = name.getRequired("name") /** * List of pay frequencies associated with this pay group * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun payFrequencies(): Optional> = - payFrequencies.getOptional("pay_frequencies") + fun payFrequencies(): List = payFrequencies.getRequired("pay_frequencies") /** * Returns the raw JSON value of [id]. @@ -98,15 +97,24 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayGroupListResponse]. */ + /** + * Returns a mutable builder for constructing an instance of [PayGroupListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .payFrequencies() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [PayGroupListResponse]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var payFrequencies: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -190,12 +198,21 @@ private constructor( * Returns an immutable instance of [PayGroupListResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .payFrequencies() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayGroupListResponse = PayGroupListResponse( - id, - name, - (payFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("payFrequencies", payFrequencies).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -209,7 +226,7 @@ private constructor( id() name() - payFrequencies().ifPresent { it.forEach { it.validate() } } + payFrequencies().forEach { it.validate() } validated = true } @@ -249,21 +266,21 @@ private constructor( @JvmField val ANNUALLY = of("annually") - @JvmField val SEMI_ANNUALLY = of("semi_annually") + @JvmField val BI_WEEKLY = of("bi_weekly") - @JvmField val QUARTERLY = of("quarterly") + @JvmField val DAILY = of("daily") @JvmField val MONTHLY = of("monthly") - @JvmField val SEMI_MONTHLY = of("semi_monthly") + @JvmField val OTHER = of("other") - @JvmField val BI_WEEKLY = of("bi_weekly") + @JvmField val QUARTERLY = of("quarterly") - @JvmField val WEEKLY = of("weekly") + @JvmField val SEMI_ANNUALLY = of("semi_annually") - @JvmField val DAILY = of("daily") + @JvmField val SEMI_MONTHLY = of("semi_monthly") - @JvmField val OTHER = of("other") + @JvmField val WEEKLY = of("weekly") @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } @@ -271,14 +288,14 @@ private constructor( /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, } /** @@ -292,14 +309,14 @@ private constructor( */ enum class Value { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, /** * An enum member indicating that [PayFrequency] was instantiated with an unknown value. */ @@ -316,14 +333,14 @@ private constructor( fun value(): Value = when (this) { ANNUALLY -> Value.ANNUALLY - SEMI_ANNUALLY -> Value.SEMI_ANNUALLY - QUARTERLY -> Value.QUARTERLY - MONTHLY -> Value.MONTHLY - SEMI_MONTHLY -> Value.SEMI_MONTHLY BI_WEEKLY -> Value.BI_WEEKLY - WEEKLY -> Value.WEEKLY DAILY -> Value.DAILY + MONTHLY -> Value.MONTHLY OTHER -> Value.OTHER + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUALLY -> Value.SEMI_ANNUALLY + SEMI_MONTHLY -> Value.SEMI_MONTHLY + WEEKLY -> Value.WEEKLY else -> Value._UNKNOWN } @@ -338,14 +355,14 @@ private constructor( fun known(): Known = when (this) { ANNUALLY -> Known.ANNUALLY - SEMI_ANNUALLY -> Known.SEMI_ANNUALLY - QUARTERLY -> Known.QUARTERLY - MONTHLY -> Known.MONTHLY - SEMI_MONTHLY -> Known.SEMI_MONTHLY BI_WEEKLY -> Known.BI_WEEKLY - WEEKLY -> Known.WEEKLY DAILY -> Known.DAILY + MONTHLY -> Known.MONTHLY OTHER -> Known.OTHER + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUALLY -> Known.SEMI_ANNUALLY + SEMI_MONTHLY -> Known.SEMI_MONTHLY + WEEKLY -> Known.WEEKLY else -> throw FinchInvalidDataException("Unknown PayFrequency: $value") } 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 e6e2c27b..8e93a1cc 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 @@ -317,21 +317,21 @@ private constructor( @JvmField val ANNUALLY = of("annually") - @JvmField val SEMI_ANNUALLY = of("semi_annually") + @JvmField val BI_WEEKLY = of("bi_weekly") - @JvmField val QUARTERLY = of("quarterly") + @JvmField val DAILY = of("daily") @JvmField val MONTHLY = of("monthly") - @JvmField val SEMI_MONTHLY = of("semi_monthly") + @JvmField val OTHER = of("other") - @JvmField val BI_WEEKLY = of("bi_weekly") + @JvmField val QUARTERLY = of("quarterly") - @JvmField val WEEKLY = of("weekly") + @JvmField val SEMI_ANNUALLY = of("semi_annually") - @JvmField val DAILY = of("daily") + @JvmField val SEMI_MONTHLY = of("semi_monthly") - @JvmField val OTHER = of("other") + @JvmField val WEEKLY = of("weekly") @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } @@ -339,14 +339,14 @@ private constructor( /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, } /** @@ -360,14 +360,14 @@ private constructor( */ enum class Value { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, /** * An enum member indicating that [PayFrequency] was instantiated with an unknown value. */ @@ -384,14 +384,14 @@ private constructor( fun value(): Value = when (this) { ANNUALLY -> Value.ANNUALLY - SEMI_ANNUALLY -> Value.SEMI_ANNUALLY - QUARTERLY -> Value.QUARTERLY - MONTHLY -> Value.MONTHLY - SEMI_MONTHLY -> Value.SEMI_MONTHLY BI_WEEKLY -> Value.BI_WEEKLY - WEEKLY -> Value.WEEKLY DAILY -> Value.DAILY + MONTHLY -> Value.MONTHLY OTHER -> Value.OTHER + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUALLY -> Value.SEMI_ANNUALLY + SEMI_MONTHLY -> Value.SEMI_MONTHLY + WEEKLY -> Value.WEEKLY else -> Value._UNKNOWN } @@ -406,14 +406,14 @@ private constructor( fun known(): Known = when (this) { ANNUALLY -> Known.ANNUALLY - SEMI_ANNUALLY -> Known.SEMI_ANNUALLY - QUARTERLY -> Known.QUARTERLY - MONTHLY -> Known.MONTHLY - SEMI_MONTHLY -> Known.SEMI_MONTHLY BI_WEEKLY -> Known.BI_WEEKLY - WEEKLY -> Known.WEEKLY DAILY -> Known.DAILY + MONTHLY -> Known.MONTHLY OTHER -> Known.OTHER + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUALLY -> Known.SEMI_ANNUALLY + SEMI_MONTHLY -> Known.SEMI_MONTHLY + WEEKLY -> Known.WEEKLY else -> throw FinchInvalidDataException("Unknown PayFrequency: $value") } 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 805ed50b..a30617de 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -105,10 +106,10 @@ private constructor( /** * A stable Finch `id` (UUID v4) for an individual in the company * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun individualId(): Optional = individualId.getOptional("individual_id") + fun individualId(): String = individualId.getRequired("individual_id") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -242,7 +243,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayStatement]. */ + /** + * Returns a mutable builder for constructing an instance of [PayStatement]. + * + * The following fields are required: + * ```java + * .earnings() + * .employeeDeductions() + * .employerContributions() + * .grossPay() + * .individualId() + * .netPay() + * .paymentMethod() + * .taxes() + * .totalHours() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -252,13 +269,13 @@ private constructor( private var earnings: JsonField>? = null private var employeeDeductions: JsonField>? = null private var employerContributions: JsonField>? = null - private var grossPay: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var netPay: JsonField = JsonMissing.of() - private var paymentMethod: JsonField = JsonMissing.of() + private var grossPay: JsonField? = null + private var individualId: JsonField? = null + private var netPay: JsonField? = null + private var paymentMethod: JsonField? = null private var taxes: JsonField>? = null - private var totalHours: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var totalHours: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -517,19 +534,37 @@ private constructor( * Returns an immutable instance of [PayStatement]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .earnings() + * .employeeDeductions() + * .employerContributions() + * .grossPay() + * .individualId() + * .netPay() + * .paymentMethod() + * .taxes() + * .totalHours() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayStatement = PayStatement( - (earnings ?: JsonMissing.of()).map { it.toImmutable() }, - (employeeDeductions ?: JsonMissing.of()).map { it.toImmutable() }, - (employerContributions ?: JsonMissing.of()).map { it.toImmutable() }, - grossPay, - individualId, - netPay, - paymentMethod, - (taxes ?: JsonMissing.of()).map { it.toImmutable() }, - totalHours, - type, + checkRequired("earnings", earnings).map { it.toImmutable() }, + checkRequired("employeeDeductions", employeeDeductions).map { it.toImmutable() }, + checkRequired("employerContributions", employerContributions).map { + it.toImmutable() + }, + checkRequired("grossPay", grossPay), + checkRequired("individualId", individualId), + checkRequired("netPay", netPay), + checkRequired("paymentMethod", paymentMethod), + checkRequired("taxes", taxes).map { it.toImmutable() }, + checkRequired("totalHours", totalHours), + checkRequired("type", type), additionalProperties.toMutableMap(), ) } @@ -585,27 +620,27 @@ private constructor( class Earning private constructor( private val amount: JsonField, - private val attributes: JsonField, private val currency: JsonField, private val hours: JsonField, private val name: JsonField, private val type: JsonField, + private val attributes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("hours") @ExcludeMissing hours: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, hours, name, type, mutableMapOf()) + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(amount, currency, hours, name, type, attributes, mutableMapOf()) /** * The earnings amount in cents. @@ -615,12 +650,6 @@ private constructor( */ fun amount(): Optional = amount.getOptional("amount") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - /** * The earnings currency code. * @@ -655,20 +684,17 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun attributes(): Optional = attributes.getOptional("attributes") /** - * Returns the raw JSON value of [attributes]. + * Returns the raw JSON value of [amount]. * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * Returns the raw JSON value of [currency]. @@ -698,6 +724,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -712,29 +747,40 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Earning]. */ + /** + * Returns a mutable builder for constructing an instance of [Earning]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .hours() + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Earning]. */ class Builder internal constructor() { - private var amount: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null + private var hours: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var hours: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(earning: Earning) = apply { amount = earning.amount - attributes = earning.attributes currency = earning.currency hours = earning.hours name = earning.name type = earning.type + attributes = earning.attributes additionalProperties = earning.additionalProperties.toMutableMap() } @@ -760,22 +806,6 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - /** The earnings currency code. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -846,6 +876,22 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -869,15 +915,26 @@ private constructor( * Returns an immutable instance of [Earning]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .hours() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Earning = Earning( - amount, + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("hours", hours), + checkRequired("name", name), + checkRequired("type", type), attributes, - currency, - hours, - name, - type, additionalProperties.toMutableMap(), ) } @@ -890,11 +947,11 @@ private constructor( } amount() - attributes().ifPresent { it.validate() } currency() hours() name() type().ifPresent { it.validate() } + attributes().ifPresent { it.validate() } validated = true } @@ -915,162 +972,376 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (hours.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + /** The type of earning. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { /** - * Returns the raw JSON value of [metadata]. + * Returns this class instance's raw value. * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { + @JvmField val SALARY = of("salary") - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val WAGE = of("wage") - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } + @JvmField val REIMBURSEMENT = of("reimbursement") - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + @JvmField val OVERTIME = of("overtime") - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + @JvmField val SEVERANCE = of("severance") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val DOUBLE_OVERTIME = of("double_overtime") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val PTO = of("pto") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val SICK = of("sick") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val BONUS = of("bonus") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val COMMISSION = of("commission") - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Attributes = Attributes(metadata, additionalProperties.toMutableMap()) - } + @JvmField val TIPS = of("tips") - private var validated: Boolean = false + @JvmField val _1099 = of("1099") - fun validate(): Attributes = apply { - if (validated) { - return@apply - } + @JvmField val OTHER = of("other") - metadata().ifPresent { it.validate() } - validated = true + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** An enum containing [Type]'s known values. */ + enum class Known { + SALARY, + WAGE, + REIMBURSEMENT, + OVERTIME, + SEVERANCE, + DOUBLE_OVERTIME, + PTO, + SICK, + BONUS, + COMMISSION, + TIPS, + _1099, + OTHER, + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * - * Used for best match union deserialization. + * 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. */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) + enum class Value { + SALARY, + WAGE, + REIMBURSEMENT, + OVERTIME, + SEVERANCE, + DOUBLE_OVERTIME, + PTO, + SICK, + BONUS, + COMMISSION, + 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 + WAGE -> Value.WAGE + REIMBURSEMENT -> Value.REIMBURSEMENT + OVERTIME -> Value.OVERTIME + SEVERANCE -> Value.SEVERANCE + DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME + PTO -> Value.PTO + SICK -> Value.SICK + BONUS -> Value.BONUS + COMMISSION -> Value.COMMISSION + TIPS -> Value.TIPS + _1099 -> Value._1099 + OTHER -> Value.OTHER + 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 + WAGE -> Known.WAGE + REIMBURSEMENT -> Known.REIMBURSEMENT + OVERTIME -> Known.OVERTIME + SEVERANCE -> Known.SEVERANCE + DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME + PTO -> Known.PTO + SICK -> Known.SICK + BONUS -> Known.BONUS + COMMISSION -> Known.COMMISSION + TIPS -> Known.TIPS + _1099 -> Known._1099 + OTHER -> Known.OTHER + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) /** * The metadata to be attached to the entity by existing rules. It is a key-value * pairs where the values can be of any type (string, number, boolean, object, * array, etc.). * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): InnerMetadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -1096,14 +1367,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1156,8 +1434,19 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(metadata, additionalProperties.toMutableMap()) + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1167,7 +1456,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -1341,242 +1630,48 @@ private constructor( "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" } - /** The type of earning. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * 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 SALARY = of("salary") - - @JvmField val WAGE = of("wage") - - @JvmField val REIMBURSEMENT = of("reimbursement") - - @JvmField val OVERTIME = of("overtime") - - @JvmField val SEVERANCE = of("severance") - - @JvmField val DOUBLE_OVERTIME = of("double_overtime") - - @JvmField val PTO = of("pto") - - @JvmField val SICK = of("sick") - - @JvmField val BONUS = of("bonus") - - @JvmField val COMMISSION = of("commission") - - @JvmField val TIPS = of("tips") - - @JvmField val _1099 = of("1099") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - 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, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - 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 - WAGE -> Value.WAGE - REIMBURSEMENT -> Value.REIMBURSEMENT - OVERTIME -> Value.OVERTIME - SEVERANCE -> Value.SEVERANCE - DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME - PTO -> Value.PTO - SICK -> Value.SICK - BONUS -> Value.BONUS - COMMISSION -> Value.COMMISSION - TIPS -> Value.TIPS - _1099 -> Value._1099 - OTHER -> Value.OTHER - 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 - WAGE -> Known.WAGE - REIMBURSEMENT -> Known.REIMBURSEMENT - OVERTIME -> Known.OVERTIME - SEVERANCE -> Known.SEVERANCE - DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME - PTO -> Known.PTO - SICK -> Known.SICK - BONUS -> Known.BONUS - COMMISSION -> Known.COMMISSION - TIPS -> Known.TIPS - _1099 -> Known._1099 - OTHER -> Known.OTHER - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Earning && amount == other.amount && attributes == other.attributes && currency == other.currency && hours == other.hours && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Earning && amount == other.amount && currency == other.currency && hours == other.hours && name == other.name && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, hours, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, currency, hours, name, type, attributes, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Earning{amount=$amount, attributes=$attributes, currency=$currency, hours=$hours, name=$name, type=$type, additionalProperties=$additionalProperties}" + "Earning{amount=$amount, currency=$currency, hours=$hours, name=$name, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" } class EmployeeDeduction private constructor( private val amount: JsonField, - private val attributes: JsonField, private val currency: JsonField, private val name: JsonField, private val preTax: JsonField, private val type: JsonField, + private val attributes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("pre_tax") @ExcludeMissing preTax: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, name, preTax, type, mutableMapOf()) + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(amount, currency, name, preTax, type, attributes, mutableMapOf()) /** * The deduction amount in cents. @@ -1586,12 +1681,6 @@ private constructor( */ fun amount(): Optional = amount.getOptional("amount") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - /** * The deduction currency. * @@ -1625,20 +1714,17 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun attributes(): Optional = attributes.getOptional("attributes") /** - * Returns the raw JSON value of [attributes]. + * Returns the raw JSON value of [amount]. * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * Returns the raw JSON value of [currency]. @@ -1668,6 +1754,15 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1682,29 +1777,40 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [EmployeeDeduction]. */ + /** + * Returns a mutable builder for constructing an instance of [EmployeeDeduction]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .name() + * .preTax() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [EmployeeDeduction]. */ class Builder internal constructor() { - private var amount: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null + private var name: JsonField? = null + private var preTax: JsonField? = null + private var type: JsonField? = null private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var preTax: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(employeeDeduction: EmployeeDeduction) = apply { amount = employeeDeduction.amount - attributes = employeeDeduction.attributes currency = employeeDeduction.currency name = employeeDeduction.name preTax = employeeDeduction.preTax type = employeeDeduction.type + attributes = employeeDeduction.attributes additionalProperties = employeeDeduction.additionalProperties.toMutableMap() } @@ -1730,22 +1836,6 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - /** The deduction currency. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -1813,6 +1903,22 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1836,15 +1942,26 @@ private constructor( * Returns an immutable instance of [EmployeeDeduction]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .name() + * .preTax() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): EmployeeDeduction = EmployeeDeduction( - amount, + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("name", name), + checkRequired("preTax", preTax), + checkRequired("type", type), attributes, - currency, - name, - preTax, - type, additionalProperties.toMutableMap(), ) } @@ -1857,11 +1974,11 @@ private constructor( } amount() - attributes().ifPresent { it.validate() } currency() name() preTax() type().ifPresent { it.validate() } + attributes().ifPresent { it.validate() } validated = true } @@ -1882,11 +1999,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (preTax.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) class Attributes private constructor( @@ -1902,10 +2019,11 @@ private constructor( ) : this(metadata, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): Metadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -1931,14 +2049,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Attributes]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1984,8 +2109,19 @@ private constructor( * Returns an immutable instance of [Attributes]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Attributes = Attributes(metadata, additionalProperties.toMutableMap()) + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1995,7 +2131,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -2034,10 +2170,11 @@ private constructor( * pairs where the values can be of any type (string, number, boolean, object, * array, etc.). * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): InnerMetadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -2063,14 +2200,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2123,8 +2267,19 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(metadata, additionalProperties.toMutableMap()) + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -2134,7 +2289,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -2313,55 +2468,41 @@ private constructor( return true } - return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && attributes == other.attributes && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, name, preTax, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, currency, name, preTax, type, attributes, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "EmployeeDeduction{amount=$amount, attributes=$attributes, currency=$currency, name=$name, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" + "EmployeeDeduction{amount=$amount, currency=$currency, name=$name, preTax=$preTax, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" } class EmployerContribution private constructor( - private val amount: JsonField, - private val attributes: JsonField, private val currency: JsonField, private val name: JsonField, private val type: JsonField, + private val amount: JsonField, + private val attributes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, name, type, mutableMapOf()) - - /** - * The contribution amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(currency, name, type, amount, attributes, mutableMapOf()) /** * The contribution currency. @@ -2388,20 +2529,18 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [amount]. + * The contribution amount in cents. * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun amount(): Optional = amount.getOptional("amount") /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes + fun attributes(): Optional = attributes.getOptional("attributes") /** * Returns the raw JSON value of [currency]. @@ -2424,6 +2563,22 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -2438,68 +2593,39 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [EmployerContribution]. */ + /** + * Returns a mutable builder for constructing an instance of [EmployerContribution]. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [EmployerContribution]. */ class Builder internal constructor() { + private var currency: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null private var amount: JsonField = JsonMissing.of() private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(employerContribution: EmployerContribution) = apply { - amount = employerContribution.amount - attributes = employerContribution.attributes currency = employerContribution.currency name = employerContribution.name type = employerContribution.type + amount = employerContribution.amount + attributes = employerContribution.attributes additionalProperties = employerContribution.additionalProperties.toMutableMap() } - /** The contribution amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - /** The contribution currency. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -2545,6 +2671,44 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** The contribution amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2568,14 +2732,23 @@ private constructor( * Returns an immutable instance of [EmployerContribution]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): EmployerContribution = EmployerContribution( + checkRequired("currency", currency), + checkRequired("name", name), + checkRequired("type", type), amount, attributes, - currency, - name, - type, additionalProperties.toMutableMap(), ) } @@ -2587,11 +2760,11 @@ private constructor( return@apply } - amount() - attributes().ifPresent { it.validate() } currency() name() type().ifPresent { it.validate() } + amount() + attributes().ifPresent { it.validate() } validated = true } @@ -2611,11 +2784,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) class Attributes private constructor( @@ -2631,10 +2804,11 @@ private constructor( ) : this(metadata, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): Metadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -2660,14 +2834,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Attributes]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2713,8 +2894,19 @@ private constructor( * Returns an immutable instance of [Attributes]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Attributes = Attributes(metadata, additionalProperties.toMutableMap()) + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -2724,7 +2916,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -2763,10 +2955,11 @@ private constructor( * pairs where the values can be of any type (string, number, boolean, object, * array, etc.). * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): InnerMetadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -2792,14 +2985,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2852,8 +3052,19 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(metadata, additionalProperties.toMutableMap()) + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -2863,7 +3074,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -3042,17 +3253,17 @@ private constructor( return true } - return /* spotless:off */ other is EmployerContribution && amount == other.amount && attributes == other.attributes && currency == other.currency && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EmployerContribution && currency == other.currency && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(currency, name, type, amount, attributes, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "EmployerContribution{amount=$amount, attributes=$attributes, currency=$currency, name=$name, type=$type, additionalProperties=$additionalProperties}" + "EmployerContribution{currency=$currency, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" } /** The payment method. */ @@ -3192,21 +3403,17 @@ private constructor( class Tax private constructor( - private val amount: JsonField, - private val attributes: JsonField, private val currency: JsonField, private val employer: JsonField, private val name: JsonField, private val type: JsonField, + private val amount: JsonField, + private val attributes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -3215,21 +3422,11 @@ private constructor( employer: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, employer, name, type, mutableMapOf()) - - /** - * The tax amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(currency, employer, name, type, amount, attributes, mutableMapOf()) /** * The currency code. @@ -3264,20 +3461,18 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [amount]. + * The tax amount in cents. * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun amount(): Optional = amount.getOptional("amount") /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes + fun attributes(): Optional = attributes.getOptional("attributes") /** * Returns the raw JSON value of [currency]. @@ -3307,6 +3502,22 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3321,70 +3532,42 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Tax]. */ + /** + * Returns a mutable builder for constructing an instance of [Tax]. + * + * The following fields are required: + * ```java + * .currency() + * .employer() + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Tax]. */ class Builder internal constructor() { + private var currency: JsonField? = null + private var employer: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null private var amount: JsonField = JsonMissing.of() private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var employer: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tax: Tax) = apply { - amount = tax.amount - attributes = tax.attributes currency = tax.currency employer = tax.employer name = tax.name type = tax.type + amount = tax.amount + attributes = tax.attributes additionalProperties = tax.additionalProperties.toMutableMap() } - /** The tax amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - /** The currency code. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -3446,86 +3629,274 @@ private constructor( /** * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The tax amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tax]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .currency() + * .employer() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tax = + Tax( + checkRequired("currency", currency), + checkRequired("employer", employer), + checkRequired("name", name), + checkRequired("type", type), + amount, + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tax = apply { + if (validated) { + return@apply + } + + currency() + employer() + name() + type().ifPresent { it.validate() } + amount() + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (if (employer.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + /** 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 { + + @JvmField val STATE = of("state") + + @JvmField val FEDERAL = of("federal") + + @JvmField val LOCAL = of("local") + + @JvmField val FICA = of("fica") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + STATE, + FEDERAL, + LOCAL, + 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 + FEDERAL -> Value.FEDERAL + LOCAL -> Value.LOCAL + FICA -> Value.FICA + 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 + FEDERAL -> Known.FEDERAL + LOCAL -> Known.LOCAL + FICA -> Known.FICA + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. */ - fun type(type: JsonField) = apply { this.type = type } + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + private var validated: Boolean = false - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + fun validate(): Type = apply { + if (validated) { + return@apply + } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + known() + validated = true } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Returns an immutable instance of [Tax]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Tax = - Tax( - amount, - attributes, - currency, - employer, - name, - type, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Tax = apply { - if (validated) { - return@apply + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } - amount() - attributes().ifPresent { it.validate() } - currency() - employer() - name() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (employer.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + override fun toString() = value.toString() + } class Attributes private constructor( @@ -3541,10 +3912,11 @@ private constructor( ) : this(metadata, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): Metadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -3570,14 +3942,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Attributes]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3623,8 +4002,19 @@ private constructor( * Returns an immutable instance of [Attributes]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Attributes = Attributes(metadata, additionalProperties.toMutableMap()) + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -3634,7 +4024,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -3673,10 +4063,11 @@ private constructor( * pairs where the values can be of any type (string, number, boolean, object, * array, etc.). * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): InnerMetadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -3702,14 +4093,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3762,8 +4160,19 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Metadata = Metadata(metadata, additionalProperties.toMutableMap()) + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -3773,7 +4182,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -3947,162 +4356,22 @@ private constructor( "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" } - /** 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 { - - @JvmField val STATE = of("state") - - @JvmField val FEDERAL = of("federal") - - @JvmField val LOCAL = of("local") - - @JvmField val FICA = of("fica") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - STATE, - FEDERAL, - LOCAL, - 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 - FEDERAL -> Value.FEDERAL - LOCAL -> Value.LOCAL - FICA -> Value.FICA - 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 - FEDERAL -> Known.FEDERAL - LOCAL -> Known.LOCAL - FICA -> Known.FICA - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Tax && amount == other.amount && attributes == other.attributes && currency == other.currency && employer == other.employer && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tax && currency == other.currency && employer == other.employer && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, employer, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(currency, employer, name, type, amount, attributes, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Tax{amount=$amount, attributes=$attributes, currency=$currency, employer=$employer, name=$name, type=$type, additionalProperties=$additionalProperties}" + "Tax{currency=$currency, employer=$employer, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" } /** The type of the payment associated with the pay statement. */ @@ -4120,20 +4389,20 @@ private constructor( companion object { - @JvmField val REGULAR_PAYROLL = of("regular_payroll") - @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") + @JvmField val REGULAR_PAYROLL = of("regular_payroll") + @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, + REGULAR_PAYROLL, } /** @@ -4146,9 +4415,9 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - REGULAR_PAYROLL, OFF_CYCLE_PAYROLL, ONE_TIME_PAYMENT, + REGULAR_PAYROLL, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4162,9 +4431,9 @@ private constructor( */ fun value(): Value = when (this) { - REGULAR_PAYROLL -> Value.REGULAR_PAYROLL OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Value.REGULAR_PAYROLL else -> Value._UNKNOWN } @@ -4178,9 +4447,9 @@ private constructor( */ fun known(): Known = when (this) { - REGULAR_PAYROLL -> Known.REGULAR_PAYROLL OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Known.REGULAR_PAYROLL else -> throw FinchInvalidDataException("Unknown Type: $value") } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt new file mode 100644 index 00000000..e20da2e9 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt @@ -0,0 +1,754 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.Enum +import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class PayStatementDataSyncInProgress +private constructor( + private val code: JsonField, + private val finchCode: JsonField, + private val message: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("finch_code") + @ExcludeMissing + finchCode: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(code, finchCode, message, name, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Code = code.getRequired("code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun finchCode(): FinchCode = finchCode.getRequired("finch_code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): Message = message.getRequired("message") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [finchCode]. + * + * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("finch_code") @ExcludeMissing fun _finchCode(): JsonField = finchCode + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PayStatementDataSyncInProgress]. + * + * The following fields are required: + * ```java + * .code() + * .finchCode() + * .message() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PayStatementDataSyncInProgress]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var finchCode: JsonField? = null + private var message: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(payStatementDataSyncInProgress: PayStatementDataSyncInProgress) = apply { + code = payStatementDataSyncInProgress.code + finchCode = payStatementDataSyncInProgress.finchCode + message = payStatementDataSyncInProgress.message + name = payStatementDataSyncInProgress.name + additionalProperties = + payStatementDataSyncInProgress.additionalProperties.toMutableMap() + } + + fun code(code: Code) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Code] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun finchCode(finchCode: FinchCode) = finchCode(JsonField.of(finchCode)) + + /** + * Sets [Builder.finchCode] to an arbitrary JSON value. + * + * You should usually call [Builder.finchCode] with a well-typed [FinchCode] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } + + fun message(message: Message) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PayStatementDataSyncInProgress]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .finchCode() + * .message() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PayStatementDataSyncInProgress = + PayStatementDataSyncInProgress( + checkRequired("code", code), + checkRequired("finchCode", finchCode), + checkRequired("message", message), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PayStatementDataSyncInProgress = apply { + if (validated) { + return@apply + } + + code().validate() + finchCode().validate() + message().validate() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (code.asKnown().getOrNull()?.validity() ?: 0) + + (finchCode.asKnown().getOrNull()?.validity() ?: 0) + + (message.asKnown().getOrNull()?.validity() ?: 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + 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 { + + @JvmField val _202 = of(202.0) + + @JvmStatic fun of(value: Double) = Code(JsonField.of(value)) + } + + /** An enum containing [Code]'s known values. */ + enum class Known { + _202 + } + + /** + * 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 { + _202, + /** 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) { + _202 -> Value._202 + 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) { + _202 -> Known._202 + else -> throw FinchInvalidDataException("Unknown Code: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asDouble(): Double = + _value().asNumber().getOrNull()?.toDouble() + ?: throw FinchInvalidDataException("Value is not a Double") + + private var validated: Boolean = false + + fun validate(): Code = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class FinchCode @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_IN_PROGRESS = of("data_sync_in_progress") + + @JvmStatic fun of(value: String) = FinchCode(JsonField.of(value)) + } + + /** An enum containing [FinchCode]'s known values. */ + enum class Known { + DATA_SYNC_IN_PROGRESS + } + + /** + * An enum containing [FinchCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FinchCode] 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_IN_PROGRESS, + /** + * An enum member indicating that [FinchCode] 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_IN_PROGRESS -> Value.DATA_SYNC_IN_PROGRESS + 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_IN_PROGRESS -> Known.DATA_SYNC_IN_PROGRESS + else -> throw FinchInvalidDataException("Unknown FinchCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): FinchCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FinchCode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Message @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 THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER = + of( + "The pay statements for this payment are being fetched. Please check back later." + ) + + @JvmStatic fun of(value: String) = Message(JsonField.of(value)) + } + + /** An enum containing [Message]'s known values. */ + enum class Known { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + } + + /** + * An enum containing [Message]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Message] 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 { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER, + /** An enum member indicating that [Message] 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) { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER -> + Value + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + 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) { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER -> + Known + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + else -> throw FinchInvalidDataException("Unknown Message: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Message && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Name @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 ACCEPTED = of("accepted") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + ACCEPTED + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] 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 { + ACCEPTED, + /** An enum member indicating that [Name] 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) { + ACCEPTED -> Value.ACCEPTED + 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) { + ACCEPTED -> Known.ACCEPTED + else -> throw FinchInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Name && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PayStatementDataSyncInProgress && code == other.code && finchCode == other.finchCode && message == other.message && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, finchCode, message, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PayStatementDataSyncInProgress{code=$code, finchCode=$finchCode, message=$message, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt index 846be3c3..172c2ddf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -38,26 +39,26 @@ private constructor( /** * The attributes of the pay statement item. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun attributes(): Optional = attributes.getOptional("attributes") + fun attributes(): Attributes = attributes.getRequired("attributes") /** * The category of the pay statement item. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun category(): Optional = category.getOptional("category") + fun category(): Category = category.getRequired("category") /** * The name of the pay statement item. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun name(): Optional = name.getOptional("name") + fun name(): String = name.getRequired("name") /** * Returns the raw JSON value of [attributes]. @@ -98,6 +99,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [PayStatementItemListResponse]. + * + * The following fields are required: + * ```java + * .attributes() + * .category() + * .name() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -105,9 +113,9 @@ private constructor( /** A builder for [PayStatementItemListResponse]. */ class Builder internal constructor() { - private var attributes: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var attributes: JsonField? = null + private var category: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -176,12 +184,21 @@ private constructor( * Returns an immutable instance of [PayStatementItemListResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attributes() + * .category() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayStatementItemListResponse = PayStatementItemListResponse( - attributes, - category, - name, + checkRequired("attributes", attributes), + checkRequired("category", category), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } @@ -193,8 +210,8 @@ private constructor( return@apply } - attributes().ifPresent { it.validate() } - category().ifPresent { it.validate() } + attributes().validate() + category().validate() name() validated = true } @@ -221,8 +238,8 @@ private constructor( /** The attributes of the pay statement item. */ class Attributes private constructor( - private val employer: JsonField, private val metadata: JsonField, + private val employer: JsonField, private val preTax: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, @@ -230,32 +247,32 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("employer") - @ExcludeMissing - employer: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("employer") + @ExcludeMissing + employer: JsonField = JsonMissing.of(), @JsonProperty("pre_tax") @ExcludeMissing preTax: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(employer, metadata, preTax, type, mutableMapOf()) + ) : this(metadata, employer, preTax, type, mutableMapOf()) /** - * `true` if the amount is paid by the employers. This field is only available for taxes. + * The metadata of the pay statement item derived by the rules engine if available. Each + * attribute will be a key-value pair defined by a rule. * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun employer(): Optional = employer.getOptional("employer") + fun metadata(): Optional = metadata.getOptional("metadata") /** - * The metadata of the pay statement item derived by the rules engine if available. Each - * attribute will be a key-value pair defined by a rule. + * `true` if the amount is paid by the employers. This field is only available for taxes. * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun employer(): Optional = employer.getOptional("employer") /** * `true` if the pay statement item is pre-tax. This field is only available for employee @@ -275,18 +292,18 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [employer]. + * Returns the raw JSON value of [metadata]. * - * Unlike [employer], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Returns the raw JSON value of [metadata]. + * Returns the raw JSON value of [employer]. * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [employer], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer /** * Returns the raw JSON value of [preTax]. @@ -316,28 +333,53 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Attributes]. */ class Builder internal constructor() { + private var metadata: JsonField? = null private var employer: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() private var preTax: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(attributes: Attributes) = apply { - employer = attributes.employer metadata = attributes.metadata + employer = attributes.employer preTax = attributes.preTax type = attributes.type additionalProperties = attributes.additionalProperties.toMutableMap() } + /** + * The metadata of the pay statement item derived by the rules engine if available. Each + * attribute will be a key-value pair defined by a rule. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * `true` if the amount is paid by the employers. This field is only available for * taxes. @@ -363,24 +405,6 @@ private constructor( */ fun employer(employer: JsonField) = apply { this.employer = employer } - /** - * The metadata of the pay statement item derived by the rules engine if available. Each - * attribute will be a key-value pair defined by a rule. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** * `true` if the pay statement item is pre-tax. This field is only available for * employee deductions. @@ -444,9 +468,22 @@ private constructor( * Returns an immutable instance of [Attributes]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Attributes = - Attributes(employer, metadata, preTax, type, additionalProperties.toMutableMap()) + Attributes( + checkRequired("metadata", metadata), + employer, + preTax, + type, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -456,8 +493,8 @@ private constructor( return@apply } - employer() metadata().ifPresent { it.validate() } + employer() preTax() type() validated = true @@ -479,8 +516,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (employer.asKnown().isPresent) 1 else 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (employer.asKnown().isPresent) 1 else 0) + (if (preTax.asKnown().isPresent) 1 else 0) + (if (type.asKnown().isPresent) 1 else 0) @@ -597,17 +634,17 @@ private constructor( return true } - return /* spotless:off */ other is Attributes && employer == other.employer && metadata == other.metadata && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Attributes && metadata == other.metadata && employer == other.employer && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(employer, metadata, preTax, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(metadata, employer, preTax, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Attributes{employer=$employer, metadata=$metadata, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" + "Attributes{metadata=$metadata, employer=$employer, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" } /** The category of the pay statement item. */ 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 3f5cf6c6..04d0fa8a 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 @@ -6,10 +6,22 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.BaseDeserializer +import com.tryfinch.api.core.BaseSerializer import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.allMaxBy +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.getOrThrow import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -18,7 +30,7 @@ import kotlin.jvm.optionals.getOrNull class PayStatementResponse private constructor( - private val body: JsonField, + private val body: JsonField, private val code: JsonField, private val paymentId: JsonField, private val additionalProperties: MutableMap, @@ -26,37 +38,35 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("body") - @ExcludeMissing - body: JsonField = JsonMissing.of(), + @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), @JsonProperty("payment_id") @ExcludeMissing paymentId: JsonField = JsonMissing.of(), ) : this(body, code, paymentId, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun body(): Optional = body.getOptional("body") + fun body(): Body = body.getRequired("body") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun code(): Optional = code.getOptional("code") + fun code(): Long = code.getRequired("code") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun paymentId(): Optional = paymentId.getOptional("payment_id") + fun paymentId(): String = paymentId.getRequired("payment_id") /** * Returns the raw JSON value of [body]. * * Unlike [body], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body /** * Returns the raw JSON value of [code]. @@ -86,16 +96,25 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayStatementResponse]. */ + /** + * Returns a mutable builder for constructing an instance of [PayStatementResponse]. + * + * The following fields are required: + * ```java + * .body() + * .code() + * .paymentId() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [PayStatementResponse]. */ class Builder internal constructor() { - private var body: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() - private var paymentId: JsonField = JsonMissing.of() + private var body: JsonField? = null + private var code: JsonField? = null + private var paymentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -106,16 +125,29 @@ private constructor( additionalProperties = payStatementResponse.additionalProperties.toMutableMap() } - fun body(body: PayStatementResponseBody) = body(JsonField.of(body)) + fun body(body: Body) = body(JsonField.of(body)) /** * Sets [Builder.body] to an arbitrary JSON value. * - * You should usually call [Builder.body] with a well-typed [PayStatementResponseBody] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.body] with a well-typed [Body] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun body(body: JsonField) = apply { this.body = body } + fun body(body: JsonField) = apply { this.body = body } + + /** Alias for calling [body] with `Body.ofPayStatementResponse(payStatementResponse)`. */ + fun body(payStatementResponse: PayStatementResponseBody) = + body(Body.ofPayStatementResponse(payStatementResponse)) + + /** Alias for calling [body] with `Body.ofBatchError(batchError)`. */ + fun body(batchError: Body.BatchError) = body(Body.ofBatchError(batchError)) + + /** + * Alias for calling [body] with + * `Body.ofPayStatementDataSyncInProgress(payStatementDataSyncInProgress)`. + */ + fun body(payStatementDataSyncInProgress: PayStatementDataSyncInProgress) = + body(Body.ofPayStatementDataSyncInProgress(payStatementDataSyncInProgress)) fun code(code: Long) = code(JsonField.of(code)) @@ -161,9 +193,23 @@ private constructor( * Returns an immutable instance of [PayStatementResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * .code() + * .paymentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayStatementResponse = - PayStatementResponse(body, code, paymentId, additionalProperties.toMutableMap()) + PayStatementResponse( + checkRequired("body", body), + checkRequired("code", code), + checkRequired("paymentId", paymentId), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -173,7 +219,7 @@ private constructor( return@apply } - body().ifPresent { it.validate() } + body().validate() code() paymentId() validated = true @@ -198,6 +244,489 @@ private constructor( (if (code.asKnown().isPresent) 1 else 0) + (if (paymentId.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + private constructor( + private val payStatementResponse: PayStatementResponseBody? = null, + private val batchError: BatchError? = null, + private val payStatementDataSyncInProgress: PayStatementDataSyncInProgress? = null, + private val _json: JsonValue? = null, + ) { + + fun payStatementResponse(): Optional = + Optional.ofNullable(payStatementResponse) + + fun batchError(): Optional = Optional.ofNullable(batchError) + + fun payStatementDataSyncInProgress(): Optional = + Optional.ofNullable(payStatementDataSyncInProgress) + + fun isPayStatementResponse(): Boolean = payStatementResponse != null + + fun isBatchError(): Boolean = batchError != null + + fun isPayStatementDataSyncInProgress(): Boolean = payStatementDataSyncInProgress != null + + fun asPayStatementResponse(): PayStatementResponseBody = + payStatementResponse.getOrThrow("payStatementResponse") + + fun asBatchError(): BatchError = batchError.getOrThrow("batchError") + + fun asPayStatementDataSyncInProgress(): PayStatementDataSyncInProgress = + payStatementDataSyncInProgress.getOrThrow("payStatementDataSyncInProgress") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + payStatementResponse != null -> + visitor.visitPayStatementResponse(payStatementResponse) + batchError != null -> visitor.visitBatchError(batchError) + payStatementDataSyncInProgress != null -> + visitor.visitPayStatementDataSyncInProgress(payStatementDataSyncInProgress) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPayStatementResponse( + payStatementResponse: PayStatementResponseBody + ) { + payStatementResponse.validate() + } + + override fun visitBatchError(batchError: BatchError) { + batchError.validate() + } + + override fun visitPayStatementDataSyncInProgress( + payStatementDataSyncInProgress: PayStatementDataSyncInProgress + ) { + payStatementDataSyncInProgress.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPayStatementResponse( + payStatementResponse: PayStatementResponseBody + ) = payStatementResponse.validity() + + override fun visitBatchError(batchError: BatchError) = batchError.validity() + + override fun visitPayStatementDataSyncInProgress( + payStatementDataSyncInProgress: PayStatementDataSyncInProgress + ) = payStatementDataSyncInProgress.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && payStatementResponse == other.payStatementResponse && batchError == other.batchError && payStatementDataSyncInProgress == other.payStatementDataSyncInProgress /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(payStatementResponse, batchError, payStatementDataSyncInProgress) /* spotless:on */ + + override fun toString(): String = + when { + payStatementResponse != null -> "Body{payStatementResponse=$payStatementResponse}" + batchError != null -> "Body{batchError=$batchError}" + payStatementDataSyncInProgress != null -> + "Body{payStatementDataSyncInProgress=$payStatementDataSyncInProgress}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } + + companion object { + + @JvmStatic + fun ofPayStatementResponse(payStatementResponse: PayStatementResponseBody) = + Body(payStatementResponse = payStatementResponse) + + @JvmStatic fun ofBatchError(batchError: BatchError) = Body(batchError = batchError) + + @JvmStatic + fun ofPayStatementDataSyncInProgress( + payStatementDataSyncInProgress: PayStatementDataSyncInProgress + ) = Body(payStatementDataSyncInProgress = payStatementDataSyncInProgress) + } + + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + interface Visitor { + + fun visitPayStatementResponse(payStatementResponse: PayStatementResponseBody): T + + fun visitBatchError(batchError: BatchError): T + + fun visitPayStatementDataSyncInProgress( + payStatementDataSyncInProgress: PayStatementDataSyncInProgress + ): T + + /** + * Maps an unknown variant of [Body] to a value of type [T]. + * + * An instance of [Body] 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 Body: $json") + } + } + + internal class Deserializer : BaseDeserializer(Body::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Body { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Body(payStatementResponse = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(batchError = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(payStatementDataSyncInProgress = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Body(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Body::class) { + + override fun serialize( + value: Body, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.payStatementResponse != null -> + generator.writeObject(value.payStatementResponse) + value.batchError != null -> generator.writeObject(value.batchError) + value.payStatementDataSyncInProgress != null -> + generator.writeObject(value.payStatementDataSyncInProgress) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } + } + + class BatchError + private constructor( + private val code: JsonField, + private val message: JsonField, + private val name: JsonField, + private val finchCode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("finch_code") + @ExcludeMissing + finchCode: JsonField = JsonMissing.of(), + ) : this(code, message, name, finchCode, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun code(): Double = code.getRequired("code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun finchCode(): Optional = finchCode.getOptional("finch_code") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [finchCode]. + * + * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("finch_code") + @ExcludeMissing + fun _finchCode(): JsonField = finchCode + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BatchError]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchError]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var message: JsonField? = null + private var name: JsonField? = null + private var finchCode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(batchError: BatchError) = apply { + code = batchError.code + message = batchError.message + name = batchError.name + finchCode = batchError.finchCode + additionalProperties = batchError.additionalProperties.toMutableMap() + } + + fun code(code: Double) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun finchCode(finchCode: String) = finchCode(JsonField.of(finchCode)) + + /** + * Sets [Builder.finchCode] to an arbitrary JSON value. + * + * You should usually call [Builder.finchCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BatchError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BatchError = + BatchError( + checkRequired("code", code), + checkRequired("message", message), + checkRequired("name", name), + finchCode, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BatchError = apply { + if (validated) { + return@apply + } + + code() + message() + name() + finchCode() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (finchCode.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BatchError && code == other.code && message == other.message && name == other.name && finchCode == other.finchCode && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, message, name, finchCode, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchError{code=$code, message=$message, name=$name, finchCode=$finchCode, additionalProperties=$additionalProperties}" + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 66722b9f..712d6020 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 @@ -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.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -34,18 +35,16 @@ private constructor( ) : this(paging, payStatements, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun paging(): Optional = paging.getOptional("paging") + fun paging(): Paging = paging.getRequired("paging") /** - * The array of pay statements for the current payment. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun payStatements(): Optional> = payStatements.getOptional("pay_statements") + fun payStatements(): List = payStatements.getRequired("pay_statements") /** * Returns the raw JSON value of [paging]. @@ -77,14 +76,22 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayStatementResponseBody]. */ + /** + * Returns a mutable builder for constructing an instance of [PayStatementResponseBody]. + * + * The following fields are required: + * ```java + * .paging() + * .payStatements() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [PayStatementResponseBody]. */ class Builder internal constructor() { - private var paging: JsonField = JsonMissing.of() + private var paging: JsonField? = null private var payStatements: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -105,7 +112,6 @@ private constructor( */ fun paging(paging: JsonField) = apply { this.paging = paging } - /** The array of pay statements for the current payment. */ fun payStatements(payStatements: List) = payStatements(JsonField.of(payStatements)) @@ -155,11 +161,19 @@ private constructor( * Returns an immutable instance of [PayStatementResponseBody]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .paging() + * .payStatements() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayStatementResponseBody = PayStatementResponseBody( - paging, - (payStatements ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("paging", paging), + checkRequired("payStatements", payStatements).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -171,8 +185,8 @@ private constructor( return@apply } - paging().ifPresent { it.validate() } - payStatements().ifPresent { it.forEach { it.validate() } } + paging().validate() + payStatements().forEach { it.validate() } validated = true } @@ -194,6 +208,195 @@ private constructor( (paging.asKnown().getOrNull()?.validity() ?: 0) + (payStatements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Paging + private constructor( + private val offset: JsonField, + private val count: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + ) : this(offset, count, mutableMapOf()) + + /** + * The current start index of the returned list of elements + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun offset(): Long = offset.getRequired("offset") + + /** + * The total number of elements for the entire query (not just the given page) + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun count(): Optional = count.getOptional("count") + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Paging]. + * + * The following fields are required: + * ```java + * .offset() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Paging]. */ + class Builder internal constructor() { + + private var offset: JsonField? = null + private var count: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paging: Paging) = apply { + offset = paging.offset + count = paging.count + additionalProperties = paging.additionalProperties.toMutableMap() + } + + /** The current start index of the returned list of elements */ + fun offset(offset: Long) = offset(JsonField.of(offset)) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun offset(offset: JsonField) = apply { this.offset = offset } + + /** The total number of elements for the entire query (not just the given page) */ + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun count(count: JsonField) = apply { this.count = count } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Paging]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .offset() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Paging = + Paging(checkRequired("offset", offset), count, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Paging = apply { + if (validated) { + return@apply + } + + offset() + count() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (offset.asKnown().isPresent) 1 else 0) + (if (count.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Paging && offset == other.offset && count == other.count && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(offset, count, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Paging{offset=$offset, count=$count, additionalProperties=$additionalProperties}" + } + override fun equals(other: Any?): Boolean { if (this === other) { return true 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 27d85584..c3dfdb32 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 @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -83,10 +84,10 @@ private constructor( /** * The unique id for the payment. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun id(): Optional = id.getOptional("id") + fun id(): String = id.getRequired("id") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -273,25 +274,43 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Payment]. */ + /** + * Returns a mutable builder for constructing an instance of [Payment]. + * + * The following fields are required: + * ```java + * .id() + * .companyDebit() + * .debitDate() + * .employeeTaxes() + * .employerTaxes() + * .grossPay() + * .individualIds() + * .netPay() + * .payDate() + * .payFrequencies() + * .payGroupIds() + * .payPeriod() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Payment]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var companyDebit: JsonField = JsonMissing.of() - private var debitDate: JsonField = JsonMissing.of() - private var employeeTaxes: JsonField = JsonMissing.of() - private var employerTaxes: JsonField = JsonMissing.of() - private var grossPay: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var companyDebit: JsonField? = null + private var debitDate: JsonField? = null + private var employeeTaxes: JsonField? = null + private var employerTaxes: JsonField? = null + private var grossPay: JsonField? = null private var individualIds: JsonField>? = null - private var netPay: JsonField = JsonMissing.of() - private var payDate: JsonField = JsonMissing.of() + private var netPay: JsonField? = null + private var payDate: JsonField? = null private var payFrequencies: JsonField>? = null private var payGroupIds: JsonField>? = null - private var payPeriod: JsonField = JsonMissing.of() + private var payPeriod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -554,21 +573,39 @@ private constructor( * Returns an immutable instance of [Payment]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .companyDebit() + * .debitDate() + * .employeeTaxes() + * .employerTaxes() + * .grossPay() + * .individualIds() + * .netPay() + * .payDate() + * .payFrequencies() + * .payGroupIds() + * .payPeriod() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Payment = Payment( - id, - companyDebit, - debitDate, - employeeTaxes, - employerTaxes, - grossPay, - (individualIds ?: JsonMissing.of()).map { it.toImmutable() }, - netPay, - payDate, - (payFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, - (payGroupIds ?: JsonMissing.of()).map { it.toImmutable() }, - payPeriod, + checkRequired("id", id), + checkRequired("companyDebit", companyDebit), + checkRequired("debitDate", debitDate), + checkRequired("employeeTaxes", employeeTaxes), + checkRequired("employerTaxes", employerTaxes), + checkRequired("grossPay", grossPay), + checkRequired("individualIds", individualIds).map { it.toImmutable() }, + checkRequired("netPay", netPay), + checkRequired("payDate", payDate), + checkRequired("payFrequencies", payFrequencies).map { it.toImmutable() }, + checkRequired("payGroupIds", payGroupIds).map { it.toImmutable() }, + checkRequired("payPeriod", payPeriod), additionalProperties.toMutableMap(), ) } @@ -640,21 +677,21 @@ private constructor( @JvmField val ANNUALLY = of("annually") - @JvmField val SEMI_ANNUALLY = of("semi_annually") + @JvmField val BI_WEEKLY = of("bi_weekly") - @JvmField val QUARTERLY = of("quarterly") + @JvmField val DAILY = of("daily") @JvmField val MONTHLY = of("monthly") - @JvmField val SEMI_MONTHLY = of("semi_monthly") + @JvmField val OTHER = of("other") - @JvmField val BI_WEEKLY = of("bi_weekly") + @JvmField val QUARTERLY = of("quarterly") - @JvmField val WEEKLY = of("weekly") + @JvmField val SEMI_ANNUALLY = of("semi_annually") - @JvmField val DAILY = of("daily") + @JvmField val SEMI_MONTHLY = of("semi_monthly") - @JvmField val OTHER = of("other") + @JvmField val WEEKLY = of("weekly") @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } @@ -662,14 +699,14 @@ private constructor( /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, } /** @@ -683,14 +720,14 @@ private constructor( */ enum class Value { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, /** * An enum member indicating that [PayFrequency] was instantiated with an unknown value. */ @@ -707,14 +744,14 @@ private constructor( fun value(): Value = when (this) { ANNUALLY -> Value.ANNUALLY - SEMI_ANNUALLY -> Value.SEMI_ANNUALLY - QUARTERLY -> Value.QUARTERLY - MONTHLY -> Value.MONTHLY - SEMI_MONTHLY -> Value.SEMI_MONTHLY BI_WEEKLY -> Value.BI_WEEKLY - WEEKLY -> Value.WEEKLY DAILY -> Value.DAILY + MONTHLY -> Value.MONTHLY OTHER -> Value.OTHER + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUALLY -> Value.SEMI_ANNUALLY + SEMI_MONTHLY -> Value.SEMI_MONTHLY + WEEKLY -> Value.WEEKLY else -> Value._UNKNOWN } @@ -729,14 +766,14 @@ private constructor( fun known(): Known = when (this) { ANNUALLY -> Known.ANNUALLY - SEMI_ANNUALLY -> Known.SEMI_ANNUALLY - QUARTERLY -> Known.QUARTERLY - MONTHLY -> Known.MONTHLY - SEMI_MONTHLY -> Known.SEMI_MONTHLY BI_WEEKLY -> Known.BI_WEEKLY - WEEKLY -> Known.WEEKLY DAILY -> Known.DAILY + MONTHLY -> Known.MONTHLY OTHER -> Known.OTHER + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUALLY -> Known.SEMI_ANNUALLY + SEMI_MONTHLY -> Known.SEMI_MONTHLY + WEEKLY -> Known.WEEKLY else -> throw FinchInvalidDataException("Unknown PayFrequency: $value") } @@ -848,15 +885,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayPeriod]. */ + /** + * Returns a mutable builder for constructing an instance of [PayPeriod]. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [PayPeriod]. */ class Builder internal constructor() { - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -917,9 +962,21 @@ private constructor( * Returns an immutable instance of [PayPeriod]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayPeriod = - PayPeriod(endDate, startDate, additionalProperties.toMutableMap()) + PayPeriod( + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false 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 9287b371..7505d02a 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 @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): PayrollPayGroupListParams = throw IllegalStateException("Cannot construct next page params") 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 9b790ca2..7c21fa21 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 @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): PayrollPayGroupListParams = throw IllegalStateException("Cannot construct next page params") 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 e3c2524a..818565b9 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 @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): ProviderListParams = throw IllegalStateException("Cannot construct next page params") 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 c23a65e2..f6a62b91 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 @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): ProviderListParams = throw IllegalStateException("Cannot construct next page params") 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 82188e32..4de48809 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 @@ -13,10 +13,12 @@ import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.Params import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException +import java.time.LocalDate import java.util.Collections import java.util.Objects import java.util.Optional @@ -25,7 +27,7 @@ import kotlin.jvm.optionals.getOrNull /** Add a new sandbox payment */ class SandboxPaymentCreateParams private constructor( - private val body: Body, + private val body: CreateSandboxPaymentRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -34,9 +36,11 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun endDate(): Optional = body.endDate() + fun endDate(): Optional = body.endDate() /** + * Array of pay statements to include in the payment. + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -46,14 +50,14 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startDate(): Optional = body.startDate() + fun startDate(): Optional = body.startDate() /** * Returns the raw JSON value of [endDate]. * * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. */ - fun _endDate(): JsonField = body._endDate() + fun _endDate(): JsonField = body._endDate() /** * Returns the raw JSON value of [payStatements]. @@ -67,7 +71,7 @@ private constructor( * * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. */ - fun _startDate(): JsonField = body._startDate() + fun _startDate(): JsonField = body._startDate() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -90,7 +94,8 @@ private constructor( /** A builder for [SandboxPaymentCreateParams]. */ class Builder internal constructor() { - private var body: Body.Builder = Body.builder() + private var body: CreateSandboxPaymentRequest.Builder = + CreateSandboxPaymentRequest.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -110,18 +115,20 @@ private constructor( * - [payStatements] * - [startDate] */ - fun body(body: Body) = apply { this.body = body.toBuilder() } + fun body(body: CreateSandboxPaymentRequest) = apply { this.body = body.toBuilder() } - fun endDate(endDate: String) = apply { body.endDate(endDate) } + fun endDate(endDate: LocalDate) = apply { body.endDate(endDate) } /** * Sets [Builder.endDate] to an arbitrary JSON value. * - * You should usually call [Builder.endDate] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + /** Array of pay statements to include in the payment. */ fun payStatements(payStatements: List) = apply { body.payStatements(payStatements) } @@ -146,16 +153,16 @@ private constructor( body.addPayStatement(payStatement) } - fun startDate(startDate: String) = apply { body.startDate(startDate) } + fun startDate(startDate: LocalDate) = apply { body.startDate(startDate) } /** * Sets [Builder.startDate] to an arbitrary JSON value. * - * You should usually call [Builder.startDate] with a well-typed [String] value instead. + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value instead. * This method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -287,7 +294,7 @@ private constructor( ) } - fun _body(): Body = body + fun _body(): CreateSandboxPaymentRequest = body override fun _headers(): Headers = additionalHeaders @@ -297,32 +304,36 @@ private constructor( * Fields to configure the payment. Takes all fields from the `/payment` endpoint. All fields * are optional. */ - class Body + class CreateSandboxPaymentRequest private constructor( - private val endDate: JsonField, + private val endDate: JsonField, private val payStatements: JsonField>, - private val startDate: JsonField, + private val startDate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), @JsonProperty("pay_statements") @ExcludeMissing payStatements: JsonField> = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing - startDate: JsonField = JsonMissing.of(), + startDate: JsonField = JsonMissing.of(), ) : this(endDate, payStatements, startDate, mutableMapOf()) /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun endDate(): Optional = endDate.getOptional("end_date") + fun endDate(): Optional = endDate.getOptional("end_date") /** + * Array of pay statements to include in the payment. + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -333,14 +344,14 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startDate(): Optional = startDate.getOptional("start_date") + fun startDate(): Optional = startDate.getOptional("start_date") /** * Returns the raw JSON value of [endDate]. * * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** * Returns the raw JSON value of [payStatements]. @@ -357,7 +368,9 @@ private constructor( * * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -373,37 +386,42 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Body]. */ + /** + * Returns a mutable builder for constructing an instance of + * [CreateSandboxPaymentRequest]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Body]. */ + /** A builder for [CreateSandboxPaymentRequest]. */ class Builder internal constructor() { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() private var payStatements: JsonField>? = null - private var startDate: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - endDate = body.endDate - payStatements = body.payStatements.map { it.toMutableList() } - startDate = body.startDate - additionalProperties = body.additionalProperties.toMutableMap() + internal fun from(createSandboxPaymentRequest: CreateSandboxPaymentRequest) = apply { + endDate = createSandboxPaymentRequest.endDate + payStatements = createSandboxPaymentRequest.payStatements.map { it.toMutableList() } + startDate = createSandboxPaymentRequest.startDate + additionalProperties = + createSandboxPaymentRequest.additionalProperties.toMutableMap() } - fun endDate(endDate: String) = endDate(JsonField.of(endDate)) + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) /** * Sets [Builder.endDate] to an arbitrary JSON value. * - * You should usually call [Builder.endDate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** Array of pay statements to include in the payment. */ fun payStatements(payStatements: List) = payStatements(JsonField.of(payStatements)) @@ -430,16 +448,16 @@ private constructor( } } - fun startDate(startDate: String) = startDate(JsonField.of(startDate)) + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) /** * Sets [Builder.startDate] to an arbitrary JSON value. * - * You should usually call [Builder.startDate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -461,12 +479,12 @@ private constructor( } /** - * Returns an immutable instance of [Body]. + * Returns an immutable instance of [CreateSandboxPaymentRequest]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = - Body( + fun build(): CreateSandboxPaymentRequest = + CreateSandboxPaymentRequest( endDate, (payStatements ?: JsonMissing.of()).map { it.toImmutable() }, startDate, @@ -476,7 +494,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { + fun validate(): CreateSandboxPaymentRequest = apply { if (validated) { return@apply } @@ -512,7 +530,7 @@ private constructor( return true } - return /* spotless:off */ other is Body && endDate == other.endDate && payStatements == other.payStatements && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateSandboxPaymentRequest && endDate == other.endDate && payStatements == other.payStatements && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -522,19 +540,19 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{endDate=$endDate, payStatements=$payStatements, startDate=$startDate, additionalProperties=$additionalProperties}" + "CreateSandboxPaymentRequest{endDate=$endDate, payStatements=$payStatements, startDate=$startDate, additionalProperties=$additionalProperties}" } class PayStatement private constructor( - private val earnings: JsonField>, - private val employeeDeductions: JsonField>, - private val employerContributions: JsonField>, - private val grossPay: JsonField, private val individualId: JsonField, - private val netPay: JsonField, + private val earnings: JsonField>, + private val employeeDeductions: JsonField>, + private val employerContributions: JsonField>, + private val grossPay: JsonField, + private val netPay: JsonField, private val paymentMethod: JsonField, - private val taxes: JsonField>, + private val taxes: JsonField>, private val totalHours: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, @@ -542,36 +560,34 @@ private constructor( @JsonCreator private constructor( + @JsonProperty("individual_id") + @ExcludeMissing + individualId: JsonField = JsonMissing.of(), @JsonProperty("earnings") @ExcludeMissing - earnings: JsonField> = JsonMissing.of(), + earnings: JsonField> = JsonMissing.of(), @JsonProperty("employee_deductions") @ExcludeMissing - employeeDeductions: JsonField> = JsonMissing.of(), + employeeDeductions: JsonField> = JsonMissing.of(), @JsonProperty("employer_contributions") @ExcludeMissing - employerContributions: JsonField> = JsonMissing.of(), - @JsonProperty("gross_pay") - @ExcludeMissing - grossPay: JsonField = JsonMissing.of(), - @JsonProperty("individual_id") - @ExcludeMissing - individualId: JsonField = JsonMissing.of(), - @JsonProperty("net_pay") @ExcludeMissing netPay: JsonField = JsonMissing.of(), + employerContributions: JsonField> = JsonMissing.of(), + @JsonProperty("gross_pay") @ExcludeMissing grossPay: JsonField = JsonMissing.of(), + @JsonProperty("net_pay") @ExcludeMissing netPay: JsonField = JsonMissing.of(), @JsonProperty("payment_method") @ExcludeMissing paymentMethod: JsonField = JsonMissing.of(), - @JsonProperty("taxes") @ExcludeMissing taxes: JsonField> = JsonMissing.of(), + @JsonProperty("taxes") @ExcludeMissing taxes: JsonField> = JsonMissing.of(), @JsonProperty("total_hours") @ExcludeMissing totalHours: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this( + individualId, earnings, employeeDeductions, employerContributions, grossPay, - individualId, netPay, paymentMethod, taxes, @@ -581,81 +597,77 @@ private constructor( ) /** - * The array of earnings objects associated with this pay statement - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun earnings(): Optional> = earnings.getOptional("earnings") + fun individualId(): String = individualId.getRequired("individual_id") /** - * The array of deductions objects associated with this pay statement. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun employeeDeductions(): Optional> = - employeeDeductions.getOptional("employee_deductions") + fun earnings(): Optional> = earnings.getOptional("earnings") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun employerContributions(): Optional> = - employerContributions.getOptional("employer_contributions") + fun employeeDeductions(): Optional> = + employeeDeductions.getOptional("employee_deductions") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun grossPay(): Optional = grossPay.getOptional("gross_pay") + fun employerContributions(): Optional> = + employerContributions.getOptional("employer_contributions") /** - * A stable Finch `id` (UUID v4) for an individual in the company - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun individualId(): Optional = individualId.getOptional("individual_id") + fun grossPay(): Optional = grossPay.getOptional("gross_pay") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun netPay(): Optional = netPay.getOptional("net_pay") + fun netPay(): Optional = netPay.getOptional("net_pay") /** - * The payment method. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun paymentMethod(): Optional = paymentMethod.getOptional("payment_method") /** - * The array of taxes objects associated with this pay statement. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun taxes(): Optional> = taxes.getOptional("taxes") + fun taxes(): Optional> = taxes.getOptional("taxes") /** - * The number of hours worked for this pay period - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun totalHours(): Optional = totalHours.getOptional("total_hours") /** - * The type of the payment associated with the pay statement. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ fun type(): Optional = type.getOptional("type") + /** + * Returns the raw JSON value of [individualId]. + * + * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId + /** * Returns the raw JSON value of [earnings]. * @@ -663,7 +675,7 @@ private constructor( */ @JsonProperty("earnings") @ExcludeMissing - fun _earnings(): JsonField> = earnings + fun _earnings(): JsonField> = earnings /** * Returns the raw JSON value of [employeeDeductions]. @@ -673,7 +685,7 @@ private constructor( */ @JsonProperty("employee_deductions") @ExcludeMissing - fun _employeeDeductions(): JsonField> = employeeDeductions + fun _employeeDeductions(): JsonField> = employeeDeductions /** * Returns the raw JSON value of [employerContributions]. @@ -683,31 +695,21 @@ private constructor( */ @JsonProperty("employer_contributions") @ExcludeMissing - fun _employerContributions(): JsonField> = employerContributions + fun _employerContributions(): JsonField> = employerContributions /** * Returns the raw JSON value of [grossPay]. * * Unlike [grossPay], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay - - /** - * Returns the raw JSON value of [individualId]. - * - * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("individual_id") - @ExcludeMissing - fun _individualId(): JsonField = individualId + @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay /** * Returns the raw JSON value of [netPay]. * * Unlike [netPay], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay + @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay /** * Returns the raw JSON value of [paymentMethod]. @@ -724,7 +726,7 @@ private constructor( * * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes + @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes /** * Returns the raw JSON value of [totalHours]. @@ -756,33 +758,40 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayStatement]. */ + /** + * Returns a mutable builder for constructing an instance of [PayStatement]. + * + * The following fields are required: + * ```java + * .individualId() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [PayStatement]. */ class Builder internal constructor() { - private var earnings: JsonField>? = null - private var employeeDeductions: JsonField>? = null - private var employerContributions: JsonField>? = null - private var grossPay: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var netPay: JsonField = JsonMissing.of() + private var individualId: JsonField? = null + private var earnings: JsonField>? = null + private var employeeDeductions: JsonField>? = null + private var employerContributions: JsonField>? = null + private var grossPay: JsonField = JsonMissing.of() + private var netPay: JsonField = JsonMissing.of() private var paymentMethod: JsonField = JsonMissing.of() - private var taxes: JsonField>? = null + private var taxes: JsonField>? = null private var totalHours: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(payStatement: PayStatement) = apply { + individualId = payStatement.individualId earnings = payStatement.earnings.map { it.toMutableList() } employeeDeductions = payStatement.employeeDeductions.map { it.toMutableList() } employerContributions = payStatement.employerContributions.map { it.toMutableList() } grossPay = payStatement.grossPay - individualId = payStatement.individualId netPay = payStatement.netPay paymentMethod = payStatement.paymentMethod taxes = payStatement.taxes.map { it.toMutableList() } @@ -791,20 +800,29 @@ private constructor( additionalProperties = payStatement.additionalProperties.toMutableMap() } - /** The array of earnings objects associated with this pay statement */ - fun earnings(earnings: List?) = earnings(JsonField.ofNullable(earnings)) + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** + * Sets [Builder.individualId] to an arbitrary JSON value. + * + * You should usually call [Builder.individualId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } - /** Alias for calling [Builder.earnings] with `earnings.orElse(null)`. */ - fun earnings(earnings: Optional>) = earnings(earnings.getOrNull()) + fun earnings(earnings: List) = earnings(JsonField.of(earnings)) /** * Sets [Builder.earnings] to an arbitrary JSON value. * - * You should usually call [Builder.earnings] with a well-typed `List` value + * You should usually call [Builder.earnings] with a well-typed `List` value * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun earnings(earnings: JsonField>) = apply { + fun earnings(earnings: JsonField>) = apply { this.earnings = earnings.map { it.toMutableList() } } @@ -820,28 +838,19 @@ private constructor( } } - /** The array of deductions objects associated with this pay statement. */ - fun employeeDeductions(employeeDeductions: List?) = - employeeDeductions(JsonField.ofNullable(employeeDeductions)) - - /** - * Alias for calling [Builder.employeeDeductions] with - * `employeeDeductions.orElse(null)`. - */ - fun employeeDeductions(employeeDeductions: Optional>) = - employeeDeductions(employeeDeductions.getOrNull()) + fun employeeDeductions(employeeDeductions: List) = + employeeDeductions(JsonField.of(employeeDeductions)) /** * Sets [Builder.employeeDeductions] to an arbitrary JSON value. * * You should usually call [Builder.employeeDeductions] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ - fun employeeDeductions(employeeDeductions: JsonField>) = - apply { - this.employeeDeductions = employeeDeductions.map { it.toMutableList() } - } + fun employeeDeductions(employeeDeductions: JsonField>) = apply { + this.employeeDeductions = employeeDeductions.map { it.toMutableList() } + } /** * Adds a single [EmployeeDeduction] to [employeeDeductions]. @@ -855,26 +864,18 @@ private constructor( } } - fun employerContributions(employerContributions: List?) = - employerContributions(JsonField.ofNullable(employerContributions)) - - /** - * Alias for calling [Builder.employerContributions] with - * `employerContributions.orElse(null)`. - */ - fun employerContributions( - employerContributions: Optional> - ) = employerContributions(employerContributions.getOrNull()) + fun employerContributions(employerContributions: List) = + employerContributions(JsonField.of(employerContributions)) /** * Sets [Builder.employerContributions] to an arbitrary JSON value. * * You should usually call [Builder.employerContributions] with a well-typed - * `List` value instead. This method is primarily for setting the + * `List` value instead. This method is primarily for setting the * field to an undocumented or not yet supported value. */ fun employerContributions( - employerContributions: JsonField> + employerContributions: JsonField> ) = apply { this.employerContributions = employerContributions.map { it.toMutableList() } } @@ -891,49 +892,28 @@ private constructor( } } - fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) - - /** Alias for calling [Builder.grossPay] with `grossPay.orElse(null)`. */ - fun grossPay(grossPay: Optional) = grossPay(grossPay.getOrNull()) + fun grossPay(grossPay: Long) = grossPay(JsonField.of(grossPay)) /** * Sets [Builder.grossPay] to an arbitrary JSON value. * - * You should usually call [Builder.grossPay] with a well-typed [Money] value instead. + * You should usually call [Builder.grossPay] with a well-typed [Long] value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } - - /** A stable Finch `id` (UUID v4) for an individual in the company */ - fun individualId(individualId: String) = individualId(JsonField.of(individualId)) - - /** - * Sets [Builder.individualId] to an arbitrary JSON value. - * - * You should usually call [Builder.individualId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun individualId(individualId: JsonField) = apply { - this.individualId = individualId - } + fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } - fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) - - /** Alias for calling [Builder.netPay] with `netPay.orElse(null)`. */ - fun netPay(netPay: Optional) = netPay(netPay.getOrNull()) + fun netPay(netPay: Long) = netPay(JsonField.of(netPay)) /** * Sets [Builder.netPay] to an arbitrary JSON value. * - * You should usually call [Builder.netPay] with a well-typed [Money] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.netPay] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun netPay(netPay: JsonField) = apply { this.netPay = netPay } + fun netPay(netPay: JsonField) = apply { this.netPay = netPay } - /** The payment method. */ fun paymentMethod(paymentMethod: PaymentMethod?) = paymentMethod(JsonField.ofNullable(paymentMethod)) @@ -952,20 +932,16 @@ private constructor( this.paymentMethod = paymentMethod } - /** The array of taxes objects associated with this pay statement. */ - fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) - - /** Alias for calling [Builder.taxes] with `taxes.orElse(null)`. */ - fun taxes(taxes: Optional>) = taxes(taxes.getOrNull()) + fun taxes(taxes: List) = taxes(JsonField.of(taxes)) /** * Sets [Builder.taxes] to an arbitrary JSON value. * - * You should usually call [Builder.taxes] with a well-typed `List` value instead. + * You should usually call [Builder.taxes] with a well-typed `List` value instead. * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun taxes(taxes: JsonField>) = apply { + fun taxes(taxes: JsonField>) = apply { this.taxes = taxes.map { it.toMutableList() } } @@ -981,18 +957,7 @@ private constructor( } } - /** The number of hours worked for this pay period */ - fun totalHours(totalHours: Double?) = totalHours(JsonField.ofNullable(totalHours)) - - /** - * Alias for [Builder.totalHours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun totalHours(totalHours: Double) = totalHours(totalHours as Double?) - - /** Alias for calling [Builder.totalHours] with `totalHours.orElse(null)`. */ - fun totalHours(totalHours: Optional) = totalHours(totalHours.getOrNull()) + fun totalHours(totalHours: Double) = totalHours(JsonField.of(totalHours)) /** * Sets [Builder.totalHours] to an arbitrary JSON value. @@ -1003,7 +968,6 @@ private constructor( */ fun totalHours(totalHours: JsonField) = apply { this.totalHours = totalHours } - /** The type of the payment associated with the pay statement. */ fun type(type: Type?) = type(JsonField.ofNullable(type)) /** Alias for calling [Builder.type] with `type.orElse(null)`. */ @@ -1041,14 +1005,21 @@ private constructor( * Returns an immutable instance of [PayStatement]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .individualId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayStatement = PayStatement( + checkRequired("individualId", individualId), (earnings ?: JsonMissing.of()).map { it.toImmutable() }, (employeeDeductions ?: JsonMissing.of()).map { it.toImmutable() }, (employerContributions ?: JsonMissing.of()).map { it.toImmutable() }, grossPay, - individualId, netPay, paymentMethod, (taxes ?: JsonMissing.of()).map { it.toImmutable() }, @@ -1065,14 +1036,14 @@ private constructor( 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() } + earnings().ifPresent { it.forEach { it.validate() } } + employeeDeductions().ifPresent { it.forEach { it.validate() } } + employerContributions().ifPresent { it.forEach { it.validate() } } + grossPay() + netPay() paymentMethod().ifPresent { it.validate() } - taxes().ifPresent { it.forEach { it?.validate() } } + taxes().ifPresent { it.forEach { it.validate() } } totalHours() type().ifPresent { it.validate() } validated = true @@ -1094,25 +1065,21 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (earnings.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (employeeDeductions.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } + (if (individualId.asKnown().isPresent) 1 else 0) + + (earnings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (employeeDeductions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (employerContributions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + - (employerContributions.asKnown().getOrNull()?.sumOf { - (it?.validity() ?: 0).toInt() - } ?: 0) + - (grossPay.asKnown().getOrNull()?.validity() ?: 0) + - (if (individualId.asKnown().isPresent) 1 else 0) + - (netPay.asKnown().getOrNull()?.validity() ?: 0) + + (if (grossPay.asKnown().isPresent) 1 else 0) + + (if (netPay.asKnown().isPresent) 1 else 0) + (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + - (taxes.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + + (taxes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (if (totalHours.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) class Earning private constructor( private val amount: JsonField, - private val attributes: JsonField, - private val currency: JsonField, private val hours: JsonField, private val name: JsonField, private val type: JsonField, @@ -1122,20 +1089,12 @@ private constructor( @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), @JsonProperty("hours") @ExcludeMissing hours: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, hours, name, type, mutableMapOf()) + ) : this(amount, hours, name, type, mutableMapOf()) /** - * The earnings amount in cents. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -1145,36 +1104,15 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * The earnings currency code. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The number of hours associated with this earning. (For salaried employees, this could - * be hours per pay period, `0` or `null`, depending on the provider). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ fun hours(): Optional = hours.getOptional("hours") /** - * The exact name of the deduction from the pay statement. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun name(): Optional = name.getOptional("name") /** - * The type of earning. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -1187,24 +1125,6 @@ private constructor( */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - /** * Returns the raw JSON value of [hours]. * @@ -1248,8 +1168,6 @@ private constructor( class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() private var hours: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -1258,26 +1176,13 @@ private constructor( @JvmSynthetic internal fun from(earning: Earning) = apply { amount = earning.amount - attributes = earning.attributes - currency = earning.currency hours = earning.hours name = earning.name type = earning.type additionalProperties = earning.additionalProperties.toMutableMap() } - /** The earnings amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + fun amount(amount: Long) = amount(JsonField.of(amount)) /** * Sets [Builder.amount] to an arbitrary JSON value. @@ -1288,54 +1193,7 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - /** The earnings currency code. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * The number of hours associated with this earning. (For salaried employees, this - * could be hours per pay period, `0` or `null`, depending on the provider). - */ - fun hours(hours: Double?) = hours(JsonField.ofNullable(hours)) - - /** - * Alias for [Builder.hours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hours(hours: Double) = hours(hours as Double?) - - /** Alias for calling [Builder.hours] with `hours.orElse(null)`. */ - fun hours(hours: Optional) = hours(hours.getOrNull()) + fun hours(hours: Double) = hours(JsonField.of(hours)) /** * Sets [Builder.hours] to an arbitrary JSON value. @@ -1346,11 +1204,7 @@ private constructor( */ fun hours(hours: JsonField) = apply { this.hours = hours } - /** The exact name of the deduction from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) + fun name(name: String) = name(JsonField.of(name)) /** * Sets [Builder.name] to an arbitrary JSON value. @@ -1361,11 +1215,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** The type of earning. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) + fun type(type: Type) = type(JsonField.of(type)) /** * Sets [Builder.type] to an arbitrary JSON value. @@ -1404,15 +1254,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Earning = - Earning( - amount, - attributes, - currency, - hours, - name, - type, - additionalProperties.toMutableMap(), - ) + Earning(amount, hours, name, type, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -1423,8 +1265,6 @@ private constructor( } amount() - attributes().ifPresent { it.validate() } - currency() hours() name() type().ifPresent { it.validate() } @@ -1448,522 +1288,94 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + (if (hours.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns the raw JSON value of [metadata]. + * Returns this class instance's raw value. * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { + @JvmField val BONUS = of("bonus") - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val COMMISSION = of("commission") - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } + @JvmField val DOUBLE_OVERTIME = of("double_overtime") - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + @JvmField val OTHER = of("other") - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + @JvmField val OVERTIME = of("overtime") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val PTO = of("pto") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val REIMBURSEMENT = of("reimbursement") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val SALARY = of("salary") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val SEVERANCE = of("severance") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val SICK = of("sick") - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Attributes = - Attributes(metadata, additionalProperties.toMutableMap()) - } + @JvmField val TIPS = of("tips") - private var validated: Boolean = false + @JvmField val WAGE = of("wage") - fun validate(): Attributes = apply { - if (validated) { - return@apply - } + @JvmField val _1099 = of("1099") - metadata().ifPresent { it.validate() } - validated = true + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** An enum containing [Type]'s known values. */ + enum class Known { + BONUS, + COMMISSION, + DOUBLE_OVERTIME, + OTHER, + OVERTIME, + PTO, + REIMBURSEMENT, + SALARY, + SEVERANCE, + SICK, + TIPS, + WAGE, + _1099, + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * - * Used for best match union deserialization. + * 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. */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = - Metadata(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - /** 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 { - - @JvmField val SALARY = of("salary") - - @JvmField val WAGE = of("wage") - - @JvmField val REIMBURSEMENT = of("reimbursement") - - @JvmField val OVERTIME = of("overtime") - - @JvmField val SEVERANCE = of("severance") - - @JvmField val DOUBLE_OVERTIME = of("double_overtime") - - @JvmField val PTO = of("pto") - - @JvmField val SICK = of("sick") - - @JvmField val BONUS = of("bonus") - - @JvmField val COMMISSION = of("commission") - - @JvmField val TIPS = of("tips") - - @JvmField val _1099 = of("1099") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, + enum class Value { BONUS, COMMISSION, - TIPS, - _1099, + DOUBLE_OVERTIME, 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, - REIMBURSEMENT, OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, PTO, + REIMBURSEMENT, + SALARY, + SEVERANCE, SICK, - BONUS, - COMMISSION, TIPS, + WAGE, _1099, - OTHER, /** * An enum member indicating that [Type] was instantiated with an unknown value. */ @@ -1979,19 +1391,19 @@ private constructor( */ fun value(): Value = when (this) { - SALARY -> Value.SALARY - WAGE -> Value.WAGE - REIMBURSEMENT -> Value.REIMBURSEMENT - OVERTIME -> Value.OVERTIME - SEVERANCE -> Value.SEVERANCE + BONUS -> Value.BONUS + COMMISSION -> Value.COMMISSION DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME + OTHER -> Value.OTHER + OVERTIME -> Value.OVERTIME PTO -> Value.PTO + REIMBURSEMENT -> Value.REIMBURSEMENT + SALARY -> Value.SALARY + SEVERANCE -> Value.SEVERANCE SICK -> Value.SICK - BONUS -> Value.BONUS - COMMISSION -> Value.COMMISSION TIPS -> Value.TIPS + WAGE -> Value.WAGE _1099 -> Value._1099 - OTHER -> Value.OTHER else -> Value._UNKNOWN } @@ -2006,19 +1418,19 @@ private constructor( */ fun known(): Known = when (this) { - SALARY -> Known.SALARY - WAGE -> Known.WAGE - REIMBURSEMENT -> Known.REIMBURSEMENT - OVERTIME -> Known.OVERTIME - SEVERANCE -> Known.SEVERANCE + BONUS -> Known.BONUS + COMMISSION -> Known.COMMISSION DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME + OTHER -> Known.OTHER + OVERTIME -> Known.OVERTIME PTO -> Known.PTO + REIMBURSEMENT -> Known.REIMBURSEMENT + SALARY -> Known.SALARY + SEVERANCE -> Known.SEVERANCE SICK -> Known.SICK - BONUS -> Known.BONUS - COMMISSION -> Known.COMMISSION TIPS -> Known.TIPS + WAGE -> Known.WAGE _1099 -> Known._1099 - OTHER -> Known.OTHER else -> throw FinchInvalidDataException("Unknown Type: $value") } @@ -2081,51 +1493,39 @@ private constructor( return true } - return /* spotless:off */ other is Earning && amount == other.amount && attributes == other.attributes && currency == other.currency && hours == other.hours && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Earning && amount == other.amount && hours == other.hours && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, hours, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, hours, name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Earning{amount=$amount, attributes=$attributes, currency=$currency, hours=$hours, name=$name, type=$type, additionalProperties=$additionalProperties}" + "Earning{amount=$amount, hours=$hours, name=$name, type=$type, additionalProperties=$additionalProperties}" } class EmployeeDeduction private constructor( private val amount: JsonField, - private val attributes: JsonField, - private val currency: JsonField, private val name: JsonField, private val preTax: JsonField, - private val type: JsonField, + private val type: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("pre_tax") @ExcludeMissing preTax: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, name, preTax, type, mutableMapOf()) + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(amount, name, preTax, type, mutableMapOf()) /** - * The deduction amount in cents. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -2135,39 +1535,19 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * The deduction currency. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The deduction name from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ fun name(): Optional = name.getOptional("name") /** - * Boolean indicating if the deduction is pre-tax. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun preTax(): Optional = preTax.getOptional("pre_tax") /** - * Type of benefit. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun type(): Optional = type.getOptional("type") + fun type(): Optional = type.getOptional("type") /** * Returns the raw JSON value of [amount]. @@ -2176,24 +1556,6 @@ private constructor( */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - /** * Returns the raw JSON value of [name]. * @@ -2213,7 +1575,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -2239,36 +1601,21 @@ private constructor( class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var preTax: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(employeeDeduction: EmployeeDeduction) = apply { amount = employeeDeduction.amount - attributes = employeeDeduction.attributes - currency = employeeDeduction.currency name = employeeDeduction.name preTax = employeeDeduction.preTax type = employeeDeduction.type additionalProperties = employeeDeduction.additionalProperties.toMutableMap() } - /** The deduction amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + fun amount(amount: Long) = amount(JsonField.of(amount)) /** * Sets [Builder.amount] to an arbitrary JSON value. @@ -2279,44 +1626,7 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - /** The deduction currency. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The deduction name from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) + fun name(name: String) = name(JsonField.of(name)) /** * Sets [Builder.name] to an arbitrary JSON value. @@ -2327,18 +1637,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Boolean indicating if the deduction is pre-tax. */ - fun preTax(preTax: Boolean?) = preTax(JsonField.ofNullable(preTax)) - - /** - * Alias for [Builder.preTax]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preTax(preTax: Boolean) = preTax(preTax as Boolean?) - - /** Alias for calling [Builder.preTax] with `preTax.orElse(null)`. */ - fun preTax(preTax: Optional) = preTax(preTax.getOrNull()) + fun preTax(preTax: Boolean) = preTax(JsonField.of(preTax)) /** * Sets [Builder.preTax] to an arbitrary JSON value. @@ -2349,20 +1648,16 @@ private constructor( */ fun preTax(preTax: JsonField) = apply { this.preTax = preTax } - /** Type of benefit. */ - fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) + fun type(type: Type) = type(JsonField.of(type)) /** * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [BenefitType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2394,8 +1689,6 @@ private constructor( fun build(): EmployeeDeduction = EmployeeDeduction( amount, - attributes, - currency, name, preTax, type, @@ -2411,8 +1704,6 @@ private constructor( } amount() - attributes().ifPresent { it.validate() } - currency() name() preTax() type().ifPresent { it.validate() } @@ -2436,121 +1727,210 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (preTax.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns the raw JSON value of [metadata]. + * Returns this class instance's raw value. * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val _457 = of("457") - fun toBuilder() = Builder().from(this) + @JvmField val _401K = of("401k") - companion object { + @JvmField val _401K_ROTH = of("401k_roth") - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } + @JvmField val _401K_LOAN = of("401k_loan") - /** A builder for [Attributes]. */ - class Builder internal constructor() { + @JvmField val _403B = of("403b") - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val _403B_ROTH = of("403b_roth") - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } + @JvmField val _457_ROTH = of("457_roth") - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + @JvmField val COMMUTER = of("commuter") - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + @JvmField val CUSTOM_POST_TAX = of("custom_post_tax") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val CUSTOM_PRE_TAX = of("custom_pre_tax") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val FSA_DEPENDENT_CARE = of("fsa_dependent_care") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val FSA_MEDICAL = of("fsa_medical") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val HSA_POST = of("hsa_post") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val HSA_PRE = of("hsa_pre") + + @JvmField val S125_DENTAL = of("s125_dental") + + @JvmField val S125_MEDICAL = of("s125_medical") + + @JvmField val S125_VISION = of("s125_vision") + + @JvmField val SIMPLE = of("simple") + + @JvmField val SIMPLE_IRA = of("simple_ira") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + /** An enum containing [Type]'s known values. */ + enum class Known { + _457, + _401K, + _401K_ROTH, + _401K_LOAN, + _403B, + _403B_ROTH, + _457_ROTH, + COMMUTER, + CUSTOM_POST_TAX, + CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, + } + + /** + * 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 { + _457, + _401K, + _401K_ROTH, + _401K_LOAN, + _403B, + _403B_ROTH, + _457_ROTH, + COMMUTER, + CUSTOM_POST_TAX, + CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * An enum member indicating that [Type] was instantiated with an unknown value. */ - fun build(): Attributes = - Attributes(metadata, additionalProperties.toMutableMap()) + _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) { + _457 -> Value._457 + _401K -> Value._401K + _401K_ROTH -> Value._401K_ROTH + _401K_LOAN -> Value._401K_LOAN + _403B -> Value._403B + _403B_ROTH -> Value._403B_ROTH + _457_ROTH -> Value._457_ROTH + COMMUTER -> Value.COMMUTER + CUSTOM_POST_TAX -> Value.CUSTOM_POST_TAX + CUSTOM_PRE_TAX -> Value.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Value.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Value.FSA_MEDICAL + HSA_POST -> Value.HSA_POST + HSA_PRE -> Value.HSA_PRE + S125_DENTAL -> Value.S125_DENTAL + S125_MEDICAL -> Value.S125_MEDICAL + S125_VISION -> Value.S125_VISION + SIMPLE -> Value.SIMPLE + SIMPLE_IRA -> Value.SIMPLE_IRA + 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) { + _457 -> Known._457 + _401K -> Known._401K + _401K_ROTH -> Known._401K_ROTH + _401K_LOAN -> Known._401K_LOAN + _403B -> Known._403B + _403B_ROTH -> Known._403B_ROTH + _457_ROTH -> Known._457_ROTH + COMMUTER -> Known.COMMUTER + CUSTOM_POST_TAX -> Known.CUSTOM_POST_TAX + CUSTOM_PRE_TAX -> Known.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Known.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Known.FSA_MEDICAL + HSA_POST -> Known.HSA_POST + HSA_PRE -> Known.HSA_PRE + S125_DENTAL -> Known.S125_DENTAL + S125_MEDICAL -> Known.S125_MEDICAL + S125_VISION -> Known.S125_VISION + SIMPLE -> Known.SIMPLE + SIMPLE_IRA -> Known.SIMPLE_IRA + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + private var validated: Boolean = false - fun validate(): Attributes = apply { + fun validate(): Type = apply { if (validated) { return@apply } - metadata().ifPresent { it.validate() } + known() validated = true } @@ -2568,303 +1948,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = - Metadata(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -2872,47 +1968,35 @@ private constructor( return true } - return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && attributes == other.attributes && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && name == other.name && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, name, preTax, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, name, preTax, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "EmployeeDeduction{amount=$amount, attributes=$attributes, currency=$currency, name=$name, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" + "EmployeeDeduction{amount=$amount, name=$name, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" } class EmployerContribution private constructor( private val amount: JsonField, - private val attributes: JsonField, - private val currency: JsonField, private val name: JsonField, - private val type: JsonField, + private val type: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, name, type, mutableMapOf()) + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(amount, name, type, mutableMapOf()) /** - * The contribution amount in cents. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -2922,31 +2006,13 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * The contribution currency. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The contribution name from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ fun name(): Optional = name.getOptional("name") /** - * Type of benefit. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun type(): Optional = type.getOptional("type") + fun type(): Optional = type.getOptional("type") /** * Returns the raw JSON value of [amount]. @@ -2955,24 +2021,6 @@ private constructor( */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - /** * Returns the raw JSON value of [name]. * @@ -2985,7 +2033,7 @@ private constructor( * * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -3011,34 +2059,19 @@ private constructor( class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(employerContribution: EmployerContribution) = apply { amount = employerContribution.amount - attributes = employerContribution.attributes - currency = employerContribution.currency name = employerContribution.name type = employerContribution.type additionalProperties = employerContribution.additionalProperties.toMutableMap() } - /** The contribution amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + fun amount(amount: Long) = amount(JsonField.of(amount)) /** * Sets [Builder.amount] to an arbitrary JSON value. @@ -3049,44 +2082,7 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - /** The contribution currency. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The contribution name from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) + fun name(name: String) = name(JsonField.of(name)) /** * Sets [Builder.name] to an arbitrary JSON value. @@ -3097,20 +2093,16 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** Type of benefit. */ - fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) + fun type(type: Type) = type(JsonField.of(type)) /** * Sets [Builder.type] to an arbitrary JSON value. * - * You should usually call [Builder.type] with a well-typed [BenefitType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun type(type: JsonField) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3140,14 +2132,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): EmployerContribution = - EmployerContribution( - amount, - attributes, - currency, - name, - type, - additionalProperties.toMutableMap(), - ) + EmployerContribution(amount, name, type, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -3158,8 +2143,6 @@ private constructor( } amount() - attributes().ifPresent { it.validate() } - currency() name() type().ifPresent { it.validate() } validated = true @@ -3182,120 +2165,209 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns the raw JSON value of [metadata]. + * Returns this class instance's raw value. * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + companion object { - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmField val _457 = of("457") - fun toBuilder() = Builder().from(this) + @JvmField val _401K = of("401k") - companion object { + @JvmField val _401K_ROTH = of("401k_roth") - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } + @JvmField val _401K_LOAN = of("401k_loan") - /** A builder for [Attributes]. */ - class Builder internal constructor() { + @JvmField val _403B = of("403b") - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val _403B_ROTH = of("403b_roth") - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } + @JvmField val _457_ROTH = of("457_roth") - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + @JvmField val COMMUTER = of("commuter") - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + @JvmField val CUSTOM_POST_TAX = of("custom_post_tax") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val CUSTOM_PRE_TAX = of("custom_pre_tax") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val FSA_DEPENDENT_CARE = of("fsa_dependent_care") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val FSA_MEDICAL = of("fsa_medical") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val HSA_POST = of("hsa_post") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val HSA_PRE = of("hsa_pre") + + @JvmField val S125_DENTAL = of("s125_dental") + + @JvmField val S125_MEDICAL = of("s125_medical") + + @JvmField val S125_VISION = of("s125_vision") + + @JvmField val SIMPLE = of("simple") + + @JvmField val SIMPLE_IRA = of("simple_ira") + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + _457, + _401K, + _401K_ROTH, + _401K_LOAN, + _403B, + _403B_ROTH, + _457_ROTH, + COMMUTER, + CUSTOM_POST_TAX, + CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, + } + + /** + * 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 { + _457, + _401K, + _401K_ROTH, + _401K_LOAN, + _403B, + _403B_ROTH, + _457_ROTH, + COMMUTER, + CUSTOM_POST_TAX, + CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. + * An enum member indicating that [Type] was instantiated with an unknown value. */ - fun build(): Attributes = - Attributes(metadata, additionalProperties.toMutableMap()) + _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) { + _457 -> Value._457 + _401K -> Value._401K + _401K_ROTH -> Value._401K_ROTH + _401K_LOAN -> Value._401K_LOAN + _403B -> Value._403B + _403B_ROTH -> Value._403B_ROTH + _457_ROTH -> Value._457_ROTH + COMMUTER -> Value.COMMUTER + CUSTOM_POST_TAX -> Value.CUSTOM_POST_TAX + CUSTOM_PRE_TAX -> Value.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Value.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Value.FSA_MEDICAL + HSA_POST -> Value.HSA_POST + HSA_PRE -> Value.HSA_PRE + S125_DENTAL -> Value.S125_DENTAL + S125_MEDICAL -> Value.S125_MEDICAL + S125_VISION -> Value.S125_VISION + SIMPLE -> Value.SIMPLE + SIMPLE_IRA -> Value.SIMPLE_IRA + 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) { + _457 -> Known._457 + _401K -> Known._401K + _401K_ROTH -> Known._401K_ROTH + _401K_LOAN -> Known._401K_LOAN + _403B -> Known._403B + _403B_ROTH -> Known._403B_ROTH + _457_ROTH -> Known._457_ROTH + COMMUTER -> Known.COMMUTER + CUSTOM_POST_TAX -> Known.CUSTOM_POST_TAX + CUSTOM_PRE_TAX -> Known.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Known.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Known.FSA_MEDICAL + HSA_POST -> Known.HSA_POST + HSA_PRE -> Known.HSA_PRE + S125_DENTAL -> Known.S125_DENTAL + S125_MEDICAL -> Known.S125_MEDICAL + S125_VISION -> Known.S125_VISION + SIMPLE -> Known.SIMPLE + SIMPLE_IRA -> Known.SIMPLE_IRA + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + private var validated: Boolean = false - fun validate(): Attributes = apply { + fun validate(): Type = apply { if (validated) { return@apply } - metadata().ifPresent { it.validate() } + known() validated = true } @@ -3313,303 +2385,19 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = - Metadata(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() } override fun equals(other: Any?): Boolean { @@ -3617,20 +2405,19 @@ private constructor( return true } - return /* spotless:off */ other is EmployerContribution && amount == other.amount && attributes == other.attributes && currency == other.currency && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EmployerContribution && amount == other.amount && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "EmployerContribution{amount=$amount, attributes=$attributes, currency=$currency, name=$name, type=$type, additionalProperties=$additionalProperties}" + "EmployerContribution{amount=$amount, name=$name, type=$type, additionalProperties=$additionalProperties}" } - /** The payment method. */ class PaymentMethod @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -3771,8 +2558,6 @@ private constructor( class Tax private constructor( private val amount: JsonField, - private val attributes: JsonField, - private val currency: JsonField, private val employer: JsonField, private val name: JsonField, private val type: JsonField, @@ -3782,22 +2567,14 @@ private constructor( @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), @JsonProperty("employer") @ExcludeMissing employer: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, employer, name, type, mutableMapOf()) + ) : this(amount, employer, name, type, mutableMapOf()) /** - * The tax amount in cents. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -3807,35 +2584,15 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * The currency code. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * `true` if the amount is paid by the employers. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ fun employer(): Optional = employer.getOptional("employer") /** - * The exact name of tax from the pay statement. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun name(): Optional = name.getOptional("name") /** - * The type of taxes. - * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ @@ -3848,24 +2605,6 @@ private constructor( */ @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - /** * Returns the raw JSON value of [employer]. * @@ -3910,8 +2649,6 @@ private constructor( class Builder internal constructor() { private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() private var employer: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() @@ -3920,26 +2657,13 @@ private constructor( @JvmSynthetic internal fun from(tax: Tax) = apply { amount = tax.amount - attributes = tax.attributes - currency = tax.currency employer = tax.employer name = tax.name type = tax.type additionalProperties = tax.additionalProperties.toMutableMap() } - /** The tax amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) + fun amount(amount: Long) = amount(JsonField.of(amount)) /** * Sets [Builder.amount] to an arbitrary JSON value. @@ -3950,51 +2674,7 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - /** The currency code. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** `true` if the amount is paid by the employers. */ - fun employer(employer: Boolean?) = employer(JsonField.ofNullable(employer)) - - /** - * Alias for [Builder.employer]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun employer(employer: Boolean) = employer(employer as Boolean?) - - /** Alias for calling [Builder.employer] with `employer.orElse(null)`. */ - fun employer(employer: Optional) = employer(employer.getOrNull()) + fun employer(employer: Boolean) = employer(JsonField.of(employer)) /** * Sets [Builder.employer] to an arbitrary JSON value. @@ -4005,11 +2685,7 @@ private constructor( */ fun employer(employer: JsonField) = apply { this.employer = employer } - /** The exact name of tax from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) + fun name(name: String) = name(JsonField.of(name)) /** * Sets [Builder.name] to an arbitrary JSON value. @@ -4020,11 +2696,7 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - /** The type of taxes. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) + fun type(type: Type) = type(JsonField.of(type)) /** * Sets [Builder.type] to an arbitrary JSON value. @@ -4063,15 +2735,7 @@ private constructor( * Further updates to this [Builder] will not mutate the returned instance. */ fun build(): Tax = - Tax( - amount, - attributes, - currency, - employer, - name, - type, - additionalProperties.toMutableMap(), - ) + Tax(amount, employer, name, type, additionalProperties.toMutableMap()) } private var validated: Boolean = false @@ -4082,8 +2746,6 @@ private constructor( } amount() - attributes().ifPresent { it.validate() } - currency() employer() name() type().ifPresent { it.validate() } @@ -4107,438 +2769,10 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + (if (employer.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (type.asKnown().getOrNull()?.validity() ?: 0) - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Attributes = - Attributes(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = - Metadata(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - /** The type of taxes. */ class Type @JsonCreator private constructor(private val value: JsonField) : Enum { @@ -4554,23 +2788,23 @@ private constructor( companion object { - @JvmField val STATE = of("state") - @JvmField val FEDERAL = of("federal") + @JvmField val FICA = of("fica") + @JvmField val LOCAL = of("local") - @JvmField val FICA = of("fica") + @JvmField val STATE = of("state") @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } /** An enum containing [Type]'s known values. */ enum class Known { - STATE, FEDERAL, - LOCAL, FICA, + LOCAL, + STATE, } /** @@ -4583,10 +2817,10 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - STATE, FEDERAL, - LOCAL, FICA, + LOCAL, + STATE, /** * An enum member indicating that [Type] was instantiated with an unknown value. */ @@ -4602,10 +2836,10 @@ private constructor( */ fun value(): Value = when (this) { - STATE -> Value.STATE FEDERAL -> Value.FEDERAL - LOCAL -> Value.LOCAL FICA -> Value.FICA + LOCAL -> Value.LOCAL + STATE -> Value.STATE else -> Value._UNKNOWN } @@ -4620,10 +2854,10 @@ private constructor( */ fun known(): Known = when (this) { - STATE -> Known.STATE FEDERAL -> Known.FEDERAL - LOCAL -> Known.LOCAL FICA -> Known.FICA + LOCAL -> Known.LOCAL + STATE -> Known.STATE else -> throw FinchInvalidDataException("Unknown Type: $value") } @@ -4686,20 +2920,19 @@ private constructor( return true } - return /* spotless:off */ other is Tax && amount == other.amount && attributes == other.attributes && currency == other.currency && employer == other.employer && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tax && amount == other.amount && employer == other.employer && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, employer, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, employer, name, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Tax{amount=$amount, attributes=$attributes, currency=$currency, employer=$employer, name=$name, type=$type, additionalProperties=$additionalProperties}" + "Tax{amount=$amount, 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 { /** @@ -4714,20 +2947,20 @@ private constructor( companion object { - @JvmField val REGULAR_PAYROLL = of("regular_payroll") - @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") + @JvmField val REGULAR_PAYROLL = of("regular_payroll") + @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, + REGULAR_PAYROLL, } /** @@ -4740,9 +2973,9 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - REGULAR_PAYROLL, OFF_CYCLE_PAYROLL, ONE_TIME_PAYMENT, + REGULAR_PAYROLL, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4756,9 +2989,9 @@ private constructor( */ fun value(): Value = when (this) { - REGULAR_PAYROLL -> Value.REGULAR_PAYROLL OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Value.REGULAR_PAYROLL else -> Value._UNKNOWN } @@ -4773,9 +3006,9 @@ private constructor( */ fun known(): Known = when (this) { - REGULAR_PAYROLL -> Known.REGULAR_PAYROLL OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Known.REGULAR_PAYROLL else -> throw FinchInvalidDataException("Unknown Type: $value") } @@ -4838,17 +3071,17 @@ private constructor( return true } - return /* spotless:off */ other is PayStatement && earnings == other.earnings && employeeDeductions == other.employeeDeductions && employerContributions == other.employerContributions && grossPay == other.grossPay && individualId == other.individualId && netPay == other.netPay && paymentMethod == other.paymentMethod && taxes == other.taxes && totalHours == other.totalHours && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is PayStatement && individualId == other.individualId && earnings == other.earnings && employeeDeductions == other.employeeDeductions && employerContributions == other.employerContributions && grossPay == other.grossPay && netPay == other.netPay && paymentMethod == other.paymentMethod && taxes == other.taxes && totalHours == other.totalHours && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(earnings, employeeDeductions, employerContributions, grossPay, individualId, netPay, paymentMethod, taxes, totalHours, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(individualId, earnings, employeeDeductions, employerContributions, grossPay, netPay, paymentMethod, taxes, totalHours, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "PayStatement{earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, individualId=$individualId, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" + "PayStatement{individualId=$individualId, earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt index 7dd0db87..36c9661d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AccessTokenServiceAsync { @@ -16,6 +17,13 @@ interface AccessTokenServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccessTokenServiceAsync + /** Exchange the authorization code for an access token */ fun create(params: AccessTokenCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -32,18 +40,25 @@ interface AccessTokenServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccessTokenServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /auth/token`, but is otherwise the same as * [AccessTokenServiceAsync.create]. */ - @MustBeClosed fun create( params: AccessTokenCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: AccessTokenCreateParams, requestOptions: RequestOptions = RequestOptions.none(), 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 6ad0bf71..ef156b00 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.errors.FinchException import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions override fun withRawResponse(): AccessTokenServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccessTokenServiceAsync = + AccessTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AccessTokenCreateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccessTokenServiceAsync.WithRawResponse = + AccessTokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -77,6 +88,7 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("auth", "token") .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(modifiedParams._queryParams()) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt index 787a514b..7212dfad 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountDisconnectParams @@ -10,6 +10,7 @@ import com.tryfinch.api.models.AccountIntrospectParams import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AccountServiceAsync { @@ -18,6 +19,13 @@ interface AccountServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountServiceAsync + /** Disconnect one or more `access_token`s from your application. */ fun disconnect(): CompletableFuture = disconnect(AccountDisconnectParams.none()) @@ -60,30 +68,35 @@ interface AccountServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /disconnect`, but is otherwise the same as * [AccountServiceAsync.disconnect]. */ - @MustBeClosed fun disconnect(): CompletableFuture> = disconnect(AccountDisconnectParams.none()) /** @see [disconnect] */ - @MustBeClosed fun disconnect( params: AccountDisconnectParams = AccountDisconnectParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [disconnect] */ - @MustBeClosed fun disconnect( params: AccountDisconnectParams = AccountDisconnectParams.none() ): CompletableFuture> = disconnect(params, RequestOptions.none()) /** @see [disconnect] */ - @MustBeClosed fun disconnect( requestOptions: RequestOptions ): CompletableFuture> = @@ -93,26 +106,22 @@ interface AccountServiceAsync { * Returns a raw HTTP response for `get /introspect`, but is otherwise the same as * [AccountServiceAsync.introspect]. */ - @MustBeClosed fun introspect(): CompletableFuture> = introspect(AccountIntrospectParams.none()) /** @see [introspect] */ - @MustBeClosed fun introspect( params: AccountIntrospectParams = AccountIntrospectParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [introspect] */ - @MustBeClosed fun introspect( params: AccountIntrospectParams = AccountIntrospectParams.none() ): CompletableFuture> = introspect(params, RequestOptions.none()) /** @see [introspect] */ - @MustBeClosed fun introspect( requestOptions: RequestOptions ): CompletableFuture> = 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 dc00271c..3ba53cae 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 @@ -20,6 +20,7 @@ import com.tryfinch.api.models.AccountIntrospectParams import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AccountServiceAsync { @@ -30,6 +31,9 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): AccountServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccountServiceAsync = + AccountServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun disconnect( params: AccountDisconnectParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse = + AccountServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val disconnectHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -59,6 +70,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("disconnect") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -89,6 +101,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("introspect") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsync.kt index 53ceda78..511e36b2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsync.kt @@ -2,7 +2,9 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.connect.SessionServiceAsync +import java.util.function.Consumer interface ConnectServiceAsync { @@ -11,6 +13,13 @@ interface ConnectServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectServiceAsync + fun sessions(): SessionServiceAsync /** @@ -18,6 +27,15 @@ interface ConnectServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConnectServiceAsync.WithRawResponse + fun sessions(): SessionServiceAsync.WithRawResponse } } 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 f93bc643..38e8db16 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 @@ -5,6 +5,7 @@ package com.tryfinch.api.services.async import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.connect.SessionServiceAsync import com.tryfinch.api.services.async.connect.SessionServiceAsyncImpl +import java.util.function.Consumer class ConnectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ConnectServiceAsync { @@ -17,6 +18,9 @@ class ConnectServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): ConnectServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConnectServiceAsync = + ConnectServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun sessions(): SessionServiceAsync = sessions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class ConnectServiceAsyncImpl internal constructor(private val clientOptions: Cl SessionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConnectServiceAsync.WithRawResponse = + ConnectServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun sessions(): SessionServiceAsync.WithRawResponse = sessions } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsync.kt index 9a2feba1..0093242b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.hris.BenefitServiceAsync import com.tryfinch.api.services.async.hris.CompanyServiceAsync import com.tryfinch.api.services.async.hris.DirectoryServiceAsync @@ -10,6 +11,7 @@ import com.tryfinch.api.services.async.hris.EmploymentServiceAsync import com.tryfinch.api.services.async.hris.IndividualServiceAsync import com.tryfinch.api.services.async.hris.PayStatementServiceAsync import com.tryfinch.api.services.async.hris.PaymentServiceAsync +import java.util.function.Consumer interface HrisServiceAsync { @@ -18,6 +20,13 @@ interface HrisServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HrisServiceAsync + fun company(): CompanyServiceAsync fun directory(): DirectoryServiceAsync @@ -37,6 +46,13 @@ interface HrisServiceAsync { /** A view of [HrisServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HrisServiceAsync.WithRawResponse + fun company(): CompanyServiceAsync.WithRawResponse fun directory(): DirectoryServiceAsync.WithRawResponse 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 93d03324..afccc63c 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.services.async.hris.PayStatementServiceAsync import com.tryfinch.api.services.async.hris.PayStatementServiceAsyncImpl import com.tryfinch.api.services.async.hris.PaymentServiceAsync import com.tryfinch.api.services.async.hris.PaymentServiceAsyncImpl +import java.util.function.Consumer class HrisServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : HrisServiceAsync { @@ -53,6 +54,9 @@ class HrisServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): HrisServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): HrisServiceAsync = + HrisServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun company(): CompanyServiceAsync = company override fun directory(): DirectoryServiceAsync = directory @@ -104,6 +108,13 @@ class HrisServiceAsyncImpl internal constructor(private val clientOptions: Clien BenefitServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): HrisServiceAsync.WithRawResponse = + HrisServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun company(): CompanyServiceAsync.WithRawResponse = company override fun directory(): DirectoryServiceAsync.WithRawResponse = directory diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsync.kt index 5b415166..d0f8e96a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsync.kt @@ -2,8 +2,10 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.jobs.AutomatedServiceAsync import com.tryfinch.api.services.async.jobs.ManualServiceAsync +import java.util.function.Consumer interface JobServiceAsync { @@ -12,6 +14,13 @@ interface JobServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync + fun automated(): AutomatedServiceAsync fun manual(): ManualServiceAsync @@ -19,6 +28,13 @@ interface JobServiceAsync { /** A view of [JobServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync.WithRawResponse + fun automated(): AutomatedServiceAsync.WithRawResponse fun manual(): ManualServiceAsync.WithRawResponse 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 5849135c..e1313907 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 @@ -7,6 +7,7 @@ import com.tryfinch.api.services.async.jobs.AutomatedServiceAsync import com.tryfinch.api.services.async.jobs.AutomatedServiceAsyncImpl import com.tryfinch.api.services.async.jobs.ManualServiceAsync import com.tryfinch.api.services.async.jobs.ManualServiceAsyncImpl +import java.util.function.Consumer class JobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : JobServiceAsync { @@ -23,6 +24,9 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): JobServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobServiceAsync = + JobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun automated(): AutomatedServiceAsync = automated override fun manual(): ManualServiceAsync = manual @@ -38,6 +42,13 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client ManualServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobServiceAsync.WithRawResponse = + JobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun automated(): AutomatedServiceAsync.WithRawResponse = automated override fun manual(): ManualServiceAsync.WithRawResponse = manual diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsync.kt index 66caaaaa..c7c8ab69 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsync.kt @@ -2,7 +2,9 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.payroll.PayGroupServiceAsync +import java.util.function.Consumer interface PayrollServiceAsync { @@ -11,6 +13,13 @@ interface PayrollServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayrollServiceAsync + fun payGroups(): PayGroupServiceAsync /** @@ -18,6 +27,15 @@ interface PayrollServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayrollServiceAsync.WithRawResponse + fun payGroups(): PayGroupServiceAsync.WithRawResponse } } 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 6c3ca41f..ee6470c8 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 @@ -5,6 +5,7 @@ package com.tryfinch.api.services.async import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.payroll.PayGroupServiceAsync import com.tryfinch.api.services.async.payroll.PayGroupServiceAsyncImpl +import java.util.function.Consumer class PayrollServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PayrollServiceAsync { @@ -17,6 +18,9 @@ class PayrollServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): PayrollServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayrollServiceAsync = + PayrollServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun payGroups(): PayGroupServiceAsync = payGroups class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class PayrollServiceAsyncImpl internal constructor(private val clientOptions: Cl PayGroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): PayrollServiceAsync.WithRawResponse = + PayrollServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun payGroups(): PayGroupServiceAsync.WithRawResponse = payGroups } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt index 4f112fda..40d2a85c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ProviderListPageAsync import com.tryfinch.api.models.ProviderListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ProviderServiceAsync { @@ -16,6 +17,13 @@ interface ProviderServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderServiceAsync + /** Return details on all available payroll and HR systems. */ fun list(): CompletableFuture = list(ProviderListParams.none()) @@ -39,30 +47,35 @@ interface ProviderServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ProviderServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /providers`, but is otherwise the same as * [ProviderServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(ProviderListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: ProviderListParams = ProviderListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: ProviderListParams = ProviderListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = 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 9de04dba..4a98315b 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.models.Provider import com.tryfinch.api.models.ProviderListPageAsync import com.tryfinch.api.models.ProviderListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ProviderServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ProviderServiceAsync { @@ -28,6 +29,9 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): ProviderServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ProviderServiceAsync = + ProviderServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: ProviderListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ProviderServiceAsync.WithRawResponse = + ProviderServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("providers") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt index 323e5566..883d8abc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RequestForwardingServiceAsync { @@ -16,6 +17,13 @@ interface RequestForwardingServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RequestForwardingServiceAsync + /** * The Forward API allows you to make direct requests to an employment system. If Finch’s * unified API doesn’t have a data model that cleanly fits your needs, then Forward allows you @@ -37,18 +45,25 @@ interface RequestForwardingServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RequestForwardingServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /forward`, but is otherwise the same as * [RequestForwardingServiceAsync.forward]. */ - @MustBeClosed fun forward( params: RequestForwardingForwardParams ): CompletableFuture> = forward(params, RequestOptions.none()) /** @see [forward] */ - @MustBeClosed fun forward( params: RequestForwardingForwardParams, requestOptions: RequestOptions = RequestOptions.none(), 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 25b6c483..3f406b22 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class RequestForwardingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RequestForwardingServiceAsync { @@ -28,6 +29,11 @@ internal constructor(private val clientOptions: ClientOptions) : RequestForwardi override fun withRawResponse(): RequestForwardingServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): RequestForwardingServiceAsync = + RequestForwardingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun forward( params: RequestForwardingForwardParams, requestOptions: RequestOptions, @@ -40,6 +46,13 @@ internal constructor(private val clientOptions: ClientOptions) : RequestForwardi private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RequestForwardingServiceAsync.WithRawResponse = + RequestForwardingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val forwardHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +64,7 @@ internal constructor(private val clientOptions: ClientOptions) : RequestForwardi val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("forward") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsync.kt index d7cf62b6..f04490d9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.sandbox.CompanyServiceAsync import com.tryfinch.api.services.async.sandbox.ConnectionServiceAsync import com.tryfinch.api.services.async.sandbox.DirectoryServiceAsync @@ -9,6 +10,7 @@ import com.tryfinch.api.services.async.sandbox.EmploymentServiceAsync import com.tryfinch.api.services.async.sandbox.IndividualServiceAsync import com.tryfinch.api.services.async.sandbox.JobServiceAsync import com.tryfinch.api.services.async.sandbox.PaymentServiceAsync +import java.util.function.Consumer interface SandboxServiceAsync { @@ -17,6 +19,13 @@ interface SandboxServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SandboxServiceAsync + fun connections(): ConnectionServiceAsync fun company(): CompanyServiceAsync @@ -36,6 +45,15 @@ interface SandboxServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SandboxServiceAsync.WithRawResponse + fun connections(): ConnectionServiceAsync.WithRawResponse fun company(): CompanyServiceAsync.WithRawResponse 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 409d5daf..65186547 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.services.async.sandbox.JobServiceAsync import com.tryfinch.api.services.async.sandbox.JobServiceAsyncImpl import com.tryfinch.api.services.async.sandbox.PaymentServiceAsync import com.tryfinch.api.services.async.sandbox.PaymentServiceAsyncImpl +import java.util.function.Consumer class SandboxServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SandboxServiceAsync { @@ -49,6 +50,9 @@ class SandboxServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): SandboxServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SandboxServiceAsync = + SandboxServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun connections(): ConnectionServiceAsync = connections override fun company(): CompanyServiceAsync = company @@ -94,6 +98,13 @@ class SandboxServiceAsyncImpl internal constructor(private val clientOptions: Cl JobServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): SandboxServiceAsync.WithRawResponse = + SandboxServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun connections(): ConnectionServiceAsync.WithRawResponse = connections override fun company(): CompanyServiceAsync.WithRawResponse = company diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsync.kt index 922adb3f..67dae0f0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsync.kt @@ -2,11 +2,20 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.http.Headers import com.tryfinch.api.models.WebhookEvent +import java.util.function.Consumer interface WebhookServiceAsync { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebhookServiceAsync + fun unwrap(payload: String, headers: Headers, secret: String?): WebhookEvent fun verifySignature(payload: String, headers: Headers, secret: String?) 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 594a5792..c6488253 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 @@ -12,6 +12,7 @@ import java.security.MessageDigest import java.time.Duration import java.time.Instant import java.util.Base64 +import java.util.function.Consumer import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec import kotlin.jvm.optionals.getOrNull @@ -19,6 +20,9 @@ import kotlin.jvm.optionals.getOrNull class WebhookServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : WebhookServiceAsync { + override fun withOptions(modifier: Consumer): WebhookServiceAsync = + WebhookServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun unwrap(payload: String, headers: Headers, secret: String?): WebhookEvent { verifySignature(payload, headers, secret) return try { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt index 3b1e18cb..930e06a7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.connect -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectSessionNewParams @@ -10,6 +10,7 @@ import com.tryfinch.api.models.ConnectSessionReauthenticateParams import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface SessionServiceAsync { @@ -18,6 +19,13 @@ interface SessionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SessionServiceAsync + /** Create a new connect session for an employer */ fun new_(params: ConnectSessionNewParams): CompletableFuture = new_(params, RequestOptions.none()) @@ -45,18 +53,25 @@ interface SessionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SessionServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /connect/sessions`, but is otherwise the same as * [SessionServiceAsync.new_]. */ - @MustBeClosed fun new_( params: ConnectSessionNewParams ): CompletableFuture> = new_(params, RequestOptions.none()) /** @see [new_] */ - @MustBeClosed fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -66,14 +81,12 @@ interface SessionServiceAsync { * Returns a raw HTTP response for `post /connect/sessions/reauthenticate`, but is otherwise * the same as [SessionServiceAsync.reauthenticate]. */ - @MustBeClosed fun reauthenticate( params: ConnectSessionReauthenticateParams ): CompletableFuture> = reauthenticate(params, RequestOptions.none()) /** @see [reauthenticate] */ - @MustBeClosed fun reauthenticate( params: ConnectSessionReauthenticateParams, requestOptions: RequestOptions = RequestOptions.none(), 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 b703391c..384db65f 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 @@ -20,6 +20,7 @@ import com.tryfinch.api.models.ConnectSessionReauthenticateParams import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class SessionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SessionServiceAsync { @@ -30,6 +31,9 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): SessionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SessionServiceAsync = + SessionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SessionServiceAsync.WithRawResponse = + SessionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val newHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -59,6 +70,7 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("connect", "sessions") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -90,6 +102,7 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("connect", "sessions", "reauthenticate") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt index 78490ed2..3d239a23 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyBenefit @@ -17,6 +17,7 @@ import com.tryfinch.api.models.HrisBenefitUpdateParams import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface BenefitServiceAsync { @@ -25,6 +26,13 @@ interface BenefitServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BenefitServiceAsync + fun individuals(): IndividualServiceAsync /** @@ -167,32 +175,37 @@ interface BenefitServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BenefitServiceAsync.WithRawResponse + fun individuals(): IndividualServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /employer/benefits`, but is otherwise the same as * [BenefitServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(HrisBenefitCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: HrisBenefitCreateParams = HrisBenefitCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: HrisBenefitCreateParams = HrisBenefitCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -202,12 +215,10 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}`, but is otherwise * the same as [BenefitServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(benefitId: String): CompletableFuture> = retrieve(benefitId, HrisBenefitRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( benefitId: String, params: HrisBenefitRetrieveParams = HrisBenefitRetrieveParams.none(), @@ -216,7 +227,6 @@ interface BenefitServiceAsync { retrieve(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( benefitId: String, params: HrisBenefitRetrieveParams = HrisBenefitRetrieveParams.none(), @@ -224,21 +234,18 @@ interface BenefitServiceAsync { retrieve(benefitId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: HrisBenefitRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: HrisBenefitRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( benefitId: String, requestOptions: RequestOptions, @@ -249,14 +256,12 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `post /employer/benefits/{benefit_id}`, but is otherwise * the same as [BenefitServiceAsync.update]. */ - @MustBeClosed fun update( benefitId: String ): CompletableFuture> = update(benefitId, HrisBenefitUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( benefitId: String, params: HrisBenefitUpdateParams = HrisBenefitUpdateParams.none(), @@ -265,7 +270,6 @@ interface BenefitServiceAsync { update(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( benefitId: String, params: HrisBenefitUpdateParams = HrisBenefitUpdateParams.none(), @@ -273,21 +277,18 @@ interface BenefitServiceAsync { update(benefitId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: HrisBenefitUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: HrisBenefitUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( benefitId: String, requestOptions: RequestOptions, @@ -298,26 +299,22 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `get /employer/benefits`, but is otherwise the same as * [BenefitServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisBenefitListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisBenefitListParams = HrisBenefitListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisBenefitListParams = HrisBenefitListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -327,13 +324,11 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `get /employer/benefits/meta`, but is otherwise the same * as [BenefitServiceAsync.listSupportedBenefits]. */ - @MustBeClosed fun listSupportedBenefits(): CompletableFuture> = listSupportedBenefits(HrisBenefitListSupportedBenefitsParams.none()) /** @see [listSupportedBenefits] */ - @MustBeClosed fun listSupportedBenefits( params: HrisBenefitListSupportedBenefitsParams = HrisBenefitListSupportedBenefitsParams.none(), @@ -341,7 +336,6 @@ interface BenefitServiceAsync { ): CompletableFuture> /** @see [listSupportedBenefits] */ - @MustBeClosed fun listSupportedBenefits( params: HrisBenefitListSupportedBenefitsParams = HrisBenefitListSupportedBenefitsParams.none() @@ -349,7 +343,6 @@ interface BenefitServiceAsync { listSupportedBenefits(params, RequestOptions.none()) /** @see [listSupportedBenefits] */ - @MustBeClosed fun listSupportedBenefits( requestOptions: RequestOptions ): CompletableFuture> = 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 1e38a525..05273d48 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 @@ -16,7 +16,6 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.json import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepareAsync -import com.tryfinch.api.models.BenefitListSupportedBenefitsResponse import com.tryfinch.api.models.CompanyBenefit import com.tryfinch.api.models.CreateCompanyBenefitsResponse import com.tryfinch.api.models.HrisBenefitCreateParams @@ -26,11 +25,13 @@ import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsPageAsync import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams +import com.tryfinch.api.models.SupportedBenefit import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsyncImpl import java.util.Optional import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BenefitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -46,6 +47,9 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): BenefitServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BenefitServiceAsync = + BenefitServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun individuals(): IndividualServiceAsync = individuals override fun create( @@ -92,6 +96,13 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl IndividualServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): BenefitServiceAsync.WithRawResponse = + BenefitServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun individuals(): IndividualServiceAsync.WithRawResponse = individuals private val createHandler: Handler = @@ -105,6 +116,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -138,6 +150,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -171,6 +184,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -202,6 +216,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits") .build() .prepareAsync(clientOptions, params) @@ -229,11 +244,8 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val listSupportedBenefitsHandler: - Handler>> = - jsonHandler>>( - clientOptions.jsonMapper - ) + private val listSupportedBenefitsHandler: Handler>> = + jsonHandler>>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun listSupportedBenefits( @@ -243,6 +255,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", "meta") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt index cfdf2ff3..ca3d512f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt @@ -2,13 +2,14 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.Company import com.tryfinch.api.models.HrisCompanyRetrieveParams import com.tryfinch.api.services.async.hris.company.PayStatementItemServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CompanyServiceAsync { @@ -17,6 +18,13 @@ interface CompanyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyServiceAsync + fun payStatementItem(): PayStatementItemServiceAsync /** Read basic company data */ @@ -42,31 +50,36 @@ interface CompanyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompanyServiceAsync.WithRawResponse + fun payStatementItem(): PayStatementItemServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `get /employer/company`, but is otherwise the same as * [CompanyServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(): CompletableFuture> = retrieve(HrisCompanyRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: HrisCompanyRetrieveParams = HrisCompanyRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: HrisCompanyRetrieveParams = HrisCompanyRetrieveParams.none() ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve(requestOptions: RequestOptions): CompletableFuture> = retrieve(HrisCompanyRetrieveParams.none(), requestOptions) } 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 36674057..61e667e3 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisCompanyRetrieveParams import com.tryfinch.api.services.async.hris.company.PayStatementItemServiceAsync import com.tryfinch.api.services.async.hris.company.PayStatementItemServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CompanyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CompanyServiceAsync { @@ -33,6 +34,9 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): CompanyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompanyServiceAsync = + CompanyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun payStatementItem(): PayStatementItemServiceAsync = payStatementItem override fun retrieve( @@ -51,6 +55,13 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl PayStatementItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): CompanyServiceAsync.WithRawResponse = + CompanyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun payStatementItem(): PayStatementItemServiceAsync.WithRawResponse = payStatementItem @@ -64,6 +75,7 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "company") .build() .prepareAsync(clientOptions, params) 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 83b5b834..9bfba346 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 @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisDirectoryListIndividualsPageAsync @@ -10,6 +10,7 @@ import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPageAsync import com.tryfinch.api.models.HrisDirectoryListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface DirectoryServiceAsync { @@ -18,6 +19,13 @@ interface DirectoryServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryServiceAsync + /** Read company directory and organization structure */ fun list(): CompletableFuture = list(HrisDirectoryListParams.none()) @@ -67,30 +75,35 @@ interface DirectoryServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DirectoryServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/directory`, but is otherwise the same as * [DirectoryServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisDirectoryListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisDirectoryListParams = HrisDirectoryListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisDirectoryListParams = HrisDirectoryListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -101,14 +114,12 @@ interface DirectoryServiceAsync { * [DirectoryServiceAsync.listIndividuals]. */ @Deprecated("use `list` instead") - @MustBeClosed fun listIndividuals(): CompletableFuture> = listIndividuals(HrisDirectoryListIndividualsParams.none()) /** @see [listIndividuals] */ @Deprecated("use `list` instead") - @MustBeClosed fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), @@ -116,7 +127,6 @@ interface DirectoryServiceAsync { /** @see [listIndividuals] */ @Deprecated("use `list` instead") - @MustBeClosed fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none() ): CompletableFuture> = @@ -124,7 +134,6 @@ interface DirectoryServiceAsync { /** @see [listIndividuals] */ @Deprecated("use `list` instead") - @MustBeClosed fun listIndividuals( requestOptions: RequestOptions ): CompletableFuture> = 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 737aeac0..dccddb59 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 @@ -21,6 +21,7 @@ import com.tryfinch.api.models.HrisDirectoryListPageAsync import com.tryfinch.api.models.HrisDirectoryListPageResponse import com.tryfinch.api.models.HrisDirectoryListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DirectoryServiceAsync { @@ -31,6 +32,9 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): DirectoryServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DirectoryServiceAsync = + DirectoryServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisDirectoryListParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DirectoryServiceAsync.WithRawResponse = + DirectoryServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -62,6 +73,7 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "directory") .build() .prepareAsync(clientOptions, params) @@ -101,6 +113,7 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "directory") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt index 5688823e..22ffb8a9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DocumentListResponse @@ -10,6 +10,7 @@ import com.tryfinch.api.models.DocumentRetreiveResponse import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface DocumentServiceAsync { @@ -18,6 +19,13 @@ interface DocumentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DocumentServiceAsync + /** * **Beta:** This endpoint is in beta and may change. Retrieve a list of company-wide documents. */ @@ -82,30 +90,35 @@ interface DocumentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DocumentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/documents`, but is otherwise the same as * [DocumentServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisDocumentListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisDocumentListParams = HrisDocumentListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisDocumentListParams = HrisDocumentListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -115,14 +128,12 @@ interface DocumentServiceAsync { * Returns a raw HTTP response for `get /employer/documents/{document_id}`, but is otherwise * the same as [DocumentServiceAsync.retreive]. */ - @MustBeClosed fun retreive( documentId: String ): CompletableFuture> = retreive(documentId, HrisDocumentRetreiveParams.none()) /** @see [retreive] */ - @MustBeClosed fun retreive( documentId: String, params: HrisDocumentRetreiveParams = HrisDocumentRetreiveParams.none(), @@ -131,7 +142,6 @@ interface DocumentServiceAsync { retreive(params.toBuilder().documentId(documentId).build(), requestOptions) /** @see [retreive] */ - @MustBeClosed fun retreive( documentId: String, params: HrisDocumentRetreiveParams = HrisDocumentRetreiveParams.none(), @@ -139,21 +149,18 @@ interface DocumentServiceAsync { retreive(documentId, params, RequestOptions.none()) /** @see [retreive] */ - @MustBeClosed fun retreive( params: HrisDocumentRetreiveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retreive] */ - @MustBeClosed fun retreive( params: HrisDocumentRetreiveParams ): CompletableFuture> = retreive(params, RequestOptions.none()) /** @see [retreive] */ - @MustBeClosed fun retreive( documentId: String, requestOptions: RequestOptions, 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 cd75084e..24c48edb 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 @@ -20,6 +20,7 @@ import com.tryfinch.api.models.DocumentRetreiveResponse import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class DocumentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,6 +32,9 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): DocumentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DocumentServiceAsync = + DocumentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisDocumentListParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DocumentServiceAsync.WithRawResponse = + DocumentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -61,6 +72,7 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "documents") .build() .prepareAsync(clientOptions, params) @@ -94,6 +106,7 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "documents", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt index 9b0987cd..6ad32bab 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageAsync import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EmploymentServiceAsync { @@ -16,6 +17,13 @@ interface EmploymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmploymentServiceAsync + /** Read individual employment and income data */ fun retrieveMany( params: HrisEmploymentRetrieveManyParams @@ -34,18 +42,25 @@ interface EmploymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmploymentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/employment`, but is otherwise the same as * [EmploymentServiceAsync.retrieveMany]. */ - @MustBeClosed fun retrieveMany( params: HrisEmploymentRetrieveManyParams ): CompletableFuture> = retrieveMany(params, RequestOptions.none()) /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( params: HrisEmploymentRetrieveManyParams, requestOptions: RequestOptions = RequestOptions.none(), 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 a9c72d89..22d9baa8 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageAsync import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageResponse import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EmploymentServiceAsync { @@ -29,6 +30,9 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): EmploymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmploymentServiceAsync = + EmploymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisEmploymentRetrieveManyParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmploymentServiceAsync.WithRawResponse = + EmploymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -52,6 +63,7 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "employment") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt index e51cd00b..e05abbc3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisIndividualRetrieveManyPageAsync import com.tryfinch.api.models.HrisIndividualRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface IndividualServiceAsync { @@ -16,6 +17,13 @@ interface IndividualServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualServiceAsync + /** Read individual data, excluding income and employment data */ fun retrieveMany(): CompletableFuture = retrieveMany(HrisIndividualRetrieveManyParams.none()) @@ -44,31 +52,36 @@ interface IndividualServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/individual`, but is otherwise the same as * [IndividualServiceAsync.retrieveMany]. */ - @MustBeClosed fun retrieveMany(): CompletableFuture> = retrieveMany(HrisIndividualRetrieveManyParams.none()) /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( params: HrisIndividualRetrieveManyParams = HrisIndividualRetrieveManyParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( params: HrisIndividualRetrieveManyParams = HrisIndividualRetrieveManyParams.none() ): CompletableFuture> = retrieveMany(params, RequestOptions.none()) /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( requestOptions: RequestOptions ): CompletableFuture> = 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 26a7925a..1d4cc4fd 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisIndividualRetrieveManyPageAsync import com.tryfinch.api.models.HrisIndividualRetrieveManyPageResponse import com.tryfinch.api.models.HrisIndividualRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : IndividualServiceAsync { @@ -29,6 +30,9 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): IndividualServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualServiceAsync = + IndividualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisIndividualRetrieveManyParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse = + IndividualServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -52,6 +63,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "individual") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt index 79077b3a..586f6283 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageAsync import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PayStatementServiceAsync { @@ -16,6 +17,13 @@ interface PayStatementServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayStatementServiceAsync + /** * Read detailed pay statements for each individual. * @@ -38,18 +46,25 @@ interface PayStatementServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayStatementServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/pay-statement`, but is otherwise the same * as [PayStatementServiceAsync.retrieveMany]. */ - @MustBeClosed fun retrieveMany( params: HrisPayStatementRetrieveManyParams ): CompletableFuture> = retrieveMany(params, RequestOptions.none()) /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( params: HrisPayStatementRetrieveManyParams, requestOptions: RequestOptions = RequestOptions.none(), 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 6a682d8f..bee508d7 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageAsync import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageResponse import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class PayStatementServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PayStatementServiceAsync { @@ -29,6 +30,9 @@ class PayStatementServiceAsyncImpl internal constructor(private val clientOption override fun withRawResponse(): PayStatementServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayStatementServiceAsync = + PayStatementServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisPayStatementRetrieveManyParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class PayStatementServiceAsyncImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PayStatementServiceAsync.WithRawResponse = + PayStatementServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -52,6 +63,7 @@ class PayStatementServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt index f0d25be6..fb6012e9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPaymentListPageAsync import com.tryfinch.api.models.HrisPaymentListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PaymentServiceAsync { @@ -16,6 +17,13 @@ interface PaymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentServiceAsync + /** Read payroll and contractor related payments by the company. */ fun list(params: HrisPaymentListParams): CompletableFuture = list(params, RequestOptions.none()) @@ -31,18 +39,25 @@ interface PaymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PaymentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/payment`, but is otherwise the same as * [PaymentServiceAsync.list]. */ - @MustBeClosed fun list( params: HrisPaymentListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisPaymentListParams, requestOptions: RequestOptions = RequestOptions.none(), 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 c8b13fea..afd34eef 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.models.HrisPaymentListPageAsync import com.tryfinch.api.models.HrisPaymentListParams import com.tryfinch.api.models.Payment import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class PaymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PaymentServiceAsync { @@ -28,6 +29,9 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): PaymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PaymentServiceAsync = + PaymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisPaymentListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PaymentServiceAsync.WithRawResponse = + PaymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "payment") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt index 12b6ea0f..691053a3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.hris.benefits -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams @@ -12,6 +12,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface IndividualServiceAsync { @@ -20,6 +21,13 @@ interface IndividualServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualServiceAsync + /** Lists individuals currently enrolled in a given deduction. */ fun enrolledIds(benefitId: String): CompletableFuture = enrolledIds(benefitId, HrisBenefitIndividualEnrolledIdsParams.none()) @@ -151,18 +159,25 @@ interface IndividualServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/enrolled`, but is * otherwise the same as [IndividualServiceAsync.enrolledIds]. */ - @MustBeClosed fun enrolledIds( benefitId: String ): CompletableFuture> = enrolledIds(benefitId, HrisBenefitIndividualEnrolledIdsParams.none()) /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( benefitId: String, params: HrisBenefitIndividualEnrolledIdsParams = @@ -172,7 +187,6 @@ interface IndividualServiceAsync { enrolledIds(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( benefitId: String, params: HrisBenefitIndividualEnrolledIdsParams = @@ -181,21 +195,18 @@ interface IndividualServiceAsync { enrolledIds(benefitId, params, RequestOptions.none()) /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams ): CompletableFuture> = enrolledIds(params, RequestOptions.none()) /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( benefitId: String, requestOptions: RequestOptions, @@ -206,14 +217,12 @@ interface IndividualServiceAsync { * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/individuals`, but is * otherwise the same as [IndividualServiceAsync.retrieveManyBenefits]. */ - @MustBeClosed fun retrieveManyBenefits( benefitId: String ): CompletableFuture> = retrieveManyBenefits(benefitId, HrisBenefitIndividualRetrieveManyBenefitsParams.none()) /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( benefitId: String, params: HrisBenefitIndividualRetrieveManyBenefitsParams = @@ -223,7 +232,6 @@ interface IndividualServiceAsync { retrieveManyBenefits(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( benefitId: String, params: HrisBenefitIndividualRetrieveManyBenefitsParams = @@ -232,21 +240,18 @@ interface IndividualServiceAsync { retrieveManyBenefits(benefitId, params, RequestOptions.none()) /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( params: HrisBenefitIndividualRetrieveManyBenefitsParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( params: HrisBenefitIndividualRetrieveManyBenefitsParams ): CompletableFuture> = retrieveManyBenefits(params, RequestOptions.none()) /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( benefitId: String, requestOptions: RequestOptions, @@ -261,14 +266,12 @@ interface IndividualServiceAsync { * Returns a raw HTTP response for `delete /employer/benefits/{benefit_id}/individuals`, but * is otherwise the same as [IndividualServiceAsync.unenrollMany]. */ - @MustBeClosed fun unenrollMany( benefitId: String ): CompletableFuture> = unenrollMany(benefitId, HrisBenefitIndividualUnenrollManyParams.none()) /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( benefitId: String, params: HrisBenefitIndividualUnenrollManyParams = @@ -278,7 +281,6 @@ interface IndividualServiceAsync { unenrollMany(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( benefitId: String, params: HrisBenefitIndividualUnenrollManyParams = @@ -287,21 +289,18 @@ interface IndividualServiceAsync { unenrollMany(benefitId, params, RequestOptions.none()) /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams ): CompletableFuture> = unenrollMany(params, RequestOptions.none()) /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( benefitId: String, requestOptions: RequestOptions, 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 959a36b0..e78ec6a1 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 @@ -24,6 +24,7 @@ import com.tryfinch.api.models.IndividualBenefit import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -35,6 +36,9 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): IndividualServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualServiceAsync = + IndividualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams, requestOptions: RequestOptions, @@ -61,6 +65,13 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse = + IndividualServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val enrolledIdsHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -75,6 +86,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "enrolled") .build() .prepareAsync(clientOptions, params) @@ -108,6 +120,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") .build() .prepareAsync(clientOptions, params) @@ -149,6 +162,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt index a0fdb11b..939e8743 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt @@ -2,13 +2,14 @@ package com.tryfinch.api.services.async.hris.company -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemListPageAsync import com.tryfinch.api.models.HrisCompanyPayStatementItemListParams import com.tryfinch.api.services.async.hris.company.payStatementItem.RuleServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PayStatementItemServiceAsync { @@ -17,6 +18,13 @@ interface PayStatementItemServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayStatementItemServiceAsync + fun rules(): RuleServiceAsync /** @@ -52,18 +60,25 @@ interface PayStatementItemServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayStatementItemServiceAsync.WithRawResponse + fun rules(): RuleServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `get /employer/pay-statement-item`, but is otherwise the * same as [PayStatementItemServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisCompanyPayStatementItemListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisCompanyPayStatementItemListParams = HrisCompanyPayStatementItemListParams.none(), @@ -71,7 +86,6 @@ interface PayStatementItemServiceAsync { ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisCompanyPayStatementItemListParams = HrisCompanyPayStatementItemListParams.none() @@ -79,7 +93,6 @@ interface PayStatementItemServiceAsync { list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsyncImpl.kt index 6c1131c8..6839e175 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.HrisCompanyPayStatementItemListParams import com.tryfinch.api.services.async.hris.company.payStatementItem.RuleServiceAsync import com.tryfinch.api.services.async.hris.company.payStatementItem.RuleServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class PayStatementItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PayStatementItemServiceAsync { @@ -32,6 +33,11 @@ internal constructor(private val clientOptions: ClientOptions) : PayStatementIte override fun withRawResponse(): PayStatementItemServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): PayStatementItemServiceAsync = + PayStatementItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun rules(): RuleServiceAsync = rules override fun list( @@ -50,6 +56,13 @@ internal constructor(private val clientOptions: ClientOptions) : PayStatementIte RuleServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): PayStatementItemServiceAsync.WithRawResponse = + PayStatementItemServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun rules(): RuleServiceAsync.WithRawResponse = rules private val listHandler: Handler = @@ -63,6 +76,7 @@ internal constructor(private val clientOptions: ClientOptions) : PayStatementIte val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt index 613b9577..6fa6af04 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.hris.company.payStatementItem -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleCreateParams @@ -14,6 +14,7 @@ import com.tryfinch.api.models.RuleCreateResponse import com.tryfinch.api.models.RuleDeleteResponse import com.tryfinch.api.models.RuleUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RuleServiceAsync { @@ -22,6 +23,13 @@ interface RuleServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleServiceAsync + /** * **Beta:** this endpoint currently serves employers onboarded after March 4th and historical * support will be added soon Custom rules can be created to associate specific attributes to @@ -161,16 +169,21 @@ interface RuleServiceAsync { /** A view of [RuleServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/pay-statement-item/rule`, but is * otherwise the same as [RuleServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(HrisCompanyPayStatementItemRuleCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: HrisCompanyPayStatementItemRuleCreateParams = HrisCompanyPayStatementItemRuleCreateParams.none(), @@ -178,7 +191,6 @@ interface RuleServiceAsync { ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: HrisCompanyPayStatementItemRuleCreateParams = HrisCompanyPayStatementItemRuleCreateParams.none() @@ -186,7 +198,6 @@ interface RuleServiceAsync { create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -196,12 +207,10 @@ interface RuleServiceAsync { * Returns a raw HTTP response for `put /employer/pay-statement-item/rule/{rule_id}`, but is * otherwise the same as [RuleServiceAsync.update]. */ - @MustBeClosed fun update(ruleId: String): CompletableFuture> = update(ruleId, HrisCompanyPayStatementItemRuleUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( ruleId: String, params: HrisCompanyPayStatementItemRuleUpdateParams = @@ -211,7 +220,6 @@ interface RuleServiceAsync { update(params.toBuilder().ruleId(ruleId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( ruleId: String, params: HrisCompanyPayStatementItemRuleUpdateParams = @@ -220,21 +228,18 @@ interface RuleServiceAsync { update(ruleId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: HrisCompanyPayStatementItemRuleUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: HrisCompanyPayStatementItemRuleUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( ruleId: String, requestOptions: RequestOptions, @@ -245,13 +250,11 @@ interface RuleServiceAsync { * Returns a raw HTTP response for `get /employer/pay-statement-item/rule`, but is otherwise * the same as [RuleServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisCompanyPayStatementItemRuleListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisCompanyPayStatementItemRuleListParams = HrisCompanyPayStatementItemRuleListParams.none(), @@ -259,7 +262,6 @@ interface RuleServiceAsync { ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisCompanyPayStatementItemRuleListParams = HrisCompanyPayStatementItemRuleListParams.none() @@ -267,7 +269,6 @@ interface RuleServiceAsync { list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -277,12 +278,10 @@ interface RuleServiceAsync { * Returns a raw HTTP response for `delete /employer/pay-statement-item/rule/{rule_id}`, but * is otherwise the same as [RuleServiceAsync.delete]. */ - @MustBeClosed fun delete(ruleId: String): CompletableFuture> = delete(ruleId, HrisCompanyPayStatementItemRuleDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( ruleId: String, params: HrisCompanyPayStatementItemRuleDeleteParams = @@ -292,7 +291,6 @@ interface RuleServiceAsync { delete(params.toBuilder().ruleId(ruleId).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( ruleId: String, params: HrisCompanyPayStatementItemRuleDeleteParams = @@ -301,21 +299,18 @@ interface RuleServiceAsync { delete(ruleId, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: HrisCompanyPayStatementItemRuleDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: HrisCompanyPayStatementItemRuleDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( ruleId: String, requestOptions: RequestOptions, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsyncImpl.kt index 71f908a0..376f8892 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsyncImpl.kt @@ -26,6 +26,7 @@ import com.tryfinch.api.models.RuleCreateResponse import com.tryfinch.api.models.RuleDeleteResponse import com.tryfinch.api.models.RuleUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class RuleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): RuleServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RuleServiceAsync = + RuleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: HrisCompanyPayStatementItemRuleCreateParams, requestOptions: RequestOptions, @@ -70,6 +74,13 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RuleServiceAsync.WithRawResponse = + RuleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -80,6 +91,7 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -113,6 +125,7 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -144,6 +157,7 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule") .build() .prepareAsync(clientOptions, params) @@ -184,6 +198,7 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt index 90fc195c..d6854525 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.jobs -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AutomatedAsyncJob @@ -12,6 +12,7 @@ import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AutomatedServiceAsync { @@ -20,6 +21,13 @@ interface AutomatedServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AutomatedServiceAsync + /** * Enqueue an automated job. * @@ -115,30 +123,35 @@ interface AutomatedServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AutomatedServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /jobs/automated`, but is otherwise the same as * [AutomatedServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(JobAutomatedCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: JobAutomatedCreateParams = JobAutomatedCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: JobAutomatedCreateParams = JobAutomatedCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -148,12 +161,10 @@ interface AutomatedServiceAsync { * Returns a raw HTTP response for `get /jobs/automated/{job_id}`, but is otherwise the same * as [AutomatedServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(jobId: String): CompletableFuture> = retrieve(jobId, JobAutomatedRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, params: JobAutomatedRetrieveParams = JobAutomatedRetrieveParams.none(), @@ -162,7 +173,6 @@ interface AutomatedServiceAsync { retrieve(params.toBuilder().jobId(jobId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, params: JobAutomatedRetrieveParams = JobAutomatedRetrieveParams.none(), @@ -170,21 +180,18 @@ interface AutomatedServiceAsync { retrieve(jobId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobAutomatedRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobAutomatedRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, requestOptions: RequestOptions, @@ -195,26 +202,22 @@ interface AutomatedServiceAsync { * Returns a raw HTTP response for `get /jobs/automated`, but is otherwise the same as * [AutomatedServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(JobAutomatedListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: JobAutomatedListParams = JobAutomatedListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: JobAutomatedListParams = JobAutomatedListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = 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 77de2441..da95121d 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 @@ -23,6 +23,7 @@ import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): AutomatedServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AutomatedServiceAsync = + AutomatedServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: JobAutomatedCreateParams, requestOptions: RequestOptions, @@ -60,6 +64,13 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AutomatedServiceAsync.WithRawResponse = + AutomatedServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -71,6 +82,7 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -104,6 +116,7 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -134,6 +147,7 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt index 9d131db4..a7cdb0bf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.jobs -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ManualServiceAsync { @@ -16,6 +17,13 @@ interface ManualServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ManualServiceAsync + /** * Get a manual job by `job_id`. Manual jobs are completed by a human and include Assisted * Benefits jobs. @@ -56,16 +64,23 @@ interface ManualServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ManualServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /jobs/manual/{job_id}`, but is otherwise the same as * [ManualServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(jobId: String): CompletableFuture> = retrieve(jobId, JobManualRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, params: JobManualRetrieveParams = JobManualRetrieveParams.none(), @@ -74,7 +89,6 @@ interface ManualServiceAsync { retrieve(params.toBuilder().jobId(jobId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, params: JobManualRetrieveParams = JobManualRetrieveParams.none(), @@ -82,21 +96,18 @@ interface ManualServiceAsync { retrieve(jobId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobManualRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobManualRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, requestOptions: RequestOptions, 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 f52bfd4e..a7f58b32 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ManualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class ManualServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): ManualServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ManualServiceAsync = + ManualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: JobManualRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class ManualServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ManualServiceAsync.WithRawResponse = + ManualServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -54,6 +65,7 @@ class ManualServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "manual", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt index 303f01d7..02e5f8a8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.payroll -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PayGroupRetrieveResponse @@ -10,6 +10,7 @@ import com.tryfinch.api.models.PayrollPayGroupListPageAsync import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PayGroupServiceAsync { @@ -18,6 +19,13 @@ interface PayGroupServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayGroupServiceAsync + /** Read information from a single pay group */ fun retrieve(payGroupId: String): CompletableFuture = retrieve(payGroupId, PayrollPayGroupRetrieveParams.none()) @@ -79,18 +87,25 @@ interface PayGroupServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayGroupServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/pay-groups/{pay_group_id}`, but is * otherwise the same as [PayGroupServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( payGroupId: String ): CompletableFuture> = retrieve(payGroupId, PayrollPayGroupRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( payGroupId: String, params: PayrollPayGroupRetrieveParams = PayrollPayGroupRetrieveParams.none(), @@ -99,7 +114,6 @@ interface PayGroupServiceAsync { retrieve(params.toBuilder().payGroupId(payGroupId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( payGroupId: String, params: PayrollPayGroupRetrieveParams = PayrollPayGroupRetrieveParams.none(), @@ -107,21 +121,18 @@ interface PayGroupServiceAsync { retrieve(payGroupId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: PayrollPayGroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: PayrollPayGroupRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( payGroupId: String, requestOptions: RequestOptions, @@ -132,26 +143,22 @@ interface PayGroupServiceAsync { * Returns a raw HTTP response for `get /employer/pay-groups`, but is otherwise the same as * [PayGroupServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(PayrollPayGroupListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: PayrollPayGroupListParams = PayrollPayGroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: PayrollPayGroupListParams = PayrollPayGroupListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = 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 2e8dacac..fcbee564 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 @@ -21,6 +21,7 @@ import com.tryfinch.api.models.PayrollPayGroupListPageAsync import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,6 +33,9 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): PayGroupServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayGroupServiceAsync = + PayGroupServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: PayrollPayGroupRetrieveParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PayGroupServiceAsync.WithRawResponse = + PayGroupServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -65,6 +76,7 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-groups", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -95,6 +107,7 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-groups") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt index 5b946b43..5a8a0f05 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CompanyServiceAsync { @@ -16,6 +17,13 @@ interface CompanyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyServiceAsync + /** Update a sandbox company's data */ fun update(params: SandboxCompanyUpdateParams): CompletableFuture = update(params, RequestOptions.none()) @@ -31,18 +39,25 @@ interface CompanyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompanyServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/company`, but is otherwise the same as * [CompanyServiceAsync.update]. */ - @MustBeClosed fun update( params: SandboxCompanyUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxCompanyUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), 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 bb6bd71a..df0d2518 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CompanyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CompanyServiceAsync { @@ -28,6 +29,9 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): CompanyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompanyServiceAsync = + CompanyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxCompanyUpdateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompanyServiceAsync.WithRawResponse = + CompanyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "company") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt index 77f7287e..a56b40d9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt @@ -2,13 +2,14 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectionCreateResponse import com.tryfinch.api.models.SandboxConnectionCreateParams import com.tryfinch.api.services.async.sandbox.connections.AccountServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ConnectionServiceAsync { @@ -17,6 +18,13 @@ interface ConnectionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectionServiceAsync + fun accounts(): AccountServiceAsync /** Create a new connection (new company/provider pair) with a new account */ @@ -35,20 +43,27 @@ interface ConnectionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConnectionServiceAsync.WithRawResponse + fun accounts(): AccountServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /sandbox/connections`, but is otherwise the same as * [ConnectionServiceAsync.create]. */ - @MustBeClosed fun create( params: SandboxConnectionCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxConnectionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), 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 25170227..3faa4d60 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 @@ -20,6 +20,7 @@ import com.tryfinch.api.models.SandboxConnectionCreateParams import com.tryfinch.api.services.async.sandbox.connections.AccountServiceAsync import com.tryfinch.api.services.async.sandbox.connections.AccountServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ConnectionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ConnectionServiceAsync { @@ -32,6 +33,9 @@ class ConnectionServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): ConnectionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConnectionServiceAsync = + ConnectionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun accounts(): AccountServiceAsync = accounts override fun create( @@ -50,6 +54,13 @@ class ConnectionServiceAsyncImpl internal constructor(private val clientOptions: AccountServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConnectionServiceAsync.WithRawResponse = + ConnectionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun accounts(): AccountServiceAsync.WithRawResponse = accounts private val createHandler: Handler = @@ -63,6 +74,7 @@ class ConnectionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt index 66f7b336..9068bce6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DirectoryCreateResponse import com.tryfinch.api.models.SandboxDirectoryCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface DirectoryServiceAsync { @@ -16,6 +17,13 @@ interface DirectoryServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryServiceAsync + /** Add new individuals to a sandbox company */ fun create(): CompletableFuture> = create(SandboxDirectoryCreateParams.none()) @@ -40,30 +48,35 @@ interface DirectoryServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DirectoryServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/directory`, but is otherwise the same as * [DirectoryServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture>> = create(SandboxDirectoryCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxDirectoryCreateParams = SandboxDirectoryCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [create] */ - @MustBeClosed fun create( params: SandboxDirectoryCreateParams = SandboxDirectoryCreateParams.none() ): CompletableFuture>> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture>> = 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 6da02916..678bcd63 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.DirectoryCreateResponse import com.tryfinch.api.models.SandboxDirectoryCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DirectoryServiceAsync { @@ -28,6 +29,9 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): DirectoryServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DirectoryServiceAsync = + DirectoryServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxDirectoryCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DirectoryServiceAsync.WithRawResponse = + DirectoryServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "directory") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt index 1828a047..e025f5a1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EmploymentServiceAsync { @@ -16,6 +17,13 @@ interface EmploymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmploymentServiceAsync + /** Update sandbox employment */ fun update(individualId: String): CompletableFuture = update(individualId, SandboxEmploymentUpdateParams.none()) @@ -58,18 +66,25 @@ interface EmploymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmploymentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/employment/{individual_id}`, but is * otherwise the same as [EmploymentServiceAsync.update]. */ - @MustBeClosed fun update( individualId: String ): CompletableFuture> = update(individualId, SandboxEmploymentUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( individualId: String, params: SandboxEmploymentUpdateParams = SandboxEmploymentUpdateParams.none(), @@ -78,7 +93,6 @@ interface EmploymentServiceAsync { update(params.toBuilder().individualId(individualId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( individualId: String, params: SandboxEmploymentUpdateParams = SandboxEmploymentUpdateParams.none(), @@ -86,21 +100,18 @@ interface EmploymentServiceAsync { update(individualId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxEmploymentUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: SandboxEmploymentUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( individualId: String, requestOptions: RequestOptions, 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 9534d121..f2094734 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): EmploymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmploymentServiceAsync = + EmploymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxEmploymentUpdateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmploymentServiceAsync.WithRawResponse = + EmploymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -56,6 +67,7 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "employment", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt index 74ba9437..f91b34e6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface IndividualServiceAsync { @@ -16,6 +17,13 @@ interface IndividualServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualServiceAsync + /** Update sandbox individual */ fun update(individualId: String): CompletableFuture = update(individualId, SandboxIndividualUpdateParams.none()) @@ -58,18 +66,25 @@ interface IndividualServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/individual/{individual_id}`, but is * otherwise the same as [IndividualServiceAsync.update]. */ - @MustBeClosed fun update( individualId: String ): CompletableFuture> = update(individualId, SandboxIndividualUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( individualId: String, params: SandboxIndividualUpdateParams = SandboxIndividualUpdateParams.none(), @@ -78,7 +93,6 @@ interface IndividualServiceAsync { update(params.toBuilder().individualId(individualId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( individualId: String, params: SandboxIndividualUpdateParams = SandboxIndividualUpdateParams.none(), @@ -86,21 +100,18 @@ interface IndividualServiceAsync { update(individualId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxIndividualUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: SandboxIndividualUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( individualId: String, requestOptions: RequestOptions, 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 fca58ca0..8b3777eb 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): IndividualServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualServiceAsync = + IndividualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxIndividualUpdateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse = + IndividualServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -56,6 +67,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "individual", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt index e5cb1480..30011030 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt @@ -2,13 +2,14 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobCreateResponse import com.tryfinch.api.models.SandboxJobCreateParams import com.tryfinch.api.services.async.sandbox.jobs.ConfigurationServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface JobServiceAsync { @@ -17,6 +18,13 @@ interface JobServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync + fun configuration(): ConfigurationServiceAsync /** Enqueue a new sandbox job */ @@ -32,20 +40,25 @@ interface JobServiceAsync { /** A view of [JobServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync.WithRawResponse + fun configuration(): ConfigurationServiceAsync.WithRawResponse /** * Returns a raw HTTP response for `post /sandbox/jobs`, but is otherwise the same as * [JobServiceAsync.create]. */ - @MustBeClosed fun create( params: SandboxJobCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxJobCreateParams, requestOptions: RequestOptions = RequestOptions.none(), 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 cbb5ae24..701f75e3 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 @@ -20,6 +20,7 @@ import com.tryfinch.api.models.SandboxJobCreateParams import com.tryfinch.api.services.async.sandbox.jobs.ConfigurationServiceAsync import com.tryfinch.api.services.async.sandbox.jobs.ConfigurationServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class JobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : JobServiceAsync { @@ -34,6 +35,9 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): JobServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobServiceAsync = + JobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun configuration(): ConfigurationServiceAsync = configuration override fun create( @@ -52,6 +56,13 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client ConfigurationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobServiceAsync.WithRawResponse = + JobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun configuration(): ConfigurationServiceAsync.WithRawResponse = configuration private val createHandler: Handler = @@ -64,6 +75,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt index 57cf34ff..b1668fdb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt @@ -2,12 +2,13 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PaymentServiceAsync { @@ -16,6 +17,13 @@ interface PaymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentServiceAsync + /** Add a new sandbox payment */ fun create(): CompletableFuture = create(SandboxPaymentCreateParams.none()) @@ -40,30 +48,35 @@ interface PaymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PaymentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/payment`, but is otherwise the same as * [PaymentServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(SandboxPaymentCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxPaymentCreateParams = SandboxPaymentCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: SandboxPaymentCreateParams = SandboxPaymentCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = 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 6f4667da..f18555ce 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class PaymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PaymentServiceAsync { @@ -28,6 +29,9 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): PaymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PaymentServiceAsync = + PaymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxPaymentCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PaymentServiceAsync.WithRawResponse = + PaymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "payment") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt index 600917c9..1afa9577 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.services.async.sandbox.connections -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountCreateResponse @@ -10,6 +10,7 @@ import com.tryfinch.api.models.AccountUpdateResponse import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AccountServiceAsync { @@ -18,6 +19,13 @@ interface AccountServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountServiceAsync + /** Create a new account for an existing connection (company/provider pair) */ fun create( params: SandboxConnectionAccountCreateParams @@ -56,18 +64,25 @@ interface AccountServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/connections/accounts`, but is otherwise * the same as [AccountServiceAsync.create]. */ - @MustBeClosed fun create( params: SandboxConnectionAccountCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxConnectionAccountCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -77,12 +92,10 @@ interface AccountServiceAsync { * Returns a raw HTTP response for `put /sandbox/connections/accounts`, but is otherwise the * same as [AccountServiceAsync.update]. */ - @MustBeClosed fun update(): CompletableFuture> = update(SandboxConnectionAccountUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxConnectionAccountUpdateParams = SandboxConnectionAccountUpdateParams.none(), @@ -90,7 +103,6 @@ interface AccountServiceAsync { ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: SandboxConnectionAccountUpdateParams = SandboxConnectionAccountUpdateParams.none() @@ -98,7 +110,6 @@ interface AccountServiceAsync { update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( requestOptions: RequestOptions ): CompletableFuture> = 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 5f788805..a81cdad1 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 @@ -20,6 +20,7 @@ import com.tryfinch.api.models.AccountUpdateResponse import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AccountServiceAsync { @@ -30,6 +31,9 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): AccountServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccountServiceAsync = + AccountServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxConnectionAccountCreateParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse = + AccountServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -60,6 +71,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -91,6 +103,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt index 683e02e8..bbacb035 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt @@ -2,13 +2,14 @@ package com.tryfinch.api.services.async.sandbox.jobs -import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ConfigurationServiceAsync { @@ -17,6 +18,13 @@ interface ConfigurationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigurationServiceAsync + /** Get configurations for sandbox jobs */ fun retrieve(): CompletableFuture> = retrieve(SandboxJobConfigurationRetrieveParams.none()) @@ -54,16 +62,23 @@ interface ConfigurationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConfigurationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /sandbox/jobs/configuration`, but is otherwise the * same as [ConfigurationServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(): CompletableFuture>> = retrieve(SandboxJobConfigurationRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: SandboxJobConfigurationRetrieveParams = SandboxJobConfigurationRetrieveParams.none(), @@ -71,7 +86,6 @@ interface ConfigurationServiceAsync { ): CompletableFuture>> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: SandboxJobConfigurationRetrieveParams = SandboxJobConfigurationRetrieveParams.none() @@ -79,7 +93,6 @@ interface ConfigurationServiceAsync { retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( requestOptions: RequestOptions ): CompletableFuture>> = @@ -89,14 +102,12 @@ interface ConfigurationServiceAsync { * Returns a raw HTTP response for `put /sandbox/jobs/configuration`, but is otherwise the * same as [ConfigurationServiceAsync.update]. */ - @MustBeClosed fun update( params: SandboxJobConfigurationUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxJobConfigurationUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), 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 4002444e..510717f3 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ConfigurationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ConfigurationServiceAsync { @@ -29,6 +30,9 @@ class ConfigurationServiceAsyncImpl internal constructor(private val clientOptio override fun withRawResponse(): ConfigurationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConfigurationServiceAsync = + ConfigurationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: SandboxJobConfigurationRetrieveParams, requestOptions: RequestOptions, @@ -48,6 +52,13 @@ class ConfigurationServiceAsyncImpl internal constructor(private val clientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ConfigurationServiceAsync.WithRawResponse = + ConfigurationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -59,6 +70,7 @@ class ConfigurationServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs", "configuration") .build() .prepareAsync(clientOptions, params) @@ -89,6 +101,7 @@ class ConfigurationServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs", "configuration") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenService.kt index 0a0b9cf5..c927481f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse +import java.util.function.Consumer interface AccessTokenService { @@ -15,6 +17,13 @@ interface AccessTokenService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccessTokenService + /** Exchange the authorization code for an access token */ fun create(params: AccessTokenCreateParams): CreateAccessTokenResponse = create(params, RequestOptions.none()) @@ -30,6 +39,15 @@ interface AccessTokenService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccessTokenService.WithRawResponse + /** * Returns a raw HTTP response for `post /auth/token`, but is otherwise the same as * [AccessTokenService.create]. 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 40a41b0d..437cc9c3 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchException import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AccessTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): AccessTokenService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccessTokenService = + AccessTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AccessTokenCreateParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccessTokenService.WithRawResponse = + AccessTokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -76,6 +87,7 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("auth", "token") .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(modifiedParams._queryParams()) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt index 9247468f..67064bbd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection +import java.util.function.Consumer interface AccountService { @@ -17,6 +19,13 @@ interface AccountService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountService + /** Disconnect one or more `access_token`s from your application. */ fun disconnect(): DisconnectResponse = disconnect(AccountDisconnectParams.none()) @@ -56,6 +65,13 @@ interface AccountService { /** A view of [AccountService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountService.WithRawResponse + /** * Returns a raw HTTP response for `post /disconnect`, but is otherwise the same as * [AccountService.disconnect]. 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 84261e55..0423e3e8 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection +import java.util.function.Consumer class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : AccountService { @@ -29,6 +30,9 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): AccountService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccountService = + AccountServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun disconnect( params: AccountDisconnectParams, requestOptions: RequestOptions, @@ -48,6 +52,13 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccountService.WithRawResponse = + AccountServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val disconnectHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -58,6 +69,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("disconnect") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -85,6 +97,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("introspect") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectService.kt index 5ac1c0d8..911e7b34 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectService.kt @@ -2,7 +2,9 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.connect.SessionService +import java.util.function.Consumer interface ConnectService { @@ -11,11 +13,25 @@ interface ConnectService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectService + fun sessions(): SessionService /** A view of [ConnectService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectService.WithRawResponse + fun sessions(): SessionService.WithRawResponse } } 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 762f16c3..85c5a244 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 @@ -5,6 +5,7 @@ package com.tryfinch.api.services.blocking import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.connect.SessionService import com.tryfinch.api.services.blocking.connect.SessionServiceImpl +import java.util.function.Consumer class ConnectServiceImpl internal constructor(private val clientOptions: ClientOptions) : ConnectService { @@ -17,6 +18,9 @@ class ConnectServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): ConnectService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConnectService = + ConnectServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun sessions(): SessionService = sessions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class ConnectServiceImpl internal constructor(private val clientOptions: ClientO SessionServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConnectService.WithRawResponse = + ConnectServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun sessions(): SessionService.WithRawResponse = sessions } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisService.kt index eae9dfe1..b8fc7d38 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisService.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.hris.BenefitService import com.tryfinch.api.services.blocking.hris.CompanyService import com.tryfinch.api.services.blocking.hris.DirectoryService @@ -10,6 +11,7 @@ import com.tryfinch.api.services.blocking.hris.EmploymentService import com.tryfinch.api.services.blocking.hris.IndividualService import com.tryfinch.api.services.blocking.hris.PayStatementService import com.tryfinch.api.services.blocking.hris.PaymentService +import java.util.function.Consumer interface HrisService { @@ -18,6 +20,13 @@ interface HrisService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HrisService + fun company(): CompanyService fun directory(): DirectoryService @@ -37,6 +46,13 @@ interface HrisService { /** A view of [HrisService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HrisService.WithRawResponse + fun company(): CompanyService.WithRawResponse fun directory(): DirectoryService.WithRawResponse 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 15fd8b2e..0ace050b 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.services.blocking.hris.PayStatementService import com.tryfinch.api.services.blocking.hris.PayStatementServiceImpl import com.tryfinch.api.services.blocking.hris.PaymentService import com.tryfinch.api.services.blocking.hris.PaymentServiceImpl +import java.util.function.Consumer class HrisServiceImpl internal constructor(private val clientOptions: ClientOptions) : HrisService { @@ -46,6 +47,9 @@ class HrisServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): HrisService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): HrisService = + HrisServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun company(): CompanyService = company override fun directory(): DirectoryService = directory @@ -97,6 +101,13 @@ class HrisServiceImpl internal constructor(private val clientOptions: ClientOpti BenefitServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): HrisService.WithRawResponse = + HrisServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun company(): CompanyService.WithRawResponse = company override fun directory(): DirectoryService.WithRawResponse = directory diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobService.kt index 09461d9d..1f72c6c8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobService.kt @@ -2,8 +2,10 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.jobs.AutomatedService import com.tryfinch.api.services.blocking.jobs.ManualService +import java.util.function.Consumer interface JobService { @@ -12,6 +14,13 @@ interface JobService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService + fun automated(): AutomatedService fun manual(): ManualService @@ -19,6 +28,13 @@ interface JobService { /** A view of [JobService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService.WithRawResponse + fun automated(): AutomatedService.WithRawResponse fun manual(): ManualService.WithRawResponse 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 bd836478..ff34cf39 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 @@ -7,6 +7,7 @@ import com.tryfinch.api.services.blocking.jobs.AutomatedService import com.tryfinch.api.services.blocking.jobs.AutomatedServiceImpl import com.tryfinch.api.services.blocking.jobs.ManualService import com.tryfinch.api.services.blocking.jobs.ManualServiceImpl +import java.util.function.Consumer class JobServiceImpl internal constructor(private val clientOptions: ClientOptions) : JobService { @@ -20,6 +21,9 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): JobService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobService = + JobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun automated(): AutomatedService = automated override fun manual(): ManualService = manual @@ -35,6 +39,13 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio ManualServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobService.WithRawResponse = + JobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun automated(): AutomatedService.WithRawResponse = automated override fun manual(): ManualService.WithRawResponse = manual diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollService.kt index 872b220a..dd191ae0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollService.kt @@ -2,7 +2,9 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.payroll.PayGroupService +import java.util.function.Consumer interface PayrollService { @@ -11,11 +13,25 @@ interface PayrollService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayrollService + fun payGroups(): PayGroupService /** A view of [PayrollService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayrollService.WithRawResponse + fun payGroups(): PayGroupService.WithRawResponse } } 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 f3e89397..dc8e8e9f 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 @@ -5,6 +5,7 @@ package com.tryfinch.api.services.blocking import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.payroll.PayGroupService import com.tryfinch.api.services.blocking.payroll.PayGroupServiceImpl +import java.util.function.Consumer class PayrollServiceImpl internal constructor(private val clientOptions: ClientOptions) : PayrollService { @@ -17,6 +18,9 @@ class PayrollServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): PayrollService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayrollService = + PayrollServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun payGroups(): PayGroupService = payGroups class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class PayrollServiceImpl internal constructor(private val clientOptions: ClientO PayGroupServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): PayrollService.WithRawResponse = + PayrollServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun payGroups(): PayGroupService.WithRawResponse = payGroups } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderService.kt index 92ef210e..a2c68ded 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ProviderListPage import com.tryfinch.api.models.ProviderListParams +import java.util.function.Consumer interface ProviderService { @@ -15,6 +17,13 @@ interface ProviderService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderService + /** Return details on all available payroll and HR systems. */ fun list(): ProviderListPage = list(ProviderListParams.none()) @@ -35,6 +44,13 @@ interface ProviderService { /** A view of [ProviderService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderService.WithRawResponse + /** * Returns a raw HTTP response for `get /providers`, but is otherwise the same as * [ProviderService.list]. 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 0e75130d..dfb4ba66 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.Provider import com.tryfinch.api.models.ProviderListPage import com.tryfinch.api.models.ProviderListParams +import java.util.function.Consumer class ProviderServiceImpl internal constructor(private val clientOptions: ClientOptions) : ProviderService { @@ -27,6 +28,9 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): ProviderService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ProviderService = + ProviderServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: ProviderListParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ProviderService.WithRawResponse = + ProviderServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("providers") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingService.kt index 2d29034b..a180b608 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse +import java.util.function.Consumer interface RequestForwardingService { @@ -15,6 +17,13 @@ interface RequestForwardingService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RequestForwardingService + /** * The Forward API allows you to make direct requests to an employment system. If Finch’s * unified API doesn’t have a data model that cleanly fits your needs, then Forward allows you @@ -35,6 +44,15 @@ interface RequestForwardingService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RequestForwardingService.WithRawResponse + /** * Returns a raw HTTP response for `post /forward`, but is otherwise the same as * [RequestForwardingService.forward]. 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 f68e8ce7..51c3a9c7 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse +import java.util.function.Consumer class RequestForwardingServiceImpl internal constructor(private val clientOptions: ClientOptions) : RequestForwardingService { @@ -27,6 +28,9 @@ class RequestForwardingServiceImpl internal constructor(private val clientOption override fun withRawResponse(): RequestForwardingService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RequestForwardingService = + RequestForwardingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun forward( params: RequestForwardingForwardParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class RequestForwardingServiceImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RequestForwardingService.WithRawResponse = + RequestForwardingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val forwardHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class RequestForwardingServiceImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("forward") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxService.kt index 413e04e5..53ad137c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxService.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.sandbox.CompanyService import com.tryfinch.api.services.blocking.sandbox.ConnectionService import com.tryfinch.api.services.blocking.sandbox.DirectoryService @@ -9,6 +10,7 @@ import com.tryfinch.api.services.blocking.sandbox.EmploymentService import com.tryfinch.api.services.blocking.sandbox.IndividualService import com.tryfinch.api.services.blocking.sandbox.JobService import com.tryfinch.api.services.blocking.sandbox.PaymentService +import java.util.function.Consumer interface SandboxService { @@ -17,6 +19,13 @@ interface SandboxService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SandboxService + fun connections(): ConnectionService fun company(): CompanyService @@ -34,6 +43,13 @@ interface SandboxService { /** A view of [SandboxService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SandboxService.WithRawResponse + fun connections(): ConnectionService.WithRawResponse fun company(): CompanyService.WithRawResponse 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 a52a4ba6..69c45bcc 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.services.blocking.sandbox.JobService import com.tryfinch.api.services.blocking.sandbox.JobServiceImpl import com.tryfinch.api.services.blocking.sandbox.PaymentService import com.tryfinch.api.services.blocking.sandbox.PaymentServiceImpl +import java.util.function.Consumer class SandboxServiceImpl internal constructor(private val clientOptions: ClientOptions) : SandboxService { @@ -41,6 +42,9 @@ class SandboxServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): SandboxService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SandboxService = + SandboxServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun connections(): ConnectionService = connections override fun company(): CompanyService = company @@ -86,6 +90,13 @@ class SandboxServiceImpl internal constructor(private val clientOptions: ClientO JobServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): SandboxService.WithRawResponse = + SandboxServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun connections(): ConnectionService.WithRawResponse = connections override fun company(): CompanyService.WithRawResponse = company diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookService.kt index a4236a2e..98bb6c85 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookService.kt @@ -2,11 +2,20 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.http.Headers import com.tryfinch.api.models.WebhookEvent +import java.util.function.Consumer interface WebhookService { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebhookService + fun unwrap(payload: String, headers: Headers, secret: String?): WebhookEvent fun verifySignature(payload: String, headers: Headers, secret: String?) 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 88069c27..e1e26fdb 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 @@ -12,6 +12,7 @@ import java.security.MessageDigest import java.time.Duration import java.time.Instant import java.util.Base64 +import java.util.function.Consumer import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec import kotlin.jvm.optionals.getOrNull @@ -19,6 +20,9 @@ import kotlin.jvm.optionals.getOrNull class WebhookServiceImpl internal constructor(private val clientOptions: ClientOptions) : WebhookService { + override fun withOptions(modifier: Consumer): WebhookService = + WebhookServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun unwrap(payload: String, headers: Headers, secret: String?): WebhookEvent { verifySignature(payload, headers, secret) return try { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt index ba280313..7ca4c307 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.connect import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse +import java.util.function.Consumer interface SessionService { @@ -17,6 +19,13 @@ interface SessionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SessionService + /** Create a new connect session for an employer */ fun new_(params: ConnectSessionNewParams): SessionNewResponse = new_(params, RequestOptions.none()) @@ -40,6 +49,13 @@ interface SessionService { /** A view of [SessionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SessionService.WithRawResponse + /** * Returns a raw HTTP response for `post /connect/sessions`, but is otherwise the same as * [SessionService.new_]. 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 70986f09..3a470a8c 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse +import java.util.function.Consumer class SessionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SessionService { @@ -29,6 +30,9 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): SessionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SessionService = + SessionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions, @@ -48,6 +52,13 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SessionService.WithRawResponse = + SessionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val newHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -58,6 +69,7 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("connect", "sessions") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -86,6 +98,7 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("connect", "sessions", "reauthenticate") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt index 43c93d72..5cda4c26 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyBenefit @@ -16,6 +17,7 @@ import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.blocking.hris.benefits.IndividualService +import java.util.function.Consumer interface BenefitService { @@ -24,6 +26,13 @@ interface BenefitService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BenefitService + fun individuals(): IndividualService /** @@ -153,6 +162,13 @@ interface BenefitService { /** A view of [BenefitService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BenefitService.WithRawResponse + fun individuals(): IndividualService.WithRawResponse /** 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 3fc43430..407c88c5 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 @@ -16,7 +16,6 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.json import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare -import com.tryfinch.api.models.BenefitListSupportedBenefitsResponse import com.tryfinch.api.models.CompanyBenefit import com.tryfinch.api.models.CreateCompanyBenefitsResponse import com.tryfinch.api.models.HrisBenefitCreateParams @@ -26,10 +25,12 @@ import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsPage import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams +import com.tryfinch.api.models.SupportedBenefit import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.blocking.hris.benefits.IndividualService import com.tryfinch.api.services.blocking.hris.benefits.IndividualServiceImpl import java.util.Optional +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BenefitServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -43,6 +44,9 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): BenefitService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BenefitService = + BenefitServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun individuals(): IndividualService = individuals override fun create( @@ -89,6 +93,13 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO IndividualServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): BenefitService.WithRawResponse = + BenefitServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun individuals(): IndividualService.WithRawResponse = individuals private val createHandler: Handler = @@ -102,6 +113,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -132,6 +144,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -162,6 +175,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -190,6 +204,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits") .build() .prepare(clientOptions, params) @@ -213,11 +228,8 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO } } - private val listSupportedBenefitsHandler: - Handler>> = - jsonHandler>>( - clientOptions.jsonMapper - ) + private val listSupportedBenefitsHandler: Handler>> = + jsonHandler>>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun listSupportedBenefits( @@ -227,6 +239,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", "meta") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyService.kt index 82ff7c15..befdb985 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.Company import com.tryfinch.api.models.HrisCompanyRetrieveParams import com.tryfinch.api.services.blocking.hris.company.PayStatementItemService +import java.util.function.Consumer interface CompanyService { @@ -16,6 +18,13 @@ interface CompanyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyService + fun payStatementItem(): PayStatementItemService /** Read basic company data */ @@ -38,6 +47,13 @@ interface CompanyService { /** A view of [CompanyService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyService.WithRawResponse + fun payStatementItem(): PayStatementItemService.WithRawResponse /** 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 89a1abcf..0e99459f 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.models.Company import com.tryfinch.api.models.HrisCompanyRetrieveParams import com.tryfinch.api.services.blocking.hris.company.PayStatementItemService import com.tryfinch.api.services.blocking.hris.company.PayStatementItemServiceImpl +import java.util.function.Consumer class CompanyServiceImpl internal constructor(private val clientOptions: ClientOptions) : CompanyService { @@ -32,6 +33,9 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): CompanyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompanyService = + CompanyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun payStatementItem(): PayStatementItemService = payStatementItem override fun retrieve( @@ -50,6 +54,13 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO PayStatementItemServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): CompanyService.WithRawResponse = + CompanyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun payStatementItem(): PayStatementItemService.WithRawResponse = payStatementItem private val retrieveHandler: Handler = @@ -62,6 +73,7 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "company") .build() .prepare(clientOptions, params) 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 dc9adbd0..6fb6faf4 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 @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisDirectoryListIndividualsPage import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPage import com.tryfinch.api.models.HrisDirectoryListParams +import java.util.function.Consumer interface DirectoryService { @@ -17,6 +19,13 @@ interface DirectoryService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryService + /** Read company directory and organization structure */ fun list(): HrisDirectoryListPage = list(HrisDirectoryListParams.none()) @@ -61,6 +70,13 @@ interface DirectoryService { /** A view of [DirectoryService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/directory`, but is otherwise the same as * [DirectoryService.list]. 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 b4ecac79..7a66cfad 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 @@ -20,6 +20,7 @@ import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPage import com.tryfinch.api.models.HrisDirectoryListPageResponse import com.tryfinch.api.models.HrisDirectoryListParams +import java.util.function.Consumer class DirectoryServiceImpl internal constructor(private val clientOptions: ClientOptions) : DirectoryService { @@ -30,6 +31,9 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): DirectoryService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DirectoryService = + DirectoryServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisDirectoryListParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DirectoryService.WithRawResponse = + DirectoryServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -61,6 +72,7 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "directory") .build() .prepare(clientOptions, params) @@ -96,6 +108,7 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "directory") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentService.kt index 0fb3dc39..1e34a568 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DocumentListResponse import com.tryfinch.api.models.DocumentRetreiveResponse import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams +import java.util.function.Consumer interface DocumentService { @@ -17,6 +19,13 @@ interface DocumentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DocumentService + /** * **Beta:** This endpoint is in beta and may change. Retrieve a list of company-wide documents. */ @@ -74,6 +83,13 @@ interface DocumentService { /** A view of [DocumentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DocumentService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/documents`, but is otherwise the same as * [DocumentService.list]. 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 2f11fac7..f1e8b7b3 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.DocumentListResponse import com.tryfinch.api.models.DocumentRetreiveResponse import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class DocumentServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): DocumentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DocumentService = + DocumentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisDocumentListParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DocumentService.WithRawResponse = + DocumentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -60,6 +71,7 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "documents") .build() .prepare(clientOptions, params) @@ -90,6 +102,7 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "documents", params._pathParam(0)) .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentService.kt index e2d11244..f3842a5e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisEmploymentRetrieveManyPage import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams +import java.util.function.Consumer interface EmploymentService { @@ -15,6 +17,13 @@ interface EmploymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmploymentService + /** Read individual employment and income data */ fun retrieveMany(params: HrisEmploymentRetrieveManyParams): HrisEmploymentRetrieveManyPage = retrieveMany(params, RequestOptions.none()) @@ -28,6 +37,15 @@ interface EmploymentService { /** A view of [EmploymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmploymentService.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/employment`, but is otherwise the same as * [EmploymentService.retrieveMany]. 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 b3fbd9b9..dcafefc2 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisEmploymentRetrieveManyPage import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageResponse import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams +import java.util.function.Consumer class EmploymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : EmploymentService { @@ -28,6 +29,9 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): EmploymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmploymentService = + EmploymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisEmploymentRetrieveManyParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmploymentService.WithRawResponse = + EmploymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "employment") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualService.kt index fa435bf7..3b38fc15 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisIndividualRetrieveManyPage import com.tryfinch.api.models.HrisIndividualRetrieveManyParams +import java.util.function.Consumer interface IndividualService { @@ -15,6 +17,13 @@ interface IndividualService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualService + /** Read individual data, excluding income and employment data */ fun retrieveMany(): HrisIndividualRetrieveManyPage = retrieveMany(HrisIndividualRetrieveManyParams.none()) @@ -37,6 +46,15 @@ interface IndividualService { /** A view of [IndividualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/individual`, but is otherwise the same as * [IndividualService.retrieveMany]. 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 150aaa04..d6b74967 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisIndividualRetrieveManyPage import com.tryfinch.api.models.HrisIndividualRetrieveManyPageResponse import com.tryfinch.api.models.HrisIndividualRetrieveManyParams +import java.util.function.Consumer class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : IndividualService { @@ -28,6 +29,9 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): IndividualService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualService = + IndividualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisIndividualRetrieveManyParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse = + IndividualServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "individual") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementService.kt index de869d8c..59692114 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPayStatementRetrieveManyPage import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams +import java.util.function.Consumer interface PayStatementService { @@ -15,6 +17,13 @@ interface PayStatementService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayStatementService + /** * Read detailed pay statements for each individual. * @@ -34,6 +43,15 @@ interface PayStatementService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayStatementService.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/pay-statement`, but is otherwise the same * as [PayStatementService.retrieveMany]. 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 6cfadcaf..89acf8ea 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisPayStatementRetrieveManyPage import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageResponse import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams +import java.util.function.Consumer class PayStatementServiceImpl internal constructor(private val clientOptions: ClientOptions) : PayStatementService { @@ -28,6 +29,9 @@ class PayStatementServiceImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): PayStatementService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayStatementService = + PayStatementServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisPayStatementRetrieveManyParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class PayStatementServiceImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PayStatementService.WithRawResponse = + PayStatementServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -51,6 +62,7 @@ class PayStatementServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentService.kt index f62d1061..d72883ab 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPaymentListPage import com.tryfinch.api.models.HrisPaymentListParams +import java.util.function.Consumer interface PaymentService { @@ -15,6 +17,13 @@ interface PaymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentService + /** Read payroll and contractor related payments by the company. */ fun list(params: HrisPaymentListParams): HrisPaymentListPage = list(params, RequestOptions.none()) @@ -28,6 +37,13 @@ interface PaymentService { /** A view of [PaymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/payment`, but is otherwise the same as * [PaymentService.list]. 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 7cb22ea4..67f5b3fc 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisPaymentListPage import com.tryfinch.api.models.HrisPaymentListParams import com.tryfinch.api.models.Payment +import java.util.function.Consumer class PaymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : PaymentService { @@ -27,6 +28,9 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): PaymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PaymentService = + PaymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisPaymentListParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PaymentService.WithRawResponse = + PaymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -49,6 +60,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "payment") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt index 9a306ff3..c62cf835 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.services.blocking.hris.benefits import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams @@ -11,6 +12,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse +import java.util.function.Consumer interface IndividualService { @@ -19,6 +21,13 @@ interface IndividualService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualService + /** Lists individuals currently enrolled in a given deduction. */ fun enrolledIds(benefitId: String): IndividualEnrolledIdsResponse = enrolledIds(benefitId, HrisBenefitIndividualEnrolledIdsParams.none()) @@ -141,6 +150,15 @@ interface IndividualService { /** A view of [IndividualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/enrolled`, but is * otherwise the same as [IndividualService.enrolledIds]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt index 9fc38484..92551aa3 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 @@ -23,6 +23,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualBenefit import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): IndividualService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualService = + IndividualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams, requestOptions: RequestOptions, @@ -60,6 +64,13 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse = + IndividualServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val enrolledIdsHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -74,6 +85,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "enrolled") .build() .prepare(clientOptions, params) @@ -104,6 +116,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") .build() .prepare(clientOptions, params) @@ -141,6 +154,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemService.kt index c498a733..9b75490b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.hris.company import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemListPage import com.tryfinch.api.models.HrisCompanyPayStatementItemListParams import com.tryfinch.api.services.blocking.hris.company.payStatementItem.RuleService +import java.util.function.Consumer interface PayStatementItemService { @@ -16,6 +18,13 @@ interface PayStatementItemService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayStatementItemService + fun rules(): RuleService /** @@ -48,6 +57,15 @@ interface PayStatementItemService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayStatementItemService.WithRawResponse + fun rules(): RuleService.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt index 87dd1814..63335ea0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisCompanyPayStatementItemListPageResponse import com.tryfinch.api.models.HrisCompanyPayStatementItemListParams import com.tryfinch.api.services.blocking.hris.company.payStatementItem.RuleService import com.tryfinch.api.services.blocking.hris.company.payStatementItem.RuleServiceImpl +import java.util.function.Consumer class PayStatementItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : PayStatementItemService { @@ -31,6 +32,9 @@ class PayStatementItemServiceImpl internal constructor(private val clientOptions override fun withRawResponse(): PayStatementItemService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayStatementItemService = + PayStatementItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun rules(): RuleService = rules override fun list( @@ -49,6 +53,13 @@ class PayStatementItemServiceImpl internal constructor(private val clientOptions RuleServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): PayStatementItemService.WithRawResponse = + PayStatementItemServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun rules(): RuleService.WithRawResponse = rules private val listHandler: Handler = @@ -62,6 +73,7 @@ class PayStatementItemServiceImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleService.kt index 288e3791..9014d674 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleService.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.services.blocking.hris.company.payStatementItem import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleCreateParams @@ -13,6 +14,7 @@ import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleUpdateParams import com.tryfinch.api.models.RuleCreateResponse import com.tryfinch.api.models.RuleDeleteResponse import com.tryfinch.api.models.RuleUpdateResponse +import java.util.function.Consumer interface RuleService { @@ -21,6 +23,13 @@ interface RuleService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleService + /** * **Beta:** this endpoint currently serves employers onboarded after March 4th and historical * support will be added soon Custom rules can be created to associate specific attributes to @@ -146,6 +155,13 @@ interface RuleService { /** A view of [RuleService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleService.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/pay-statement-item/rule`, but is * otherwise the same as [RuleService.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt index c829f537..94afdfa8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt @@ -25,6 +25,7 @@ import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleUpdateParams import com.tryfinch.api.models.RuleCreateResponse import com.tryfinch.api.models.RuleDeleteResponse import com.tryfinch.api.models.RuleUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class RuleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RuleService { @@ -35,6 +36,9 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): RuleService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RuleService = + RuleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: HrisCompanyPayStatementItemRuleCreateParams, requestOptions: RequestOptions, @@ -68,6 +72,13 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RuleService.WithRawResponse = + RuleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -78,6 +89,7 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -108,6 +120,7 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -136,6 +149,7 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule") .build() .prepare(clientOptions, params) @@ -172,6 +186,7 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt index 4bc55fe3..ff25fa31 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.services.blocking.jobs import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AutomatedAsyncJob @@ -11,6 +12,7 @@ import com.tryfinch.api.models.AutomatedListResponse import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams +import java.util.function.Consumer interface AutomatedService { @@ -19,6 +21,13 @@ interface AutomatedService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AutomatedService + /** * Enqueue an automated job. * @@ -107,6 +116,13 @@ interface AutomatedService { /** A view of [AutomatedService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AutomatedService.WithRawResponse + /** * Returns a raw HTTP response for `post /jobs/automated`, but is otherwise the same as * [AutomatedService.create]. 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 87e961d5..029ae982 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 @@ -22,6 +22,7 @@ import com.tryfinch.api.models.AutomatedListResponse import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AutomatedServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -33,6 +34,9 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): AutomatedService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AutomatedService = + AutomatedServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: JobAutomatedCreateParams, requestOptions: RequestOptions, @@ -59,6 +63,13 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AutomatedService.WithRawResponse = + AutomatedServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -70,6 +81,7 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -100,6 +112,7 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -127,6 +140,7 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualService.kt index 4e0334df..4b375204 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.jobs import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob +import java.util.function.Consumer interface ManualService { @@ -15,6 +17,13 @@ interface ManualService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ManualService + /** * Get a manual job by `job_id`. Manual jobs are completed by a human and include Assisted * Benefits jobs. @@ -51,6 +60,13 @@ interface ManualService { /** A view of [ManualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ManualService.WithRawResponse + /** * Returns a raw HTTP response for `get /jobs/manual/{job_id}`, but is otherwise the same as * [ManualService.retrieve]. 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 373dabf5..ec73e616 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ManualServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +29,9 @@ class ManualServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): ManualService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ManualService = + ManualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: JobManualRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ManualServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ManualService.WithRawResponse = + ManualServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) @@ -53,6 +64,7 @@ class ManualServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "manual", params._pathParam(0)) .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupService.kt index 05717f0b..cef03233 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.payroll import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PayGroupRetrieveResponse import com.tryfinch.api.models.PayrollPayGroupListPage import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams +import java.util.function.Consumer interface PayGroupService { @@ -17,6 +19,13 @@ interface PayGroupService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayGroupService + /** Read information from a single pay group */ fun retrieve(payGroupId: String): PayGroupRetrieveResponse = retrieve(payGroupId, PayrollPayGroupRetrieveParams.none()) @@ -70,6 +79,13 @@ interface PayGroupService { /** A view of [PayGroupService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayGroupService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/pay-groups/{pay_group_id}`, but is * otherwise the same as [PayGroupService.retrieve]. 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 fffb28b5..4a0b8e4e 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 @@ -20,6 +20,7 @@ import com.tryfinch.api.models.PayGroupRetrieveResponse import com.tryfinch.api.models.PayrollPayGroupListPage import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PayGroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,6 +32,9 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): PayGroupService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayGroupService = + PayGroupServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: PayrollPayGroupRetrieveParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PayGroupService.WithRawResponse = + PayGroupServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -64,6 +75,7 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-groups", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -91,6 +103,7 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-groups") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyService.kt index c2f4eaf2..e01715b6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams +import java.util.function.Consumer interface CompanyService { @@ -15,6 +17,13 @@ interface CompanyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyService + /** Update a sandbox company's data */ fun update(params: SandboxCompanyUpdateParams): CompanyUpdateResponse = update(params, RequestOptions.none()) @@ -28,6 +37,13 @@ interface CompanyService { /** A view of [CompanyService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyService.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/company`, but is otherwise the same as * [CompanyService.update]. 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 6289d961..afc15beb 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams +import java.util.function.Consumer class CompanyServiceImpl internal constructor(private val clientOptions: ClientOptions) : CompanyService { @@ -27,6 +28,9 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): CompanyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompanyService = + CompanyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxCompanyUpdateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompanyService.WithRawResponse = + CompanyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "company") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionService.kt index 7d3ce2c5..1cf89b9f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectionCreateResponse import com.tryfinch.api.models.SandboxConnectionCreateParams import com.tryfinch.api.services.blocking.sandbox.connections.AccountService +import java.util.function.Consumer interface ConnectionService { @@ -16,6 +18,13 @@ interface ConnectionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectionService + fun accounts(): AccountService /** Create a new connection (new company/provider pair) with a new account */ @@ -31,6 +40,15 @@ interface ConnectionService { /** A view of [ConnectionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConnectionService.WithRawResponse + fun accounts(): AccountService.WithRawResponse /** 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 18e96822..d7dcd7d9 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.ConnectionCreateResponse import com.tryfinch.api.models.SandboxConnectionCreateParams import com.tryfinch.api.services.blocking.sandbox.connections.AccountService import com.tryfinch.api.services.blocking.sandbox.connections.AccountServiceImpl +import java.util.function.Consumer class ConnectionServiceImpl internal constructor(private val clientOptions: ClientOptions) : ConnectionService { @@ -31,6 +32,9 @@ class ConnectionServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ConnectionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConnectionService = + ConnectionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun accounts(): AccountService = accounts override fun create( @@ -49,6 +53,13 @@ class ConnectionServiceImpl internal constructor(private val clientOptions: Clie AccountServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConnectionService.WithRawResponse = + ConnectionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun accounts(): AccountService.WithRawResponse = accounts private val createHandler: Handler = @@ -62,6 +73,7 @@ class ConnectionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryService.kt index afe8fbc5..aafbb8b7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DirectoryCreateResponse import com.tryfinch.api.models.SandboxDirectoryCreateParams +import java.util.function.Consumer interface DirectoryService { @@ -15,6 +17,13 @@ interface DirectoryService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryService + /** Add new individuals to a sandbox company */ fun create(): List = create(SandboxDirectoryCreateParams.none()) @@ -36,6 +45,13 @@ interface DirectoryService { /** A view of [DirectoryService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryService.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/directory`, but is otherwise the same as * [DirectoryService.create]. 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 41ad5a2f..97ea4078 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.DirectoryCreateResponse import com.tryfinch.api.models.SandboxDirectoryCreateParams +import java.util.function.Consumer class DirectoryServiceImpl internal constructor(private val clientOptions: ClientOptions) : DirectoryService { @@ -27,6 +28,9 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): DirectoryService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DirectoryService = + DirectoryServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxDirectoryCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DirectoryService.WithRawResponse = + DirectoryServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "directory") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentService.kt index 8c83ae62..b33e45c7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams +import java.util.function.Consumer interface EmploymentService { @@ -15,6 +17,13 @@ interface EmploymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmploymentService + /** Update sandbox employment */ fun update(individualId: String): EmploymentUpdateResponse = update(individualId, SandboxEmploymentUpdateParams.none()) @@ -50,6 +59,15 @@ interface EmploymentService { /** A view of [EmploymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmploymentService.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/employment/{individual_id}`, but is * otherwise the same as [EmploymentService.update]. 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 e956fc67..9ff66a89 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EmploymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): EmploymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmploymentService = + EmploymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxEmploymentUpdateParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmploymentService.WithRawResponse = + EmploymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "employment", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualService.kt index e8c5faef..50633080 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams +import java.util.function.Consumer interface IndividualService { @@ -15,6 +17,13 @@ interface IndividualService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualService + /** Update sandbox individual */ fun update(individualId: String): IndividualUpdateResponse = update(individualId, SandboxIndividualUpdateParams.none()) @@ -50,6 +59,15 @@ interface IndividualService { /** A view of [IndividualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/individual/{individual_id}`, but is * otherwise the same as [IndividualService.update]. 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 df8ba4b5..530c11bc 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): IndividualService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualService = + IndividualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxIndividualUpdateParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse = + IndividualServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -55,6 +66,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "individual", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobService.kt index cbff8247..76af0515 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobCreateResponse import com.tryfinch.api.models.SandboxJobCreateParams import com.tryfinch.api.services.blocking.sandbox.jobs.ConfigurationService +import java.util.function.Consumer interface JobService { @@ -16,6 +18,13 @@ interface JobService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService + fun configuration(): ConfigurationService /** Enqueue a new sandbox job */ @@ -31,6 +40,13 @@ interface JobService { /** A view of [JobService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService.WithRawResponse + fun configuration(): ConfigurationService.WithRawResponse /** 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 5a01752f..66377981 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.JobCreateResponse import com.tryfinch.api.models.SandboxJobCreateParams import com.tryfinch.api.services.blocking.sandbox.jobs.ConfigurationService import com.tryfinch.api.services.blocking.sandbox.jobs.ConfigurationServiceImpl +import java.util.function.Consumer class JobServiceImpl internal constructor(private val clientOptions: ClientOptions) : JobService { @@ -32,6 +33,9 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): JobService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobService = + JobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun configuration(): ConfigurationService = configuration override fun create( @@ -50,6 +54,13 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio ConfigurationServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobService.WithRawResponse = + JobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun configuration(): ConfigurationService.WithRawResponse = configuration private val createHandler: Handler = @@ -62,6 +73,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentService.kt index 5f78f493..8c4d831c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams +import java.util.function.Consumer interface PaymentService { @@ -15,6 +17,13 @@ interface PaymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentService + /** Add a new sandbox payment */ fun create(): PaymentCreateResponse = create(SandboxPaymentCreateParams.none()) @@ -36,6 +45,13 @@ interface PaymentService { /** A view of [PaymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentService.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/payment`, but is otherwise the same as * [PaymentService.create]. 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 efcd8f16..7c11b1e3 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 @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams +import java.util.function.Consumer class PaymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : PaymentService { @@ -27,6 +28,9 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): PaymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PaymentService = + PaymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxPaymentCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PaymentService.WithRawResponse = + PaymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -50,6 +61,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "payment") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountService.kt index 205880de..57e81402 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.sandbox.connections import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountCreateResponse import com.tryfinch.api.models.AccountUpdateResponse import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams +import java.util.function.Consumer interface AccountService { @@ -17,6 +19,13 @@ interface AccountService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountService + /** Create a new account for an existing connection (company/provider pair) */ fun create(params: SandboxConnectionAccountCreateParams): AccountCreateResponse = create(params, RequestOptions.none()) @@ -51,6 +60,13 @@ interface AccountService { /** A view of [AccountService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountService.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/connections/accounts`, but is otherwise * the same as [AccountService.create]. 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 12f7aeb6..da103eb5 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 @@ -19,6 +19,7 @@ import com.tryfinch.api.models.AccountCreateResponse import com.tryfinch.api.models.AccountUpdateResponse import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams +import java.util.function.Consumer class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : AccountService { @@ -29,6 +30,9 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): AccountService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccountService = + AccountServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxConnectionAccountCreateParams, requestOptions: RequestOptions, @@ -48,6 +52,13 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccountService.WithRawResponse = + AccountServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -59,6 +70,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -87,6 +99,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt index d9fa6264..527c841e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.sandbox.jobs import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams +import java.util.function.Consumer interface ConfigurationService { @@ -16,6 +18,13 @@ interface ConfigurationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigurationService + /** Get configurations for sandbox jobs */ fun retrieve(): List = retrieve(SandboxJobConfigurationRetrieveParams.none()) @@ -51,6 +60,15 @@ interface ConfigurationService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConfigurationService.WithRawResponse + /** * Returns a raw HTTP response for `get /sandbox/jobs/configuration`, but is otherwise the * same as [ConfigurationService.retrieve]. 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 ce53138b..faf95a70 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams +import java.util.function.Consumer class ConfigurationServiceImpl internal constructor(private val clientOptions: ClientOptions) : ConfigurationService { @@ -28,6 +29,9 @@ class ConfigurationServiceImpl internal constructor(private val clientOptions: C override fun withRawResponse(): ConfigurationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConfigurationService = + ConfigurationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: SandboxJobConfigurationRetrieveParams, requestOptions: RequestOptions, @@ -47,6 +51,13 @@ class ConfigurationServiceImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ConfigurationService.WithRawResponse = + ConfigurationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @@ -58,6 +69,7 @@ class ConfigurationServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs", "configuration") .build() .prepare(clientOptions, params) @@ -85,6 +97,7 @@ class ConfigurationServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs", "configuration") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt index eddacf85..6b784fa0 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt @@ -10,8 +10,10 @@ import com.tryfinch.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") class FinchClientAsyncTest { private lateinit var client: FinchClientAsync diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt index 9ae63cc9..67118106 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt @@ -10,8 +10,10 @@ import com.tryfinch.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") class FinchClientTest { private lateinit var client: FinchClient diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt new file mode 100644 index 00000000..679c514c --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt @@ -0,0 +1,34 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.core + +import com.tryfinch.api.core.http.HttpClient +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + private val httpClient = mock() + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + var clientOptions = + ClientOptions.builder().httpClient(httpClient).accessToken("My Access Token").build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} 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 b20e1b90..fd0f5b5f 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 @@ -20,11 +20,13 @@ import org.junit.jupiter.params.provider.ValueSource internal class RetryingHttpClientTest { private var openResponseCount = 0 + private lateinit var baseUrl: String private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() httpClient = object : HttpClient { @@ -75,7 +77,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -97,7 +103,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -139,7 +149,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -187,6 +201,7 @@ internal class RetryingHttpClientTest { retryingClient.execute( HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(baseUrl) .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), @@ -223,7 +238,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateEventTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateEventTest.kt index 6f34f4e4..a4782b0f 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateEventTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateEventTest.kt @@ -25,28 +25,20 @@ internal class AccountUpdateEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -76,28 +68,20 @@ internal class AccountUpdateEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -127,28 +111,20 @@ internal class AccountUpdateEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -178,28 +154,20 @@ internal class AccountUpdateEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -229,28 +197,20 @@ internal class AccountUpdateEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -280,28 +240,20 @@ internal class AccountUpdateEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -331,28 +283,20 @@ internal class AccountUpdateEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -382,28 +326,20 @@ internal class AccountUpdateEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -433,28 +369,20 @@ internal class AccountUpdateEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -484,28 +412,20 @@ internal class AccountUpdateEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -535,28 +455,20 @@ internal class AccountUpdateEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -586,28 +498,20 @@ internal class AccountUpdateEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1024,25 +928,19 @@ internal class AccountUpdateEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1072,25 +970,19 @@ internal class AccountUpdateEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1120,25 +1012,19 @@ internal class AccountUpdateEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1168,25 +1054,19 @@ internal class AccountUpdateEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1216,25 +1096,19 @@ internal class AccountUpdateEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1264,25 +1138,19 @@ internal class AccountUpdateEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1312,25 +1180,19 @@ internal class AccountUpdateEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1360,25 +1222,19 @@ internal class AccountUpdateEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1408,25 +1264,19 @@ internal class AccountUpdateEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1456,25 +1306,19 @@ internal class AccountUpdateEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1504,25 +1348,19 @@ internal class AccountUpdateEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1552,25 +1390,19 @@ internal class AccountUpdateEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1979,28 +1811,20 @@ internal class AccountUpdateEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2030,28 +1854,20 @@ internal class AccountUpdateEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2081,28 +1897,20 @@ internal class AccountUpdateEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2132,28 +1940,20 @@ internal class AccountUpdateEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2183,28 +1983,20 @@ internal class AccountUpdateEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2234,28 +2026,20 @@ internal class AccountUpdateEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2285,28 +2069,20 @@ internal class AccountUpdateEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2336,28 +2112,20 @@ internal class AccountUpdateEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2387,28 +2155,20 @@ internal class AccountUpdateEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2438,28 +2198,20 @@ internal class AccountUpdateEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2489,28 +2241,20 @@ internal class AccountUpdateEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2540,28 +2284,20 @@ internal class AccountUpdateEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() 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 8849aba2..9de222bf 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 @@ -14,21 +14,14 @@ internal class BenefitFeaturesAndOperationsTest { val benefitFeaturesAndOperations = BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) .build() ) .supportedOperations( @@ -55,20 +48,14 @@ internal class BenefitFeaturesAndOperationsTest { assertThat(benefitFeaturesAndOperations.supportedFeatures()) .contains( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit.INDIVIDUAL - ) + .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) .build() ) assertThat(benefitFeaturesAndOperations.supportedOperations()) @@ -100,21 +87,14 @@ internal class BenefitFeaturesAndOperationsTest { val benefitFeaturesAndOperations = BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) .build() ) .supportedOperations( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt deleted file mode 100644 index ae8dc665..00000000 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.tryfinch.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BenefitListSupportedBenefitsResponseTest { - - @Test - fun create() { - val benefitListSupportedBenefitsResponse = - BenefitListSupportedBenefitsResponse.builder() - .annualMaximum(true) - .catchUp(true) - .addCompanyContribution( - BenefitListSupportedBenefitsResponse.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction(BenefitListSupportedBenefitsResponse.EmployeeDeduction.FIXED) - .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitListSupportedBenefitsResponse.HsaContributionLimit.INDIVIDUAL - ) - .build() - - assertThat(benefitListSupportedBenefitsResponse.annualMaximum()).contains(true) - assertThat(benefitListSupportedBenefitsResponse.catchUp()).contains(true) - assertThat(benefitListSupportedBenefitsResponse.companyContribution().getOrNull()) - .containsExactly(BenefitListSupportedBenefitsResponse.CompanyContribution.FIXED) - assertThat(benefitListSupportedBenefitsResponse.description()).contains("description") - assertThat(benefitListSupportedBenefitsResponse.employeeDeduction().getOrNull()) - .containsExactly(BenefitListSupportedBenefitsResponse.EmployeeDeduction.FIXED) - assertThat(benefitListSupportedBenefitsResponse.frequencies().getOrNull()) - .containsExactly(BenefitFrequency.ONE_TIME) - assertThat(benefitListSupportedBenefitsResponse.hsaContributionLimit().getOrNull()) - .containsExactly(BenefitListSupportedBenefitsResponse.HsaContributionLimit.INDIVIDUAL) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val benefitListSupportedBenefitsResponse = - BenefitListSupportedBenefitsResponse.builder() - .annualMaximum(true) - .catchUp(true) - .addCompanyContribution( - BenefitListSupportedBenefitsResponse.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction(BenefitListSupportedBenefitsResponse.EmployeeDeduction.FIXED) - .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitListSupportedBenefitsResponse.HsaContributionLimit.INDIVIDUAL - ) - .build() - - val roundtrippedBenefitListSupportedBenefitsResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(benefitListSupportedBenefitsResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBenefitListSupportedBenefitsResponse) - .isEqualTo(benefitListSupportedBenefitsResponse) - } -} 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 6490d096..9eb14c5c 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 @@ -16,22 +16,15 @@ internal class BenefitsSupportTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -60,22 +53,15 @@ internal class BenefitsSupportTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -104,22 +90,15 @@ internal class BenefitsSupportTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -148,22 +127,15 @@ internal class BenefitsSupportTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -192,22 +164,15 @@ internal class BenefitsSupportTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -236,22 +201,15 @@ internal class BenefitsSupportTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -280,22 +238,15 @@ internal class BenefitsSupportTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -324,22 +275,15 @@ internal class BenefitsSupportTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -368,22 +312,15 @@ internal class BenefitsSupportTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -412,22 +349,15 @@ internal class BenefitsSupportTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -456,22 +386,15 @@ internal class BenefitsSupportTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -500,22 +423,15 @@ internal class BenefitsSupportTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -547,21 +463,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -591,21 +501,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -635,21 +539,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -679,21 +577,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -723,21 +615,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -767,21 +653,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -811,21 +691,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -855,21 +729,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -899,21 +767,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -943,21 +805,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -987,21 +843,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1031,21 +881,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1081,22 +925,15 @@ internal class BenefitsSupportTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1125,22 +962,15 @@ internal class BenefitsSupportTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1169,22 +999,15 @@ internal class BenefitsSupportTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1213,22 +1036,15 @@ internal class BenefitsSupportTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1257,22 +1073,15 @@ internal class BenefitsSupportTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1301,22 +1110,15 @@ internal class BenefitsSupportTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1345,22 +1147,15 @@ internal class BenefitsSupportTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1389,22 +1184,15 @@ internal class BenefitsSupportTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1433,22 +1221,15 @@ internal class BenefitsSupportTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1477,22 +1258,15 @@ internal class BenefitsSupportTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1521,22 +1295,15 @@ internal class BenefitsSupportTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1565,22 +1332,15 @@ internal class BenefitsSupportTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt index 7f4ae9bc..17bf547a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt @@ -27,7 +27,7 @@ internal class CompanyBenefitTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() assertThat(companyBenefit.benefitId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -45,7 +45,7 @@ internal class CompanyBenefitTest { ) assertThat(companyBenefit.description()).contains("description") assertThat(companyBenefit.frequency()).contains(BenefitFrequency.ONE_TIME) - assertThat(companyBenefit.type()).contains(BenefitType._401K) + assertThat(companyBenefit.type()).contains(BenefitType._457) } @Test @@ -67,7 +67,7 @@ internal class CompanyBenefitTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() val roundtrippedCompanyBenefit = 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 20f9ee8d..1fe2d86c 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 @@ -4,6 +4,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -17,12 +18,6 @@ internal class EmploymentDataResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder().name("name").build() ) @@ -58,12 +53,17 @@ internal class EmploymentDataResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -71,11 +71,12 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) @@ -88,12 +89,6 @@ internal class EmploymentDataResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder().name("name").build() ) @@ -129,12 +124,17 @@ internal class EmploymentDataResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -142,11 +142,12 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) .sourceId("source_id") + .workId("work_id") .build() ) ) @@ -164,12 +165,6 @@ internal class EmploymentDataResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder().name("name").build() ) @@ -205,12 +200,17 @@ internal class EmploymentDataResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -218,11 +218,12 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt index 17190be2..ea4f1a63 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 @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper import com.tryfinch.api.errors.FinchInvalidDataException +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -20,12 +21,6 @@ internal class EmploymentDataTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department(EmploymentData.UnionMember0.Department.builder().name("name").build()) .employment( EmploymentData.UnionMember0.Employment.builder() @@ -59,12 +54,17 @@ internal class EmploymentDataTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -72,11 +72,12 @@ internal class EmploymentDataTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) .sourceId("source_id") + .workId("work_id") .build() val employmentData = EmploymentData.ofUnionMember0(unionMember0) @@ -93,12 +94,6 @@ internal class EmploymentDataTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder().name("name").build() ) @@ -134,12 +129,17 @@ internal class EmploymentDataTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -147,11 +147,12 @@ internal class EmploymentDataTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) .sourceId("source_id") + .workId("work_id") .build() ) 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 2b9c3056..e280855b 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 @@ -5,6 +5,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper +import java.time.LocalDate import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -37,7 +38,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -45,7 +46,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -102,7 +103,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -111,7 +112,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -170,7 +171,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -178,7 +179,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) 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 d16fa73a..65de7bff 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 @@ -23,7 +23,7 @@ internal class HrisBenefitCreateParamsTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() } @@ -44,7 +44,7 @@ internal class HrisBenefitCreateParamsTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() val body = params._body() @@ -63,7 +63,7 @@ internal class HrisBenefitCreateParamsTest { ) assertThat(body.description()).contains("description") assertThat(body.frequency()).contains(BenefitFrequency.ONE_TIME) - assertThat(body.type()).contains(BenefitType._401K) + assertThat(body.type()).contains(BenefitType._457) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt index 73041054..aca870bd 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt @@ -18,12 +18,12 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() @@ -39,12 +39,12 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() @@ -64,12 +64,12 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt index 1f2186bb..837c94a4 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt @@ -4,6 +4,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -19,12 +20,6 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder() .name("name") @@ -66,12 +61,17 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -79,11 +79,12 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) @@ -99,12 +100,6 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder() .name("name") @@ -144,12 +139,17 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -157,11 +157,12 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) @@ -181,12 +182,6 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder() .name("name") @@ -228,12 +223,17 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -241,11 +241,12 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt index 21ccd032..7f376d05 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt @@ -18,12 +18,21 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + .paging( + PayStatementResponseBody.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( PayStatement.builder() .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -46,15 +55,15 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes .builder() @@ -81,14 +90,13 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes @@ -117,9 +125,6 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay( @@ -132,6 +137,10 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -155,14 +164,10 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() @@ -178,12 +183,21 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + .paging( + PayStatementResponseBody.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( PayStatement.builder() .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -206,15 +220,15 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -239,14 +253,13 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes @@ -273,9 +286,6 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay( @@ -286,6 +296,10 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -308,14 +322,10 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() @@ -335,12 +345,21 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + .paging( + PayStatementResponseBody.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( PayStatement.builder() .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -363,15 +382,15 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes .builder() @@ -398,14 +417,13 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes @@ -434,9 +452,6 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay( @@ -449,6 +464,10 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -472,14 +491,10 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IncomeTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IncomeTest.kt index f50c94ec..9fbc186d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IncomeTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IncomeTest.kt @@ -4,6 +4,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,13 +16,13 @@ internal class IncomeTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() assertThat(income.amount()).contains(0L) assertThat(income.currency()).contains("currency") - assertThat(income.effectiveDate()).contains("effective_date") + assertThat(income.effectiveDate()).contains(LocalDate.parse("2019-12-27")) assertThat(income.unit()).contains(Income.Unit.YEARLY) } @@ -32,7 +33,7 @@ internal class IncomeTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/MoneyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/MoneyTest.kt index 76045e09..a9e57056 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/MoneyTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/MoneyTest.kt @@ -14,7 +14,7 @@ internal class MoneyTest { val money = Money.builder().amount(0L).currency("currency").build() assertThat(money.amount()).contains(0L) - assertThat(money.currency()).contains("currency") + assertThat(money.currency()).isEqualTo("currency") } @Test 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 e696a7ea..a0cd4fb7 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 @@ -4,7 +4,6 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -19,9 +18,9 @@ internal class PayGroupListResponseTest { .addPayFrequency(PayGroupListResponse.PayFrequency.ANNUALLY) .build() - assertThat(payGroupListResponse.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(payGroupListResponse.name()).contains("name") - assertThat(payGroupListResponse.payFrequencies().getOrNull()) + assertThat(payGroupListResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(payGroupListResponse.name()).isEqualTo("name") + assertThat(payGroupListResponse.payFrequencies()) .containsExactly(PayGroupListResponse.PayFrequency.ANNUALLY) } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgressTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgressTest.kt new file mode 100644 index 00000000..4bc588bf --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgressTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PayStatementDataSyncInProgressTest { + + @Test + fun create() { + val payStatementDataSyncInProgress = + PayStatementDataSyncInProgress.builder() + .code(PayStatementDataSyncInProgress.Code._202) + .finchCode(PayStatementDataSyncInProgress.FinchCode.DATA_SYNC_IN_PROGRESS) + .message( + PayStatementDataSyncInProgress.Message + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + ) + .name(PayStatementDataSyncInProgress.Name.ACCEPTED) + .build() + + assertThat(payStatementDataSyncInProgress.code()) + .isEqualTo(PayStatementDataSyncInProgress.Code._202) + assertThat(payStatementDataSyncInProgress.finchCode()) + .isEqualTo(PayStatementDataSyncInProgress.FinchCode.DATA_SYNC_IN_PROGRESS) + assertThat(payStatementDataSyncInProgress.message()) + .isEqualTo( + PayStatementDataSyncInProgress.Message + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + ) + assertThat(payStatementDataSyncInProgress.name()) + .isEqualTo(PayStatementDataSyncInProgress.Name.ACCEPTED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val payStatementDataSyncInProgress = + PayStatementDataSyncInProgress.builder() + .code(PayStatementDataSyncInProgress.Code._202) + .finchCode(PayStatementDataSyncInProgress.FinchCode.DATA_SYNC_IN_PROGRESS) + .message( + PayStatementDataSyncInProgress.Message + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + ) + .name(PayStatementDataSyncInProgress.Name.ACCEPTED) + .build() + + val roundtrippedPayStatementDataSyncInProgress = + jsonMapper.readValue( + jsonMapper.writeValueAsString(payStatementDataSyncInProgress), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPayStatementDataSyncInProgress) + .isEqualTo(payStatementDataSyncInProgress) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt index 56558e40..332a3257 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt @@ -16,12 +16,12 @@ internal class PayStatementItemListResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() @@ -31,21 +31,21 @@ internal class PayStatementItemListResponseTest { .build() assertThat(payStatementItemListResponse.attributes()) - .contains( + .isEqualTo( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() ) assertThat(payStatementItemListResponse.category()) - .contains(PayStatementItemListResponse.Category.EARNINGS) - assertThat(payStatementItemListResponse.name()).contains("name") + .isEqualTo(PayStatementItemListResponse.Category.EARNINGS) + assertThat(payStatementItemListResponse.name()).isEqualTo("name") } @Test @@ -55,12 +55,12 @@ internal class PayStatementItemListResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt index 40b61151..9ea719d0 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 @@ -5,7 +5,6 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,12 +14,16 @@ internal class PayStatementResponseBodyTest { fun create() { val payStatementResponseBody = PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + .paging(PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -39,15 +42,15 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -68,14 +71,13 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes.builder() @@ -97,9 +99,6 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) @@ -108,6 +107,10 @@ internal class PayStatementResponseBodyTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -127,26 +130,26 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() assertThat(payStatementResponseBody.paging()) - .contains(Paging.builder().offset(0L).count(0L).build()) - assertThat(payStatementResponseBody.payStatements().getOrNull()) + .isEqualTo(PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build()) + assertThat(payStatementResponseBody.payStatements()) .containsExactly( PayStatement.builder() .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -165,15 +168,15 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -192,14 +195,13 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes.builder() @@ -221,9 +223,6 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) @@ -232,6 +231,10 @@ internal class PayStatementResponseBodyTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -250,14 +253,10 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) } @@ -267,12 +266,16 @@ internal class PayStatementResponseBodyTest { val jsonMapper = jsonMapper() val payStatementResponseBody = PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + .paging(PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build()) .addPayStatement( PayStatement.builder() .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -291,15 +294,15 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -320,14 +323,13 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes.builder() @@ -349,9 +351,6 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) @@ -360,6 +359,10 @@ internal class PayStatementResponseBodyTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -379,14 +382,10 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt index b436711a..32b97305 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt @@ -16,12 +16,18 @@ internal class PayStatementResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + .paging( + PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build() + ) .addPayStatement( PayStatement.builder() .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -43,15 +49,15 @@ internal class PayStatementResponseTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -76,14 +82,13 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes.builder() @@ -109,9 +114,6 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) @@ -120,6 +122,10 @@ internal class PayStatementResponseTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -141,14 +147,10 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() @@ -158,135 +160,151 @@ internal class PayStatementResponseTest { .build() assertThat(payStatementResponse.body()) - .contains( - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) - .addPayStatement( - PayStatement.builder() - .addEarning( - PayStatement.Earning.builder() - .amount(0L) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) - .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .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) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) - .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) - .build() - ) - .build() + .isEqualTo( + PayStatementResponse.Body.ofPayStatementResponse( + PayStatementResponseBody.builder() + .paging( + PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build() + ) + .addPayStatement( + PayStatement.builder() + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .attributes( + PayStatement.Earning.Attributes.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata + .builder() + .metadata( + PayStatement.Earning.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) + .attributes( + PayStatement.EmployeeDeduction.Attributes.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes + .Metadata + .builder() + .metadata( + PayStatement.EmployeeDeduction + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) + .amount(0L) + .attributes( + PayStatement.EmployerContribution.Attributes.builder() + .metadata( + PayStatement.EmployerContribution.Attributes + .Metadata + .builder() + .metadata( + PayStatement.EmployerContribution + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), + ) + .build() + ) + .build() + ) + .build() + ) + .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() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .amount(0L) + .attributes( + PayStatement.Tax.Attributes.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .totalHours(0.0) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .build() + ) + .build() + ) ) - assertThat(payStatementResponse.code()).contains(0L) - assertThat(payStatementResponse.paymentId()).contains("payment_id") + assertThat(payStatementResponse.code()).isEqualTo(0L) + assertThat(payStatementResponse.paymentId()).isEqualTo("payment_id") } @Test @@ -296,12 +314,18 @@ internal class PayStatementResponseTest { PayStatementResponse.builder() .body( PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + .paging( + PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build() + ) .addPayStatement( PayStatement.builder() .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -323,15 +347,15 @@ internal class PayStatementResponseTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -356,14 +380,13 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes.builder() @@ -389,9 +412,6 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) @@ -400,6 +420,10 @@ internal class PayStatementResponseTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -421,14 +445,10 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_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 3724bb43..abd69775 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 @@ -18,6 +18,10 @@ internal class PayStatementTest { .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -35,15 +39,15 @@ internal class PayStatementTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -62,14 +66,13 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes.builder() @@ -89,9 +92,6 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) @@ -100,6 +100,10 @@ internal class PayStatementTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -118,20 +122,20 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() assertThat(payStatement.earnings().getOrNull()) .containsExactly( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -149,16 +153,16 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) .build() ) assertThat(payStatement.employeeDeductions().getOrNull()) .containsExactly( PayStatement.EmployeeDeduction.builder() .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -177,15 +181,14 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) assertThat(payStatement.employerContributions().getOrNull()) .containsExactly( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes.builder() @@ -205,20 +208,21 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) assertThat(payStatement.grossPay()) .contains(Money.builder().amount(0L).currency("currency").build()) - assertThat(payStatement.individualId()).contains("individual_id") + assertThat(payStatement.individualId()).isEqualTo("individual_id") assertThat(payStatement.netPay()) .contains(Money.builder().amount(0L).currency("currency").build()) assertThat(payStatement.paymentMethod()).contains(PayStatement.PaymentMethod.CHECK) assertThat(payStatement.taxes().getOrNull()) .containsExactly( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -236,14 +240,10 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) assertThat(payStatement.totalHours()).contains(0.0) - assertThat(payStatement.type()).contains(PayStatement.Type.REGULAR_PAYROLL) + assertThat(payStatement.type()).contains(PayStatement.Type.OFF_CYCLE_PAYROLL) } @Test @@ -254,6 +254,10 @@ internal class PayStatementTest { .addEarning( PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) .attributes( PayStatement.Earning.Attributes.builder() .metadata( @@ -271,15 +275,15 @@ internal class PayStatementTest { ) .build() ) - .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._457) .attributes( PayStatement.EmployeeDeduction.Attributes.builder() .metadata( @@ -298,14 +302,13 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( PayStatement.EmployerContribution.Attributes.builder() @@ -325,9 +328,6 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) @@ -336,6 +336,10 @@ internal class PayStatementTest { .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( PayStatement.Tax.Attributes.builder() @@ -354,14 +358,10 @@ internal class PayStatementTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() val roundtrippedPayStatement = 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 fce8572b..c21eb02e 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 @@ -30,7 +30,7 @@ internal class PaymentTest { ) .build() - assertThat(payment.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(payment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(payment.companyDebit()) .contains(Money.builder().amount(0L).currency("currency").build()) assertThat(payment.debitDate()).contains("debit_date") 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 c8c8d6be..b0966799 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 @@ -22,25 +22,19 @@ internal class ProviderTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -69,25 +63,19 @@ internal class ProviderTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -116,25 +104,19 @@ internal class ProviderTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -163,25 +145,19 @@ internal class ProviderTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -210,25 +186,19 @@ internal class ProviderTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -257,25 +227,19 @@ internal class ProviderTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -304,25 +268,19 @@ internal class ProviderTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -351,25 +309,19 @@ internal class ProviderTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -398,25 +350,19 @@ internal class ProviderTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -445,25 +391,19 @@ internal class ProviderTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -492,25 +432,19 @@ internal class ProviderTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -539,25 +473,19 @@ internal class ProviderTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -936,25 +864,19 @@ internal class ProviderTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -983,25 +905,19 @@ internal class ProviderTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1030,25 +946,19 @@ internal class ProviderTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1077,25 +987,19 @@ internal class ProviderTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1124,25 +1028,19 @@ internal class ProviderTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1171,25 +1069,19 @@ internal class ProviderTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1218,25 +1110,19 @@ internal class ProviderTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1265,25 +1151,19 @@ internal class ProviderTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1312,25 +1192,19 @@ internal class ProviderTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1359,25 +1233,19 @@ internal class ProviderTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1406,25 +1274,19 @@ internal class ProviderTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1453,25 +1315,19 @@ internal class ProviderTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1852,25 +1708,19 @@ internal class ProviderTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1899,25 +1749,19 @@ internal class ProviderTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1946,25 +1790,19 @@ internal class ProviderTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1993,25 +1831,19 @@ internal class ProviderTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2040,25 +1872,19 @@ internal class ProviderTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2087,25 +1913,19 @@ internal class ProviderTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2134,25 +1954,19 @@ internal class ProviderTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2181,25 +1995,19 @@ internal class ProviderTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2228,25 +2036,19 @@ internal class ProviderTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2275,25 +2077,19 @@ internal class ProviderTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2322,25 +2118,19 @@ internal class ProviderTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2369,25 +2159,19 @@ internal class ProviderTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) 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 2cabe240..17320a99 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 @@ -3,6 +3,7 @@ package com.tryfinch.api.models import com.tryfinch.api.core.JsonValue +import java.time.LocalDate import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -60,7 +61,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -68,7 +69,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -182,7 +183,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -190,7 +191,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -298,7 +299,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -306,7 +307,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) 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 5a5f9fab..5d37a553 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 @@ -3,6 +3,7 @@ package com.tryfinch.api.models import com.tryfinch.api.core.JsonValue +import java.time.LocalDate import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -34,7 +35,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -42,7 +43,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -108,7 +109,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -116,7 +117,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -174,7 +175,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -183,7 +184,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt index 0f9cfcf9..7373566a 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 @@ -2,7 +2,7 @@ package com.tryfinch.api.models -import com.tryfinch.api.core.JsonValue +import java.time.LocalDate import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -12,148 +12,54 @@ internal class SandboxPaymentCreateParamsTest { @Test fun create() { SandboxPaymentCreateParams.builder() - .endDate("end_date") + .endDate(LocalDate.parse("2019-12-27")) .addPayStatement( SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes.builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .hours(0.0) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) - .attributes( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("usd") - .name("401k test") + .amount(0L) + .name("x") .preTax(true) - .type(BenefitType._401K) + .type( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Type._457 + ) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.EmployerContribution.Type + ._457 ) - .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()) + .grossPay(1L) + .netPay(9007199254740991L) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - .startDate("start_date") + .startDate(LocalDate.parse("2019-12-27")) .build() } @@ -161,300 +67,109 @@ internal class SandboxPaymentCreateParamsTest { fun body() { val params = SandboxPaymentCreateParams.builder() - .endDate("end_date") + .endDate(LocalDate.parse("2019-12-27")) .addPayStatement( SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .hours(0.0) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) - .attributes( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("usd") - .name("401k test") + .amount(0L) + .name("x") .preTax(true) - .type(BenefitType._401K) + .type( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Type + ._457 + ) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() .amount(0L) - .attributes( + .name("x") + .type( SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .Type + ._457 ) - .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()) + .grossPay(1L) + .netPay(9007199254740991L) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - .startDate("start_date") + .startDate(LocalDate.parse("2019-12-27")) .build() val body = params._body() - assertThat(body.endDate()).contains("end_date") + assertThat(body.endDate()).contains(LocalDate.parse("2019-12-27")) assertThat(body.payStatements().getOrNull()) .containsExactly( SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes.builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .hours(0.0) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) - .attributes( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("usd") - .name("401k test") + .amount(0L) + .name("x") .preTax(true) - .type(BenefitType._401K) + .type( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Type._457 + ) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.EmployerContribution.Type + ._457 ) - .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()) + .grossPay(1L) + .netPay(9007199254740991L) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - assertThat(body.startDate()).contains("start_date") + assertThat(body.startDate()).contains(LocalDate.parse("2019-12-27")) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/WebhookEventTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/WebhookEventTest.kt index 31778dac..b136c72b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/WebhookEventTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/WebhookEventTest.kt @@ -30,28 +30,20 @@ internal class WebhookEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -81,28 +73,20 @@ internal class WebhookEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -132,28 +116,20 @@ internal class WebhookEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -183,28 +159,20 @@ internal class WebhookEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -234,28 +202,20 @@ internal class WebhookEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -285,28 +245,20 @@ internal class WebhookEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -336,28 +288,20 @@ internal class WebhookEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -387,28 +331,20 @@ internal class WebhookEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -438,28 +374,20 @@ internal class WebhookEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -489,28 +417,20 @@ internal class WebhookEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -540,28 +460,20 @@ internal class WebhookEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -591,28 +503,20 @@ internal class WebhookEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1046,27 +950,21 @@ internal class WebhookEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1113,27 +1011,21 @@ internal class WebhookEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1180,27 +1072,21 @@ internal class WebhookEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1247,27 +1133,21 @@ internal class WebhookEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1314,27 +1194,21 @@ internal class WebhookEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1381,27 +1255,21 @@ internal class WebhookEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1448,27 +1316,21 @@ internal class WebhookEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1515,27 +1377,21 @@ internal class WebhookEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1582,27 +1438,21 @@ internal class WebhookEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1649,27 +1499,21 @@ internal class WebhookEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1716,27 +1560,21 @@ internal class WebhookEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1783,27 +1621,21 @@ internal class WebhookEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncTest.kt index 05610d63..78721b51 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncTest.kt @@ -6,12 +6,14 @@ import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SessionServiceAsyncTest { + @Disabled("prism tests are broken") @Test fun new_() { val client = @@ -45,6 +47,7 @@ internal class SessionServiceAsyncTest { response.validate() } + @Disabled("prism tests are broken") @Test fun reauthenticate() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt index 9d4af287..99d7b0e9 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt @@ -42,7 +42,7 @@ internal class BenefitServiceAsyncTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncTest.kt index 197e0ec5..d0051d2b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncTest.kt @@ -5,12 +5,14 @@ package com.tryfinch.api.services.async.sandbox import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.SandboxConnectionCreateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ConnectionServiceAsyncTest { + @Disabled("prism tests are broken") @Test fun create() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt index ce338d43..56484790 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.Income import com.tryfinch.api.models.Location import com.tryfinch.api.models.SandboxDirectoryCreateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -87,7 +88,7 @@ internal class DirectoryServiceAsyncTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -95,7 +96,7 @@ internal class DirectoryServiceAsyncTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt index 8db4951b..6fa1664b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.Income import com.tryfinch.api.models.Location import com.tryfinch.api.models.SandboxEmploymentUpdateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -50,7 +51,7 @@ internal class EmploymentServiceAsyncTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -58,7 +59,7 @@ internal class EmploymentServiceAsyncTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt index fc235e7b..9d051351 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt @@ -4,10 +4,8 @@ package com.tryfinch.api.services.async.sandbox import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.models.BenefitType -import com.tryfinch.api.models.Money import com.tryfinch.api.models.SandboxPaymentCreateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,161 +24,62 @@ internal class PaymentServiceAsyncTest { val paymentFuture = paymentServiceAsync.create( SandboxPaymentCreateParams.builder() - .endDate("end_date") + .endDate(LocalDate.parse("2019-12-27")) .addPayStatement( SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .Earning - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .hours(0.0) - .name("name") + .name("x") .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY + SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS ) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) - .attributes( + .amount(0L) + .name("x") + .preTax(true) + .type( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .Type + ._457 ) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution .builder() .amount(0L) - .attributes( + .name("x") + .type( SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .Type + ._457 ) - .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()) + .grossPay(1L) + .netPay(9007199254740991L) .paymentMethod( SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK ) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - .startDate("start_date") + .startDate(LocalDate.parse("2019-12-27")) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncTest.kt index c45deebb..317d3121 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncTest.kt @@ -7,12 +7,14 @@ import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.ConnectionStatusType import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AccountServiceAsyncTest { + @Disabled("prism tests are broken") @Test fun create() { val client = 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 276f3066..31ee69fa 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 @@ -6,12 +6,14 @@ import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SessionServiceTest { + @Disabled("prism tests are broken") @Test fun new_() { val client = @@ -44,6 +46,7 @@ internal class SessionServiceTest { response.validate() } + @Disabled("prism tests are broken") @Test fun reauthenticate() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt index ff54482a..334986ff 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt @@ -42,7 +42,7 @@ internal class BenefitServiceTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() ) 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 af59feec..35591a08 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 @@ -5,12 +5,14 @@ package com.tryfinch.api.services.blocking.sandbox import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.SandboxConnectionCreateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ConnectionServiceTest { + @Disabled("prism tests are broken") @Test fun create() { val client = 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 2e1068ba..b14c55a9 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 @@ -8,6 +8,7 @@ import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.Income import com.tryfinch.api.models.Location import com.tryfinch.api.models.SandboxDirectoryCreateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -87,7 +88,7 @@ internal class DirectoryServiceTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -95,7 +96,7 @@ internal class DirectoryServiceTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .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 c372d897..235b740c 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 @@ -8,6 +8,7 @@ import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.Income import com.tryfinch.api.models.Location import com.tryfinch.api.models.SandboxEmploymentUpdateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -50,7 +51,7 @@ internal class EmploymentServiceTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -58,7 +59,7 @@ internal class EmploymentServiceTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt index 1a8dba8b..afb115b8 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 @@ -4,10 +4,8 @@ package com.tryfinch.api.services.blocking.sandbox import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.models.BenefitType -import com.tryfinch.api.models.Money import com.tryfinch.api.models.SandboxPaymentCreateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -26,161 +24,62 @@ internal class PaymentServiceTest { val payment = paymentService.create( SandboxPaymentCreateParams.builder() - .endDate("end_date") + .endDate(LocalDate.parse("2019-12-27")) .addPayStatement( SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .Earning - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .hours(0.0) - .name("name") + .name("x") .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY + SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS ) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) - .attributes( + .amount(0L) + .name("x") + .preTax(true) + .type( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .Type + ._457 ) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution .builder() .amount(0L) - .attributes( + .name("x") + .type( SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .Type + ._457 ) - .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()) + .grossPay(1L) + .netPay(9007199254740991L) .paymentMethod( SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK ) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .builder() - .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - .startDate("start_date") + .startDate(LocalDate.parse("2019-12-27")) .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 5cf6c67d..fdd7ec31 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 @@ -7,12 +7,14 @@ import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.ConnectionStatusType import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AccountServiceTest { + @Disabled("prism tests are broken") @Test fun create() { val client = diff --git a/release-please-config.json b/release-please-config.json index 9d3ea4fe..eb758e23 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -73,8 +73,5 @@ "minupalaniappan" ], "release-type": "simple", - "extra-files": [ - "README.md", - "build.gradle.kts" - ] + "extra-files": ["README.md", "build.gradle.kts"] }