diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94046873..ebbaa260 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,8 +12,6 @@ jobs: lint: name: lint runs-on: ubuntu-latest - - steps: - uses: actions/checkout@v4 @@ -34,7 +32,6 @@ jobs: test: name: test runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 8e76abb5..4808d97d 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "5.0.0" + ".": "5.1.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index e3e52833..c28b601a 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-14d375aab89e6b212fe459805a42d6ea7d7da8eae2037ae710a187d06911be1d.yml -openapi_spec_hash: 08b86ecbec3323717d48e4aaee48ed54 -config_hash: ce10384813f68ba3fed61c7b601b396b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bf858f37d7ab420841ddc6329dad8c46377308b6a5c8e935908011d0f9845e22.yml +openapi_spec_hash: 2523952a32436e3c7fd3b55508c2e7ee +config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/CHANGELOG.md b/CHANGELOG.md index be5fb27e..1ab14aa2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,42 @@ # Changelog +## 5.1.0 (2025-04-11) + +Full Changelog: [v5.0.0...v5.1.0](https://github.com/Finch-API/finch-api-java/compare/v5.0.0...v5.1.0) + +### Features + +* **api:** add models for hrs benefits individuals async responses ([511b7fb](https://github.com/Finch-API/finch-api-java/commit/511b7fb4b6969bfded3c4f021753c1823b10baf1)) +* **api:** api update ([#533](https://github.com/Finch-API/finch-api-java/issues/533)) ([a7c802c](https://github.com/Finch-API/finch-api-java/commit/a7c802c84dff751a252c17ea3d4b19624792cba1)) +* **api:** benefits mutation API endpoints (create benefit, update benefit, enroll individual, unenroll individual) now properly return async response types ([#539](https://github.com/Finch-API/finch-api-java/issues/539)) ([4d1722f](https://github.com/Finch-API/finch-api-java/commit/4d1722feebfff70b762a41c6ea7c7a72299de8a8)) +* **client:** make pagination robust to missing data ([c054662](https://github.com/Finch-API/finch-api-java/commit/c054662ddf6e98fb805574d6851f8f81933bc07a)) +* **client:** support setting base URL via env var ([#535](https://github.com/Finch-API/finch-api-java/issues/535)) ([2a19f7e](https://github.com/Finch-API/finch-api-java/commit/2a19f7ec2159e69798afdb92f6f220254276a5fe)) + + +### Bug Fixes + +* **client:** bump to better jackson version ([#537](https://github.com/Finch-API/finch-api-java/issues/537)) ([4b3bc8d](https://github.com/Finch-API/finch-api-java/commit/4b3bc8d9e5a06356889f49afd96b19085c0aedfe)) +* **client:** page compilation error ([4da1190](https://github.com/Finch-API/finch-api-java/commit/4da1190d2b90298fb4d24ac48f2b9009fb39534f)) + + +### Chores + +* fix typo ([94a98e8](https://github.com/Finch-API/finch-api-java/commit/94a98e8ccff95f19fb8faf965525dd063745a3cb)) +* fix typo ([#540](https://github.com/Finch-API/finch-api-java/issues/540)) ([c56d73d](https://github.com/Finch-API/finch-api-java/commit/c56d73d2d29464841ec771edfa791fda80fb073f)) +* **internal:** expand CI branch coverage ([#536](https://github.com/Finch-API/finch-api-java/issues/536)) ([ed70465](https://github.com/Finch-API/finch-api-java/commit/ed704657d81ca00bc2e0baf40291d754b343d2aa)) +* **internal:** reduce CI branch coverage ([72adfa6](https://github.com/Finch-API/finch-api-java/commit/72adfa647da7ce56023200595f04f46379245ff8)) + + +### Documentation + +* add comments for page methods ([c054662](https://github.com/Finch-API/finch-api-java/commit/c054662ddf6e98fb805574d6851f8f81933bc07a)) + + +### Refactors + +* **client:** deduplicate page response classes ([#538](https://github.com/Finch-API/finch-api-java/issues/538)) ([c054662](https://github.com/Finch-API/finch-api-java/commit/c054662ddf6e98fb805574d6851f8f81933bc07a)) +* **client:** migrate pages to builder pattern ([#541](https://github.com/Finch-API/finch-api-java/issues/541)) ([5463e75](https://github.com/Finch-API/finch-api-java/commit/5463e75521312f9b219be62a6c7b4d090bec0754)) + ## 5.0.0 (2025-04-08) Full Changelog: [v4.2.0...v5.0.0](https://github.com/Finch-API/finch-api-java/compare/v4.2.0...v5.0.0) diff --git a/README.md b/README.md index e0b9c13b..687c0836 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/5.0.0) -[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/5.0.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/5.0.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/5.1.0) +[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/5.1.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/5.1.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 also available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/5.0.0). +The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are also available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/5.1.0). @@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.tryfinch.com](https://deve ### Gradle ```kotlin -implementation("com.tryfinch.api:finch-java:5.0.0") +implementation("com.tryfinch.api:finch-java:5.1.0") ``` ### Maven @@ -35,7 +35,7 @@ implementation("com.tryfinch.api:finch-java:5.0.0") com.tryfinch.api finch-java - 5.0.0 + 5.1.0 ``` @@ -54,7 +54,7 @@ import com.tryfinch.api.models.HrisDirectoryListPage; import com.tryfinch.api.models.HrisDirectoryListParams; FinchClient client = FinchOkHttpClient.builder() - // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET` and `FINCH_WEBHOOK_SECRET` environment variables + // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET`, `FINCH_WEBHOOK_SECRET` and `FINCH_BASE_URL` environment variables .fromEnv() .accessToken("My Access Token") .build(); @@ -71,7 +71,7 @@ import com.tryfinch.api.client.FinchClient; import com.tryfinch.api.client.okhttp.FinchOkHttpClient; FinchClient client = FinchOkHttpClient.builder() - // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET` and `FINCH_WEBHOOK_SECRET` environment variables + // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET`, `FINCH_WEBHOOK_SECRET` and `FINCH_BASE_URL` environment variables .fromEnv() .accessToken("My Access Token") .build(); @@ -95,7 +95,7 @@ import com.tryfinch.api.client.FinchClient; import com.tryfinch.api.client.okhttp.FinchOkHttpClient; FinchClient client = FinchOkHttpClient.builder() - // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET` and `FINCH_WEBHOOK_SECRET` environment variables + // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET`, `FINCH_WEBHOOK_SECRET` and `FINCH_BASE_URL` environment variables .fromEnv() .accessToken("My Access Token") .build(); @@ -103,11 +103,12 @@ FinchClient client = FinchOkHttpClient.builder() See this table for the available options: -| Setter | Environment variable | Required | Default value | -| --------------- | ---------------------- | -------- | ------------- | -| `clientId` | `FINCH_CLIENT_ID` | false | - | -| `clientSecret` | `FINCH_CLIENT_SECRET` | false | - | -| `webhookSecret` | `FINCH_WEBHOOK_SECRET` | false | - | +| Setter | Environment variable | Required | Default value | +| --------------- | ---------------------- | -------- | ---------------------------- | +| `clientId` | `FINCH_CLIENT_ID` | false | - | +| `clientSecret` | `FINCH_CLIENT_SECRET` | false | - | +| `webhookSecret` | `FINCH_WEBHOOK_SECRET` | false | - | +| `baseUrl` | `FINCH_BASE_URL` | true | `"https://api.tryfinch.com"` | > [!TIP] > Don't create more than one client in the same application. Each client has a connection pool and @@ -139,7 +140,7 @@ import com.tryfinch.api.models.HrisDirectoryListParams; import java.util.concurrent.CompletableFuture; FinchClient client = FinchOkHttpClient.builder() - // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET` and `FINCH_WEBHOOK_SECRET` environment variables + // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET`, `FINCH_WEBHOOK_SECRET` and `FINCH_BASE_URL` environment variables .fromEnv() .accessToken("My Access Token") .build(); @@ -157,7 +158,7 @@ import com.tryfinch.api.models.HrisDirectoryListParams; import java.util.concurrent.CompletableFuture; FinchClientAsync client = FinchOkHttpClientAsync.builder() - // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET` and `FINCH_WEBHOOK_SECRET` environment variables + // Configures using the `FINCH_CLIENT_ID`, `FINCH_CLIENT_SECRET`, `FINCH_WEBHOOK_SECRET` and `FINCH_BASE_URL` environment variables .fromEnv() .accessToken("My Access Token") .build(); diff --git a/build.gradle.kts b/build.gradle.kts index 371fde06..a52f35b7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.tryfinch.api" - version = "5.0.0" // x-release-please-version + version = "5.1.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 3e365dbe..625e6cac 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 @@ -29,14 +29,10 @@ class FinchOkHttpClient private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -190,7 +186,7 @@ class FinchOkHttpClient private constructor() { clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .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 0a25d955..b8aac548 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 @@ -29,14 +29,10 @@ class FinchOkHttpClientAsync private constructor() { class Builder internal constructor() { private var clientOptions: ClientOptions.Builder = ClientOptions.builder() - private var baseUrl: String = ClientOptions.PRODUCTION_URL private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { - clientOptions.baseUrl(baseUrl) - this.baseUrl = baseUrl - } + fun baseUrl(baseUrl: String) = apply { clientOptions.baseUrl(baseUrl) } /** * Whether to throw an exception if any of the Jackson versions detected at runtime are @@ -190,7 +186,7 @@ class FinchOkHttpClientAsync private constructor() { clientOptions .httpClient( OkHttpClient.builder() - .baseUrl(baseUrl) + .baseUrl(clientOptions.baseUrl()) .timeout(timeout) .proxy(proxy) .build() diff --git a/finch-java-core/build.gradle.kts b/finch-java-core/build.gradle.kts index cc2d57aa..b3da0288 100644 --- a/finch-java-core/build.gradle.kts +++ b/finch-java-core/build.gradle.kts @@ -17,14 +17,14 @@ configurations.all { } dependencies { - api("com.fasterxml.jackson.core:jackson-core:2.18.1") - api("com.fasterxml.jackson.core:jackson-databind:2.18.1") + api("com.fasterxml.jackson.core:jackson-core:2.18.2") + api("com.fasterxml.jackson.core:jackson-databind:2.18.2") api("com.google.errorprone:error_prone_annotations:2.33.0") - implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.1") - implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.1") - implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.1") + implementation("com.fasterxml.jackson.core:jackson-annotations:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.18.2") + implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.18.2") + implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.18.2") implementation("org.apache.httpcomponents.core5:httpcore5:5.2.4") implementation("org.apache.httpcomponents.client5:httpclient5:5.3.1") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Check.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Check.kt index 5918fb36..7ac22c66 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Check.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/Check.kt @@ -47,6 +47,7 @@ internal fun checkMaxLength(name: String, value: String, maxLength: Int): String internal fun checkJacksonVersionCompatibility() { val incompatibleJacksonVersions = RUNTIME_JACKSON_VERSIONS.mapNotNull { + val badVersionReason = BAD_JACKSON_VERSIONS[it.toString()] when { it.majorVersion != MINIMUM_JACKSON_VERSION.majorVersion -> it to "incompatible major version" @@ -55,6 +56,7 @@ internal fun checkJacksonVersionCompatibility() { it.minorVersion == MINIMUM_JACKSON_VERSION.minorVersion && it.patchLevel < MINIMUM_JACKSON_VERSION.patchLevel -> it to "patch version too low" + badVersionReason != null -> it to badVersionReason else -> null } } @@ -77,6 +79,8 @@ Double-check that you are depending on compatible Jackson versions. } private val MINIMUM_JACKSON_VERSION: Version = VersionUtil.parseVersion("2.13.4", null, null) +private val BAD_JACKSON_VERSIONS: Map = + mapOf("2.18.1" to "due to https://github.com/FasterXML/jackson-databind/issues/4639") private val RUNTIME_JACKSON_VERSIONS: List = listOf( com.fasterxml.jackson.core.json.PackageVersion.VERSION, 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 ee2132fe..8a9abd9c 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 @@ -222,7 +222,10 @@ 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) } System.getenv("FINCH_CLIENT_SECRET")?.let { clientSecret(it) } System.getenv("FINCH_WEBHOOK_SECRET")?.let { webhookSecret(it) } 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 new file mode 100644 index 00000000..be8e05eb --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt @@ -0,0 +1,918 @@ +// 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/CreateCompanyBenefitsResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt index 16e0501e..a65b38d4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt @@ -18,13 +18,15 @@ import java.util.Objects class CreateCompanyBenefitsResponse private constructor( private val benefitId: JsonField, + private val jobId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("benefit_id") @ExcludeMissing benefitId: JsonField = JsonMissing.of() - ) : this(benefitId, mutableMapOf()) + @JsonProperty("benefit_id") @ExcludeMissing benefitId: JsonField = JsonMissing.of(), + @JsonProperty("job_id") @ExcludeMissing jobId: JsonField = JsonMissing.of(), + ) : this(benefitId, jobId, mutableMapOf()) /** * The id of the benefit. @@ -34,6 +36,12 @@ private constructor( */ fun benefitId(): String = benefitId.getRequired("benefit_id") + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun jobId(): String = jobId.getRequired("job_id") + /** * Returns the raw JSON value of [benefitId]. * @@ -41,6 +49,13 @@ private constructor( */ @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId(): JsonField = benefitId + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -62,6 +77,7 @@ private constructor( * The following fields are required: * ```java * .benefitId() + * .jobId() * ``` */ @JvmStatic fun builder() = Builder() @@ -71,11 +87,13 @@ private constructor( class Builder internal constructor() { private var benefitId: JsonField? = null + private var jobId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(createCompanyBenefitsResponse: CreateCompanyBenefitsResponse) = apply { benefitId = createCompanyBenefitsResponse.benefitId + jobId = createCompanyBenefitsResponse.jobId additionalProperties = createCompanyBenefitsResponse.additionalProperties.toMutableMap() } @@ -91,6 +109,16 @@ private constructor( */ fun benefitId(benefitId: JsonField) = apply { this.benefitId = benefitId } + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -118,6 +146,7 @@ private constructor( * The following fields are required: * ```java * .benefitId() + * .jobId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -125,6 +154,7 @@ private constructor( fun build(): CreateCompanyBenefitsResponse = CreateCompanyBenefitsResponse( checkRequired("benefitId", benefitId), + checkRequired("jobId", jobId), additionalProperties.toMutableMap(), ) } @@ -137,6 +167,7 @@ private constructor( } benefitId() + jobId() validated = true } @@ -153,22 +184,24 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (benefitId.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (benefitId.asKnown().isPresent) 1 else 0) + (if (jobId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is CreateCompanyBenefitsResponse && benefitId == other.benefitId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateCompanyBenefitsResponse && benefitId == other.benefitId && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(benefitId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(benefitId, jobId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "CreateCompanyBenefitsResponse{benefitId=$benefitId, additionalProperties=$additionalProperties}" + "CreateCompanyBenefitsResponse{benefitId=$benefitId, jobId=$jobId, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt deleted file mode 100644 index f2a7666c..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt +++ /dev/null @@ -1,579 +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.errors.FinchInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class EnrolledIndividual -private constructor( - private val body: JsonField, - private val code: JsonField, - private val individualId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), - @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), - @JsonProperty("individual_id") - @ExcludeMissing - individualId: JsonField = JsonMissing.of(), - ) : this(body, code, individualId, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun body(): Optional = body.getOptional("body") - - /** - * HTTP status code. Either 201 or 200 - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun code(): Optional = code.getOptional("code") - - /** - * @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") - - /** - * 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 - - /** - * 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 [individualId]. - * - * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("individual_id") - @ExcludeMissing - fun _individualId(): JsonField = individualId - - @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 [EnrolledIndividual]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EnrolledIndividual]. */ - class Builder internal constructor() { - - private var body: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(enrolledIndividual: EnrolledIndividual) = apply { - body = enrolledIndividual.body - code = enrolledIndividual.code - individualId = enrolledIndividual.individualId - additionalProperties = enrolledIndividual.additionalProperties.toMutableMap() - } - - 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 [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 } - - /** HTTP status code. Either 201 or 200 */ - 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 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 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 [EnrolledIndividual]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EnrolledIndividual = - EnrolledIndividual(body, code, individualId, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): EnrolledIndividual = apply { - if (validated) { - return@apply - } - - body().ifPresent { it.validate() } - code().ifPresent { it.validate() } - individualId() - 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 = - (body.asKnown().getOrNull()?.validity() ?: 0) + - (code.asKnown().getOrNull()?.validity() ?: 0) + - (if (individualId.asKnown().isPresent) 1 else 0) - - class Body - private constructor( - private val finchCode: JsonField, - private val message: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("finch_code") - @ExcludeMissing - finchCode: JsonField = JsonMissing.of(), - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(finchCode, message, name, mutableMapOf()) - - /** - * A descriptive identifier for the response. - * - * @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") - - /** - * Short description in English that provides more information about the response. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun message(): Optional = message.getOptional("message") - - /** - * Identifier indicating whether the benefit was newly enrolled or updated. - * - * @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 [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 [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var finchCode: JsonField = JsonMissing.of() - private var message: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - finchCode = body.finchCode - message = body.message - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** A descriptive identifier for the response. */ - fun finchCode(finchCode: String?) = finchCode(JsonField.ofNullable(finchCode)) - - /** Alias for calling [Builder.finchCode] with `finchCode.orElse(null)`. */ - fun finchCode(finchCode: Optional) = finchCode(finchCode.getOrNull()) - - /** - * 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 } - - /** Short description in English that provides more information about the response. */ - fun message(message: String?) = message(JsonField.ofNullable(message)) - - /** Alias for calling [Builder.message] with `message.orElse(null)`. */ - fun message(message: Optional) = message(message.getOrNull()) - - /** - * 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 } - - /** Identifier indicating whether the benefit was newly enrolled or updated. */ - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(finchCode, message, name, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - finchCode() - message() - 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 (finchCode.asKnown().isPresent) 1 else 0) + - (if (message.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && finchCode == other.finchCode && message == other.message && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(finchCode, message, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{finchCode=$finchCode, message=$message, name=$name, additionalProperties=$additionalProperties}" - } - - /** HTTP status code. Either 201 or 200 */ - class Code @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val OK = of(200) - - @JvmField val CREATED = of(201) - - @JvmField val NOT_FOUND = of(404) - - @JvmField val FORBIDDEN = of(403) - - @JvmStatic fun of(value: Long) = Code(JsonField.of(value)) - } - - /** An enum containing [Code]'s known values. */ - enum class Known { - OK, - CREATED, - NOT_FOUND, - FORBIDDEN, - } - - /** - * An enum containing [Code]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Code] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - OK, - CREATED, - NOT_FOUND, - FORBIDDEN, - /** An enum member indicating that [Code] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - OK -> Value.OK - CREATED -> Value.CREATED - NOT_FOUND -> Value.NOT_FOUND - FORBIDDEN -> Value.FORBIDDEN - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - OK -> Known.OK - CREATED -> Known.CREATED - NOT_FOUND -> Known.NOT_FOUND - FORBIDDEN -> Known.FORBIDDEN - 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 asLong(): Long = - _value().asNumber().getOrNull()?.let { - if (it.toDouble() % 1 == 0.0) it.toLong() else null - } ?: throw FinchInvalidDataException("Value is not a Long") - - 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() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EnrolledIndividual && body == other.body && code == other.code && individualId == other.individualId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(body, code, individualId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EnrolledIndividual{body=$body, code=$code, individualId=$individualId, additionalProperties=$additionalProperties}" -} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt new file mode 100644 index 00000000..b3cabc1d --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt @@ -0,0 +1,172 @@ +// 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.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 + +class EnrolledIndividualBenefitResponse +private constructor( + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("job_id") @ExcludeMissing jobId: JsonField = JsonMissing.of() + ) : this(jobId, 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 jobId(): String = jobId.getRequired("job_id") + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId + + @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 + * [EnrolledIndividualBenefitResponse]. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EnrolledIndividualBenefitResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(enrolledIndividualBenefitResponse: EnrolledIndividualBenefitResponse) = + apply { + jobId = enrolledIndividualBenefitResponse.jobId + additionalProperties = + enrolledIndividualBenefitResponse.additionalProperties.toMutableMap() + } + + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + + 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 [EnrolledIndividualBenefitResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EnrolledIndividualBenefitResponse = + EnrolledIndividualBenefitResponse( + checkRequired("jobId", jobId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EnrolledIndividualBenefitResponse = apply { + if (validated) { + return@apply + } + + jobId() + 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 (jobId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EnrolledIndividualBenefitResponse && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EnrolledIndividualBenefitResponse{jobId=$jobId, additionalProperties=$additionalProperties}" +} 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 6ca15012..b5773d4e 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 @@ -2,166 +2,103 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.benefits.IndividualService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** Get enrollment information for the given individuals. */ +/** @see [IndividualService.retrieveManyBenefits] */ class HrisBenefitIndividualRetrieveManyBenefitsPage private constructor( - private val individualsService: IndividualService, + private val service: IndividualService, private val params: HrisBenefitIndividualRetrieveManyBenefitsParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = + Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPage && individualsService == other.individualsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ + fun getNextPage(): Optional = + getNextPageParams().map { service.retrieveManyBenefits(it) } - override fun toString() = - "HrisBenefitIndividualRetrieveManyBenefitsPage{individualsService=$individualsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitIndividualRetrieveManyBenefitsParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { individualsService.retrieveManyBenefits(it) } - } + /** The response that this page was parsed from. */ + fun items(): List = items - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of( - individualsService: IndividualService, - params: HrisBenefitIndividualRetrieveManyBenefitsParams, - response: Response, - ) = HrisBenefitIndividualRetrieveManyBenefitsPage(individualsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitIndividualRetrieveManyBenefitsPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + /** A builder for [HrisBenefitIndividualRetrieveManyBenefitsPage]. */ + class Builder internal constructor() { + + private var service: IndividualService? = null + private var params: HrisBenefitIndividualRetrieveManyBenefitsParams? = null + private var items: List? = null + + @JvmSynthetic + internal fun from( + hrisBenefitIndividualRetrieveManyBenefitsPage: + HrisBenefitIndividualRetrieveManyBenefitsPage + ) = apply { + service = hrisBenefitIndividualRetrieveManyBenefitsPage.service + params = hrisBenefitIndividualRetrieveManyBenefitsPage.params + items = hrisBenefitIndividualRetrieveManyBenefitsPage.items } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" - - companion object { + fun service(service: IndividualService) = apply { this.service = service } - /** - * Returns a mutable builder for constructing an instance of - * [HrisBenefitIndividualRetrieveManyBenefitsPage]. - */ - @JvmStatic fun builder() = Builder() + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitIndividualRetrieveManyBenefitsParams) = apply { + this.params = params } - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [HrisBenefitIndividualRetrieveManyBenefitsPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisBenefitIndividualRetrieveManyBenefitsPage = + HrisBenefitIndividualRetrieveManyBenefitsPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: HrisBenefitIndividualRetrieveManyBenefitsPage) : @@ -183,4 +120,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPage && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "HrisBenefitIndividualRetrieveManyBenefitsPage{service=$service, params=$params, items=$items}" } 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 1ff8bb43..1d164078 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 @@ -2,170 +2,106 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -/** Get enrollment information for the given individuals. */ +/** @see [IndividualServiceAsync.retrieveManyBenefits] */ class HrisBenefitIndividualRetrieveManyBenefitsPageAsync private constructor( - private val individualsService: IndividualServiceAsync, + private val service: IndividualServiceAsync, private val params: HrisBenefitIndividualRetrieveManyBenefitsParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPageAsync && individualsService == other.individualsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisBenefitIndividualRetrieveManyBenefitsPageAsync{individualsService=$individualsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = + Optional.empty() fun getNextPage(): - CompletableFuture> { - return getNextPageParams() - .map { individualsService.retrieveManyBenefits(it).thenApply { Optional.of(it) } } + CompletableFuture> = + getNextPageParams() + .map { service.retrieveManyBenefits(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - individualsService: IndividualServiceAsync, - params: HrisBenefitIndividualRetrieveManyBenefitsParams, - response: Response, - ) = HrisBenefitIndividualRetrieveManyBenefitsPageAsync(individualsService, params, response) - } - - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitIndividualRetrieveManyBenefitsParams = params - private var validated: Boolean = false + /** The response that this page was parsed from. */ + fun items(): List = items - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) + companion object { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitIndividualRetrieveManyBenefitsPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + /** A builder for [HrisBenefitIndividualRetrieveManyBenefitsPageAsync]. */ + class Builder internal constructor() { + + private var service: IndividualServiceAsync? = null + private var params: HrisBenefitIndividualRetrieveManyBenefitsParams? = null + private var items: List? = null + + @JvmSynthetic + internal fun from( + hrisBenefitIndividualRetrieveManyBenefitsPageAsync: + HrisBenefitIndividualRetrieveManyBenefitsPageAsync + ) = apply { + service = hrisBenefitIndividualRetrieveManyBenefitsPageAsync.service + params = hrisBenefitIndividualRetrieveManyBenefitsPageAsync.params + items = hrisBenefitIndividualRetrieveManyBenefitsPageAsync.items } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" + fun service(service: IndividualServiceAsync) = apply { this.service = service } - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisBenefitIndividualRetrieveManyBenefitsPageAsync]. - */ - @JvmStatic fun builder() = Builder() + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitIndividualRetrieveManyBenefitsParams) = apply { + this.params = params } - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [HrisBenefitIndividualRetrieveManyBenefitsPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisBenefitIndividualRetrieveManyBenefitsPageAsync = + HrisBenefitIndividualRetrieveManyBenefitsPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: HrisBenefitIndividualRetrieveManyBenefitsPageAsync) { @@ -197,4 +133,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPageAsync && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "HrisBenefitIndividualRetrieveManyBenefitsPageAsync{service=$service, params=$params, items=$items}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt deleted file mode 100644 index 2b7b92b4..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt +++ /dev/null @@ -1,186 +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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException -import com.tryfinch.api.services.blocking.hris.benefits.IndividualService -import java.util.Collections -import java.util.Objects -import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlin.jvm.optionals.getOrNull - -/** Unenroll individuals from a deduction or contribution */ -class HrisBenefitIndividualUnenrollManyPage -private constructor( - private val individualsService: IndividualService, - private val params: HrisBenefitIndividualUnenrollManyParams, - private val response: Response, -) { - - fun response(): Response = response - - fun items(): List = response().items() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitIndividualUnenrollManyPage && individualsService == other.individualsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisBenefitIndividualUnenrollManyPage{individualsService=$individualsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): Optional { - return getNextPageParams().map { individualsService.unenrollMany(it) } - } - - fun autoPager(): AutoPager = AutoPager(this) - - companion object { - - @JvmStatic - fun of( - individualsService: IndividualService, - params: HrisBenefitIndividualUnenrollManyParams, - response: Response, - ) = HrisBenefitIndividualUnenrollManyPage(individualsService, params, response) - } - - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisBenefitIndividualUnenrollManyPage]. - */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } - } - - class AutoPager(private val firstPage: HrisBenefitIndividualUnenrollManyPage) : - Iterable { - - override fun iterator(): Iterator = iterator { - var page = firstPage - var index = 0 - while (true) { - while (index < page.items().size) { - yield(page.items()[index++]) - } - page = page.getNextPage().getOrNull() ?: break - index = 0 - } - } - - fun stream(): Stream { - return StreamSupport.stream(spliterator(), false) - } - } -} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt deleted file mode 100644 index e569d5ee..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt +++ /dev/null @@ -1,198 +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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException -import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync -import java.util.Collections -import java.util.Objects -import java.util.Optional -import java.util.concurrent.CompletableFuture -import java.util.concurrent.Executor -import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull - -/** Unenroll individuals from a deduction or contribution */ -class HrisBenefitIndividualUnenrollManyPageAsync -private constructor( - private val individualsService: IndividualServiceAsync, - private val params: HrisBenefitIndividualUnenrollManyParams, - private val response: Response, -) { - - fun response(): Response = response - - fun items(): List = response().items() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitIndividualUnenrollManyPageAsync && individualsService == other.individualsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisBenefitIndividualUnenrollManyPageAsync{individualsService=$individualsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { individualsService.unenrollMany(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } - - fun autoPager(): AutoPager = AutoPager(this) - - companion object { - - @JvmStatic - fun of( - individualsService: IndividualServiceAsync, - params: HrisBenefitIndividualUnenrollManyParams, - response: Response, - ) = HrisBenefitIndividualUnenrollManyPageAsync(individualsService, params, response) - } - - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisBenefitIndividualUnenrollManyPageAsync]. - */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } - } - - class AutoPager(private val firstPage: HrisBenefitIndividualUnenrollManyPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (UnenrolledIndividual) -> Boolean, - executor: Executor, - ): CompletableFuture = - thenComposeAsync( - { page -> - page - .filter { it.items().all(action) } - .map { it.getNextPage().forEach(action, executor) } - .orElseGet { CompletableFuture.completedFuture(null) } - }, - executor, - ) - return CompletableFuture.completedFuture(Optional.of(firstPage)) - .forEach(action::test, executor) - } - - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() - return forEach(values::add, executor).thenApply { values } - } - } -} 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 55732adf..7b00ce90 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 @@ -2,160 +2,95 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.BenefitService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** List all company-wide deductions and contributions. */ +/** @see [BenefitService.list] */ class HrisBenefitListPage private constructor( - private val benefitsService: BenefitService, + private val service: BenefitService, private val params: HrisBenefitListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitListPage && benefitsService == other.benefitsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, response) /* spotless:on */ + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } - override fun toString() = - "HrisBenefitListPage{benefitsService=$benefitsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitListParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { benefitsService.list(it) } - } + /** The response that this page was parsed from. */ + fun items(): List = items - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of(benefitsService: BenefitService, params: HrisBenefitListParams, response: Response) = - HrisBenefitListPage(benefitsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [HrisBenefitListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** A builder for [HrisBenefitListPage]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) + private var service: BenefitService? = null + private var params: HrisBenefitListParams? = null + private var items: List? = null - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JvmSynthetic + internal fun from(hrisBenefitListPage: HrisBenefitListPage) = apply { + service = hrisBenefitListPage.service + params = hrisBenefitListPage.params + items = hrisBenefitListPage.items } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" - - companion object { - - /** Returns a mutable builder for constructing an instance of [HrisBenefitListPage]. */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + fun service(service: BenefitService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [HrisBenefitListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisBenefitListPage = + HrisBenefitListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: HrisBenefitListPage) : Iterable { @@ -176,4 +111,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisBenefitListPage && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = "HrisBenefitListPage{service=$service, params=$params, items=$items}" } 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 1dd66c6b..f49f49a4 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 @@ -2,168 +2,98 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.BenefitServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -/** List all company-wide deductions and contributions. */ +/** @see [BenefitServiceAsync.list] */ class HrisBenefitListPageAsync private constructor( - private val benefitsService: BenefitServiceAsync, + private val service: BenefitServiceAsync, private val params: HrisBenefitListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitListPageAsync && benefitsService == other.benefitsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisBenefitListPageAsync{benefitsService=$benefitsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { benefitsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - benefitsService: BenefitServiceAsync, - params: HrisBenefitListParams, - response: Response, - ) = HrisBenefitListPageAsync(benefitsService, params, response) - } - - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitListParams = params - private var validated: Boolean = false + /** The response that this page was parsed from. */ + fun items(): List = items - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } + companion object { - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ + /** + * Returns a mutable builder for constructing an instance of [HrisBenefitListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" + /** A builder for [HrisBenefitListPageAsync]. */ + class Builder internal constructor() { - companion object { + private var service: BenefitServiceAsync? = null + private var params: HrisBenefitListParams? = null + private var items: List? = null - /** - * Returns a mutable builder for constructing an instance of [HrisBenefitListPageAsync]. - */ - @JvmStatic fun builder() = Builder() + @JvmSynthetic + internal fun from(hrisBenefitListPageAsync: HrisBenefitListPageAsync) = apply { + service = hrisBenefitListPageAsync.service + params = hrisBenefitListPageAsync.params + items = hrisBenefitListPageAsync.items } - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + fun service(service: BenefitServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [HrisBenefitListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisBenefitListPageAsync = + HrisBenefitListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: HrisBenefitListPageAsync) { @@ -194,4 +124,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisBenefitListPageAsync && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "HrisBenefitListPageAsync{service=$service, params=$params, items=$items}" } 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 3d15fd51..147d1698 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 @@ -2,172 +2,107 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.BenefitService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** Get deductions metadata */ +/** @see [BenefitService.listSupportedBenefits] */ class HrisBenefitListSupportedBenefitsPage private constructor( - private val benefitsService: BenefitService, + private val service: BenefitService, private val params: HrisBenefitListSupportedBenefitsParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitListSupportedBenefitsPage && benefitsService == other.benefitsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, response) /* spotless:on */ + fun getNextPage(): Optional = + getNextPageParams().map { service.listSupportedBenefits(it) } - override fun toString() = - "HrisBenefitListSupportedBenefitsPage{benefitsService=$benefitsService, params=$params, response=$response}" + fun autoPager(): AutoPager = AutoPager(this) - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitListSupportedBenefitsParams = params - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPage(): Optional { - return getNextPageParams().map { benefitsService.listSupportedBenefits(it) } - } - - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of( - benefitsService: BenefitService, - params: HrisBenefitListSupportedBenefitsParams, - response: Response, - ) = HrisBenefitListSupportedBenefitsPage(benefitsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitListSupportedBenefitsPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false + /** A builder for [HrisBenefitListSupportedBenefitsPage]. */ + class Builder internal constructor() { - fun validate(): Response = apply { - if (validated) { - return@apply - } + private var service: BenefitService? = null + private var params: HrisBenefitListSupportedBenefitsParams? = null + private var items: Optional>? = null - items().map { it.validate() } - validated = true + @JvmSynthetic + internal fun from( + hrisBenefitListSupportedBenefitsPage: HrisBenefitListSupportedBenefitsPage + ) = apply { + service = hrisBenefitListSupportedBenefitsPage.service + params = hrisBenefitListSupportedBenefitsPage.params + items = Optional.of(hrisBenefitListSupportedBenefitsPage.items) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) + fun service(service: BenefitService) = apply { this.service = service } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitListSupportedBenefitsParams) = apply { this.params = params } - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + /** The response that this page was parsed from. */ + fun items(items: Optional>) = apply { + this.items = items } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisBenefitListSupportedBenefitsPage]. - */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisBenefitListSupportedBenefitsPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisBenefitListSupportedBenefitsPage = + HrisBenefitListSupportedBenefitsPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items).getOrNull() ?: emptyList(), + ) } class AutoPager(private val firstPage: HrisBenefitListSupportedBenefitsPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -179,8 +114,21 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisBenefitListSupportedBenefitsPage && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "HrisBenefitListSupportedBenefitsPage{service=$service, params=$params, items=$items}" } 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 b839cb7a..859239d8 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 @@ -2,17 +2,8 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.BenefitServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -20,161 +11,105 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** Get deductions metadata */ +/** @see [BenefitServiceAsync.listSupportedBenefits] */ class HrisBenefitListSupportedBenefitsPageAsync private constructor( - private val benefitsService: BenefitServiceAsync, + private val service: BenefitServiceAsync, private val params: HrisBenefitListSupportedBenefitsParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitListSupportedBenefitsPageAsync && benefitsService == other.benefitsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisBenefitListSupportedBenefitsPageAsync{benefitsService=$benefitsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { benefitsService.listSupportedBenefits(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.listSupportedBenefits(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - benefitsService: BenefitServiceAsync, - params: HrisBenefitListSupportedBenefitsParams, - response: Response, - ) = HrisBenefitListSupportedBenefitsPageAsync(benefitsService, params, response) - } - - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitListSupportedBenefitsParams = params - private var validated: Boolean = false + /** The response that this page was parsed from. */ + fun items(): List = items - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - items().map { it.validate() } - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitListSupportedBenefitsPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [HrisBenefitListSupportedBenefitsPageAsync]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var service: BenefitServiceAsync? = null + private var params: HrisBenefitListSupportedBenefitsParams? = null + private var items: Optional>? = null - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from( + hrisBenefitListSupportedBenefitsPageAsync: HrisBenefitListSupportedBenefitsPageAsync + ) = apply { + service = hrisBenefitListSupportedBenefitsPageAsync.service + params = hrisBenefitListSupportedBenefitsPageAsync.params + items = Optional.of(hrisBenefitListSupportedBenefitsPageAsync.items) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" + fun service(service: BenefitServiceAsync) = apply { this.service = service } - companion object { + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitListSupportedBenefitsParams) = apply { this.params = params } - /** - * Returns a mutable builder for constructing an instance of - * [HrisBenefitListSupportedBenefitsPageAsync]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun items(items: Optional>) = apply { + this.items = items } - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisBenefitListSupportedBenefitsPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisBenefitListSupportedBenefitsPageAsync = + HrisBenefitListSupportedBenefitsPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items).getOrNull() ?: emptyList(), + ) } class AutoPager(private val firstPage: HrisBenefitListSupportedBenefitsPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (SupportedBenefit) -> Boolean, + action: (BenefitListSupportedBenefitsResponse) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -190,9 +125,24 @@ private constructor( .forEach(action::test, executor) } - fun toList(executor: Executor): CompletableFuture> { - val values = mutableListOf() + fun toList( + executor: Executor + ): CompletableFuture> { + val values = mutableListOf() return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisBenefitListSupportedBenefitsPageAsync && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "HrisBenefitListSupportedBenefitsPageAsync{service=$service, params=$params, items=$items}" } 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 fc858012..00bcd8fa 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 @@ -2,176 +2,110 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.company.PayStatementItemService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * **Beta:** this endpoint currently serves employers onboarded after March 4th and historical - * support will be added soon Retrieve a list of detailed pay statement items for the access token's - * connection account. - */ +/** @see [PayStatementItemService.list] */ class HrisCompanyPayStatementItemListPage private constructor( - private val payStatementItemService: PayStatementItemService, + private val service: PayStatementItemService, private val params: HrisCompanyPayStatementItemListParams, - private val response: Response, + private val response: HrisCompanyPayStatementItemListPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisCompanyPayStatementItemListPageResponse], but gracefully handles missing + * data. + * + * @see [HrisCompanyPayStatementItemListPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisCompanyPayStatementItemListPage && payStatementItemService == other.payStatementItemService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payStatementItemService, params, response) /* spotless:on */ + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } - override fun toString() = - "HrisCompanyPayStatementItemListPage{payStatementItemService=$payStatementItemService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisCompanyPayStatementItemListParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { payStatementItemService.list(it) } - } + /** The response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemListPageResponse = response - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of( - payStatementItemService: PayStatementItemService, - params: HrisCompanyPayStatementItemListParams, - response: Response, - ) = HrisCompanyPayStatementItemListPage(payStatementItemService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisCompanyPayStatementItemListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** A builder for [HrisCompanyPayStatementItemListPage]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) + private var service: PayStatementItemService? = null + private var params: HrisCompanyPayStatementItemListParams? = null + private var response: HrisCompanyPayStatementItemListPageResponse? = null - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - responses().map { it.validate() } - validated = true + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemListPage: HrisCompanyPayStatementItemListPage + ) = apply { + service = hrisCompanyPayStatementItemListPage.service + params = hrisCompanyPayStatementItemListPage.params + response = hrisCompanyPayStatementItemListPage.response } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) + fun service(service: PayStatementItemService) = apply { this.service = service } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The parameters that were used to request this page. */ + fun params(params: HrisCompanyPayStatementItemListParams) = apply { this.params = params } - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + /** The response that this page was parsed from. */ + fun response(response: HrisCompanyPayStatementItemListPageResponse) = apply { + this.response = response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisCompanyPayStatementItemListPage]. - */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = - responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisCompanyPayStatementItemListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisCompanyPayStatementItemListPage = + HrisCompanyPayStatementItemListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisCompanyPayStatementItemListPage) : @@ -193,4 +127,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisCompanyPayStatementItemListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisCompanyPayStatementItemListPage{service=$service, params=$params, response=$response}" } 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 5963daa3..8a50507b 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 @@ -2,17 +2,8 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.company.PayStatementItemServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -20,161 +11,104 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * **Beta:** this endpoint currently serves employers onboarded after March 4th and historical - * support will be added soon Retrieve a list of detailed pay statement items for the access token's - * connection account. - */ +/** @see [PayStatementItemServiceAsync.list] */ class HrisCompanyPayStatementItemListPageAsync private constructor( - private val payStatementItemService: PayStatementItemServiceAsync, + private val service: PayStatementItemServiceAsync, private val params: HrisCompanyPayStatementItemListParams, - private val response: Response, + private val response: HrisCompanyPayStatementItemListPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisCompanyPayStatementItemListPageResponse], but gracefully handles missing + * data. + * + * @see [HrisCompanyPayStatementItemListPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisCompanyPayStatementItemListPageAsync && payStatementItemService == other.payStatementItemService && params == other.params && response == other.response /* spotless:on */ - } + fun getNextPageParams(): Optional = Optional.empty() - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payStatementItemService, params, response) /* spotless:on */ - - override fun toString() = - "HrisCompanyPayStatementItemListPageAsync{payStatementItemService=$payStatementItemService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { payStatementItemService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - payStatementItemService: PayStatementItemServiceAsync, - params: HrisCompanyPayStatementItemListParams, - response: Response, - ) = HrisCompanyPayStatementItemListPageAsync(payStatementItemService, params, response) - } - - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) - - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The parameters that were used to request this page. */ + fun params(): HrisCompanyPayStatementItemListParams = params - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemListPageResponse = response - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - fun validate(): Response = apply { - if (validated) { - return@apply - } - - responses().map { it.validate() } - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisCompanyPayStatementItemListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [HrisCompanyPayStatementItemListPageAsync]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var service: PayStatementItemServiceAsync? = null + private var params: HrisCompanyPayStatementItemListParams? = null + private var response: HrisCompanyPayStatementItemListPageResponse? = null - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemListPageAsync: HrisCompanyPayStatementItemListPageAsync + ) = apply { + service = hrisCompanyPayStatementItemListPageAsync.service + params = hrisCompanyPayStatementItemListPageAsync.params + response = hrisCompanyPayStatementItemListPageAsync.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" + fun service(service: PayStatementItemServiceAsync) = apply { this.service = service } - companion object { + /** The parameters that were used to request this page. */ + fun params(params: HrisCompanyPayStatementItemListParams) = apply { this.params = params } - /** - * Returns a mutable builder for constructing an instance of - * [HrisCompanyPayStatementItemListPageAsync]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun response(response: HrisCompanyPayStatementItemListPageResponse) = apply { + this.response = response } - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = - responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisCompanyPayStatementItemListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisCompanyPayStatementItemListPageAsync = + HrisCompanyPayStatementItemListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisCompanyPayStatementItemListPageAsync) { @@ -205,4 +139,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisCompanyPayStatementItemListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisCompanyPayStatementItemListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponse.kt new file mode 100644 index 00000000..fce8dcaf --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponse.kt @@ -0,0 +1,199 @@ +// 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.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class HrisCompanyPayStatementItemListPageResponse +private constructor( + private val responses: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("responses") + @ExcludeMissing + responses: JsonField> = JsonMissing.of() + ) : this(responses, 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 responses(): List = responses.getRequired("responses") + + /** + * Returns the raw JSON value of [responses]. + * + * Unlike [responses], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("responses") + @ExcludeMissing + fun _responses(): JsonField> = responses + + @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 + * [HrisCompanyPayStatementItemListPageResponse]. + * + * The following fields are required: + * ```java + * .responses() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisCompanyPayStatementItemListPageResponse]. */ + class Builder internal constructor() { + + private var responses: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemListPageResponse: HrisCompanyPayStatementItemListPageResponse + ) = apply { + responses = + hrisCompanyPayStatementItemListPageResponse.responses.map { it.toMutableList() } + additionalProperties = + hrisCompanyPayStatementItemListPageResponse.additionalProperties.toMutableMap() + } + + fun responses(responses: List) = + responses(JsonField.of(responses)) + + /** + * Sets [Builder.responses] to an arbitrary JSON value. + * + * You should usually call [Builder.responses] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun responses(responses: JsonField>) = apply { + this.responses = responses.map { it.toMutableList() } + } + + /** + * Adds a single [PayStatementItemListResponse] to [responses]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponse(response: PayStatementItemListResponse) = apply { + responses = + (responses ?: JsonField.of(mutableListOf())).also { + checkKnown("responses", it).add(response) + } + } + + 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 [HrisCompanyPayStatementItemListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .responses() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisCompanyPayStatementItemListPageResponse = + HrisCompanyPayStatementItemListPageResponse( + checkRequired("responses", responses).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HrisCompanyPayStatementItemListPageResponse = apply { + if (validated) { + return@apply + } + + responses().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 = + (responses.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisCompanyPayStatementItemListPageResponse && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(responses, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HrisCompanyPayStatementItemListPageResponse{responses=$responses, additionalProperties=$additionalProperties}" +} 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 cbc32bc7..cb2c5147 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 @@ -2,174 +2,112 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.company.payStatementItem.RuleService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * **Beta:** this endpoint currently serves employers onboarded after March 4th and historical - * support will be added soon List all rules of a connection account. - */ +/** @see [RuleService.list] */ class HrisCompanyPayStatementItemRuleListPage private constructor( - private val rulesService: RuleService, + private val service: RuleService, private val params: HrisCompanyPayStatementItemRuleListParams, - private val response: Response, + private val response: HrisCompanyPayStatementItemRuleListPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisCompanyPayStatementItemRuleListPageResponse], but gracefully handles + * missing data. + * + * @see [HrisCompanyPayStatementItemRuleListPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisCompanyPayStatementItemRuleListPage && rulesService == other.rulesService && params == other.params && response == other.response /* spotless:on */ - } + fun getNextPageParams(): Optional = Optional.empty() - override fun hashCode(): Int = /* spotless:off */ Objects.hash(rulesService, params, response) /* spotless:on */ + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } - override fun toString() = - "HrisCompanyPayStatementItemRuleListPage{rulesService=$rulesService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisCompanyPayStatementItemRuleListParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { rulesService.list(it) } - } + /** The response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemRuleListPageResponse = response - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of( - rulesService: RuleService, - params: HrisCompanyPayStatementItemRuleListParams, - response: Response, - ) = HrisCompanyPayStatementItemRuleListPage(rulesService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisCompanyPayStatementItemRuleListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) - - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false + /** A builder for [HrisCompanyPayStatementItemRuleListPage]. */ + class Builder internal constructor() { - fun validate(): Response = apply { - if (validated) { - return@apply - } + private var service: RuleService? = null + private var params: HrisCompanyPayStatementItemRuleListParams? = null + private var response: HrisCompanyPayStatementItemRuleListPageResponse? = null - responses().map { it.validate() } - validated = true + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemRuleListPage: HrisCompanyPayStatementItemRuleListPage + ) = apply { + service = hrisCompanyPayStatementItemRuleListPage.service + params = hrisCompanyPayStatementItemRuleListPage.params + response = hrisCompanyPayStatementItemRuleListPage.response } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun service(service: RuleService) = apply { this.service = service } - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + /** The parameters that were used to request this page. */ + fun params(params: HrisCompanyPayStatementItemRuleListParams) = apply { + this.params = params } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisCompanyPayStatementItemRuleListPage]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun response(response: HrisCompanyPayStatementItemRuleListPageResponse) = apply { + this.response = response } - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisCompanyPayStatementItemRuleListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisCompanyPayStatementItemRuleListPage = + HrisCompanyPayStatementItemRuleListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisCompanyPayStatementItemRuleListPage) : @@ -191,4 +129,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisCompanyPayStatementItemRuleListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisCompanyPayStatementItemRuleListPage{service=$service, params=$params, response=$response}" } 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 9b3f21e3..269318ac 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 @@ -2,17 +2,8 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.company.payStatementItem.RuleServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -20,159 +11,107 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * **Beta:** this endpoint currently serves employers onboarded after March 4th and historical - * support will be added soon List all rules of a connection account. - */ +/** @see [RuleServiceAsync.list] */ class HrisCompanyPayStatementItemRuleListPageAsync private constructor( - private val rulesService: RuleServiceAsync, + private val service: RuleServiceAsync, private val params: HrisCompanyPayStatementItemRuleListParams, - private val response: Response, + private val response: HrisCompanyPayStatementItemRuleListPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisCompanyPayStatementItemRuleListPageResponse], but gracefully handles + * missing data. + * + * @see [HrisCompanyPayStatementItemRuleListPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisCompanyPayStatementItemRuleListPageAsync && rulesService == other.rulesService && params == other.params && response == other.response /* spotless:on */ - } + fun getNextPageParams(): Optional = Optional.empty() - override fun hashCode(): Int = /* spotless:off */ Objects.hash(rulesService, params, response) /* spotless:on */ - - override fun toString() = - "HrisCompanyPayStatementItemRuleListPageAsync{rulesService=$rulesService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { rulesService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - rulesService: RuleServiceAsync, - params: HrisCompanyPayStatementItemRuleListParams, - response: Response, - ) = HrisCompanyPayStatementItemRuleListPageAsync(rulesService, params, response) - } - - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** The parameters that were used to request this page. */ + fun params(): HrisCompanyPayStatementItemRuleListParams = params - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) + /** The response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemRuleListPageResponse = response - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() + fun toBuilder() = Builder().from(this) - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false + companion object { - fun validate(): Response = apply { - if (validated) { - return@apply - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisCompanyPayStatementItemRuleListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - responses().map { it.validate() } - validated = true + /** A builder for [HrisCompanyPayStatementItemRuleListPageAsync]. */ + class Builder internal constructor() { + + private var service: RuleServiceAsync? = null + private var params: HrisCompanyPayStatementItemRuleListParams? = null + private var response: HrisCompanyPayStatementItemRuleListPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemRuleListPageAsync: + HrisCompanyPayStatementItemRuleListPageAsync + ) = apply { + service = hrisCompanyPayStatementItemRuleListPageAsync.service + params = hrisCompanyPayStatementItemRuleListPageAsync.params + response = hrisCompanyPayStatementItemRuleListPageAsync.response } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun service(service: RuleServiceAsync) = apply { this.service = service } - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + /** The parameters that were used to request this page. */ + fun params(params: HrisCompanyPayStatementItemRuleListParams) = apply { + this.params = params } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisCompanyPayStatementItemRuleListPageAsync]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun response(response: HrisCompanyPayStatementItemRuleListPageResponse) = apply { + this.response = response } - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisCompanyPayStatementItemRuleListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisCompanyPayStatementItemRuleListPageAsync = + HrisCompanyPayStatementItemRuleListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisCompanyPayStatementItemRuleListPageAsync) { @@ -203,4 +142,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisCompanyPayStatementItemRuleListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisCompanyPayStatementItemRuleListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponse.kt new file mode 100644 index 00000000..9f80a3dd --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponse.kt @@ -0,0 +1,199 @@ +// 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.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class HrisCompanyPayStatementItemRuleListPageResponse +private constructor( + private val responses: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("responses") + @ExcludeMissing + responses: JsonField> = JsonMissing.of() + ) : this(responses, 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 responses(): List = responses.getRequired("responses") + + /** + * Returns the raw JSON value of [responses]. + * + * Unlike [responses], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("responses") + @ExcludeMissing + fun _responses(): JsonField> = responses + + @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 + * [HrisCompanyPayStatementItemRuleListPageResponse]. + * + * The following fields are required: + * ```java + * .responses() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisCompanyPayStatementItemRuleListPageResponse]. */ + class Builder internal constructor() { + + private var responses: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemRuleListPageResponse: + HrisCompanyPayStatementItemRuleListPageResponse + ) = apply { + responses = + hrisCompanyPayStatementItemRuleListPageResponse.responses.map { it.toMutableList() } + additionalProperties = + hrisCompanyPayStatementItemRuleListPageResponse.additionalProperties.toMutableMap() + } + + fun responses(responses: List) = responses(JsonField.of(responses)) + + /** + * Sets [Builder.responses] to an arbitrary JSON value. + * + * You should usually call [Builder.responses] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun responses(responses: JsonField>) = apply { + this.responses = responses.map { it.toMutableList() } + } + + /** + * Adds a single [RuleListResponse] to [responses]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponse(response: RuleListResponse) = apply { + responses = + (responses ?: JsonField.of(mutableListOf())).also { + checkKnown("responses", it).add(response) + } + } + + 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 [HrisCompanyPayStatementItemRuleListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .responses() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisCompanyPayStatementItemRuleListPageResponse = + HrisCompanyPayStatementItemRuleListPageResponse( + checkRequired("responses", responses).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HrisCompanyPayStatementItemRuleListPageResponse = apply { + if (validated) { + return@apply + } + + responses().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 = + (responses.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisCompanyPayStatementItemRuleListPageResponse && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(responses, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HrisCompanyPayStatementItemRuleListPageResponse{responses=$responses, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt index 3e7dd7da..eeafc093 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt @@ -2,58 +2,48 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.DirectoryService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrDefault import kotlin.jvm.optionals.getOrNull -/** Read company directory and organization structure */ +/** @see [DirectoryService.listIndividuals] */ @Deprecated("use `list` instead") class HrisDirectoryListIndividualsPage private constructor( - private val directoryService: DirectoryService, + private val service: DirectoryService, private val params: HrisDirectoryListIndividualsParams, - private val response: Response, + private val response: HrisDirectoryListIndividualsPageResponse, ) { - fun response(): Response = response - - fun individuals(): List = response().individuals() - - fun paging(): Paging = response().paging() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisDirectoryListIndividualsPage && directoryService == other.directoryService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(directoryService, params, response) /* spotless:on */ - - override fun toString() = - "HrisDirectoryListIndividualsPage{directoryService=$directoryService, params=$params, response=$response}" + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListIndividualsPageResponse.individuals] + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() + + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListIndividualsPageResponse.paging] + */ + fun paging(): Optional = response._paging().getOptional("paging") fun hasNextPage(): Boolean { if (individuals().isEmpty()) { return false } - return paging().offset().orElse(0) + individuals().count() < - paging().count().orElse(Long.MAX_VALUE) + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + val totalCount = + paging().flatMap { it._count().getOptional("count") }.getOrDefault(Long.MAX_VALUE) + return offset + individuals().size < totalCount } fun getNextPageParams(): Optional { @@ -61,145 +51,84 @@ private constructor( return Optional.empty() } - return Optional.of( - HrisDirectoryListIndividualsParams.builder() - .from(params) - .offset(paging().offset().orElse(0) + individuals().count()) - .build() - ) + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + return Optional.of(params.toBuilder().offset(offset + individuals().size).build()) } - fun getNextPage(): Optional { - return getNextPageParams().map { directoryService.listIndividuals(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.listIndividuals(it) } fun autoPager(): AutoPager = AutoPager(this) - companion object { + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListIndividualsParams = params - @JvmStatic - fun of( - directoryService: DirectoryService, - params: HrisDirectoryListIndividualsParams, - response: Response, - ) = HrisDirectoryListIndividualsPage(directoryService, params, response) - } - - class Response( - private val individuals: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("individuals") - individuals: JsonField> = JsonMissing.of(), - @JsonProperty("paging") paging: JsonField = JsonMissing.of(), - ) : this(individuals, paging, mutableMapOf()) - - fun individuals(): List = - individuals.getOptional("individuals").getOrNull() ?: listOf() + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListIndividualsPageResponse = response - fun paging(): Paging = paging.getRequired("paging") + fun toBuilder() = Builder().from(this) - @JsonProperty("individuals") - fun _individuals(): Optional>> = - Optional.ofNullable(individuals) - - @JsonProperty("paging") - fun _paging(): Optional> = Optional.ofNullable(paging) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } + companion object { - individuals().map { it.validate() } - paging().validate() - validated = true - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisDirectoryListIndividualsPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** A builder for [HrisDirectoryListIndividualsPage]. */ + class Builder internal constructor() { - fun toBuilder() = Builder().from(this) + private var service: DirectoryService? = null + private var params: HrisDirectoryListIndividualsParams? = null + private var response: HrisDirectoryListIndividualsPageResponse? = null - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + @JvmSynthetic + internal fun from(hrisDirectoryListIndividualsPage: HrisDirectoryListIndividualsPage) = + apply { + service = hrisDirectoryListIndividualsPage.service + params = hrisDirectoryListIndividualsPage.params + response = hrisDirectoryListIndividualsPage.response } - return /* spotless:off */ other is Response && individuals == other.individuals && paging == other.paging && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individuals, paging, additionalProperties) /* spotless:on */ + fun service(service: DirectoryService) = apply { this.service = service } - override fun toString() = - "Response{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" + /** The parameters that were used to request this page. */ + fun params(params: HrisDirectoryListIndividualsParams) = apply { this.params = params } - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisDirectoryListIndividualsPage]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun response(response: HrisDirectoryListIndividualsPageResponse) = apply { + this.response = response } - class Builder { - - private var individuals: JsonField> = JsonMissing.of() - private var paging: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.individuals = page.individuals - this.paging = page.paging - this.additionalProperties.putAll(page.additionalProperties) - } - - fun individuals(individuals: List) = - individuals(JsonField.of(individuals)) - - fun individuals(individuals: JsonField>) = apply { - this.individuals = individuals - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = - Response(individuals, paging, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisDirectoryListIndividualsPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisDirectoryListIndividualsPage = + HrisDirectoryListIndividualsPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisDirectoryListIndividualsPage) : @@ -221,4 +150,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisDirectoryListIndividualsPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisDirectoryListIndividualsPage{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt index cf3abdf6..e7480379 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt @@ -2,59 +2,49 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.DirectoryServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrDefault import kotlin.jvm.optionals.getOrNull -/** Read company directory and organization structure */ +/** @see [DirectoryServiceAsync.listIndividuals] */ @Deprecated("use `list` instead") class HrisDirectoryListIndividualsPageAsync private constructor( - private val directoryService: DirectoryServiceAsync, + private val service: DirectoryServiceAsync, private val params: HrisDirectoryListIndividualsParams, - private val response: Response, + private val response: HrisDirectoryListIndividualsPageResponse, ) { - fun response(): Response = response - - fun individuals(): List = response().individuals() - - fun paging(): Paging = response().paging() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisDirectoryListIndividualsPageAsync && directoryService == other.directoryService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(directoryService, params, response) /* spotless:on */ - - override fun toString() = - "HrisDirectoryListIndividualsPageAsync{directoryService=$directoryService, params=$params, response=$response}" + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListIndividualsPageResponse.individuals] + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() + + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListIndividualsPageResponse.paging] + */ + fun paging(): Optional = response._paging().getOptional("paging") fun hasNextPage(): Boolean { if (individuals().isEmpty()) { return false } - return paging().offset().orElse(0) + individuals().count() < - paging().count().orElse(Long.MAX_VALUE) + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + val totalCount = + paging().flatMap { it._count().getOptional("count") }.getOrDefault(Long.MAX_VALUE) + return offset + individuals().size < totalCount } fun getNextPageParams(): Optional { @@ -62,147 +52,87 @@ private constructor( return Optional.empty() } - return Optional.of( - HrisDirectoryListIndividualsParams.builder() - .from(params) - .offset(paging().offset().orElse(0) + individuals().count()) - .build() - ) + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + return Optional.of(params.toBuilder().offset(offset + individuals().size).build()) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { directoryService.listIndividuals(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.listIndividuals(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - directoryService: DirectoryServiceAsync, - params: HrisDirectoryListIndividualsParams, - response: Response, - ) = HrisDirectoryListIndividualsPageAsync(directoryService, params, response) - } - - class Response( - private val individuals: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("individuals") - individuals: JsonField> = JsonMissing.of(), - @JsonProperty("paging") paging: JsonField = JsonMissing.of(), - ) : this(individuals, paging, mutableMapOf()) - - fun individuals(): List = - individuals.getOptional("individuals").getOrNull() ?: listOf() - - fun paging(): Paging = paging.getRequired("paging") - - @JsonProperty("individuals") - fun _individuals(): Optional>> = - Optional.ofNullable(individuals) - - @JsonProperty("paging") - fun _paging(): Optional> = Optional.ofNullable(paging) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListIndividualsParams = params - private var validated: Boolean = false + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListIndividualsPageResponse = response - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - individuals().map { it.validate() } - paging().validate() - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisDirectoryListIndividualsPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [HrisDirectoryListIndividualsPageAsync]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var service: DirectoryServiceAsync? = null + private var params: HrisDirectoryListIndividualsParams? = null + private var response: HrisDirectoryListIndividualsPageResponse? = null - return /* spotless:off */ other is Response && individuals == other.individuals && paging == other.paging && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from( + hrisDirectoryListIndividualsPageAsync: HrisDirectoryListIndividualsPageAsync + ) = apply { + service = hrisDirectoryListIndividualsPageAsync.service + params = hrisDirectoryListIndividualsPageAsync.params + response = hrisDirectoryListIndividualsPageAsync.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individuals, paging, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" + fun service(service: DirectoryServiceAsync) = apply { this.service = service } - companion object { + /** The parameters that were used to request this page. */ + fun params(params: HrisDirectoryListIndividualsParams) = apply { this.params = params } - /** - * Returns a mutable builder for constructing an instance of - * [HrisDirectoryListIndividualsPageAsync]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun response(response: HrisDirectoryListIndividualsPageResponse) = apply { + this.response = response } - class Builder { - - private var individuals: JsonField> = JsonMissing.of() - private var paging: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.individuals = page.individuals - this.paging = page.paging - this.additionalProperties.putAll(page.additionalProperties) - } - - fun individuals(individuals: List) = - individuals(JsonField.of(individuals)) - - fun individuals(individuals: JsonField>) = apply { - this.individuals = individuals - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = - Response(individuals, paging, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisDirectoryListIndividualsPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisDirectoryListIndividualsPageAsync = + HrisDirectoryListIndividualsPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisDirectoryListIndividualsPageAsync) { @@ -233,4 +163,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisDirectoryListIndividualsPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisDirectoryListIndividualsPageAsync{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt new file mode 100644 index 00000000..beff2dd6 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt @@ -0,0 +1,234 @@ +// 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.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class HrisDirectoryListIndividualsPageResponse +private constructor( + private val individuals: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("individuals") + @ExcludeMissing + individuals: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(individuals, paging, mutableMapOf()) + + /** + * The array of employees. + * + * @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 individuals(): List = individuals.getRequired("individuals") + + /** + * @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(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [individuals]. + * + * Unlike [individuals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("individuals") + @ExcludeMissing + fun _individuals(): JsonField> = individuals + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisDirectoryListIndividualsPageResponse]. + * + * The following fields are required: + * ```java + * .individuals() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisDirectoryListIndividualsPageResponse]. */ + class Builder internal constructor() { + + private var individuals: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + hrisDirectoryListIndividualsPageResponse: HrisDirectoryListIndividualsPageResponse + ) = apply { + individuals = + hrisDirectoryListIndividualsPageResponse.individuals.map { it.toMutableList() } + paging = hrisDirectoryListIndividualsPageResponse.paging + additionalProperties = + hrisDirectoryListIndividualsPageResponse.additionalProperties.toMutableMap() + } + + /** The array of employees. */ + fun individuals(individuals: List) = + individuals(JsonField.of(individuals)) + + /** + * Sets [Builder.individuals] to an arbitrary JSON value. + * + * You should usually call [Builder.individuals] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun individuals(individuals: JsonField>) = apply { + this.individuals = individuals.map { it.toMutableList() } + } + + /** + * Adds a single [IndividualInDirectory] to [individuals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIndividual(individual: IndividualInDirectory) = apply { + individuals = + (individuals ?: JsonField.of(mutableListOf())).also { + checkKnown("individuals", it).add(individual) + } + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [HrisDirectoryListIndividualsPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .individuals() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisDirectoryListIndividualsPageResponse = + HrisDirectoryListIndividualsPageResponse( + checkRequired("individuals", individuals).map { it.toImmutable() }, + checkRequired("paging", paging), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HrisDirectoryListIndividualsPageResponse = apply { + if (validated) { + return@apply + } + + individuals().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (individuals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisDirectoryListIndividualsPageResponse && individuals == other.individuals && paging == other.paging && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(individuals, paging, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HrisDirectoryListIndividualsPageResponse{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt index 7f5dcd14..36eff6a0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt @@ -2,57 +2,47 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.DirectoryService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport +import kotlin.jvm.optionals.getOrDefault import kotlin.jvm.optionals.getOrNull -/** Read company directory and organization structure */ +/** @see [DirectoryService.list] */ class HrisDirectoryListPage private constructor( - private val directoryService: DirectoryService, + private val service: DirectoryService, private val params: HrisDirectoryListParams, - private val response: Response, + private val response: HrisDirectoryListPageResponse, ) { - fun response(): Response = response - - fun individuals(): List = response().individuals() - - fun paging(): Paging = response().paging() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisDirectoryListPage && directoryService == other.directoryService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(directoryService, params, response) /* spotless:on */ - - override fun toString() = - "HrisDirectoryListPage{directoryService=$directoryService, params=$params, response=$response}" + /** + * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListPageResponse.individuals] + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() + + /** + * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListPageResponse.paging] + */ + fun paging(): Optional = response._paging().getOptional("paging") fun hasNextPage(): Boolean { if (individuals().isEmpty()) { return false } - return paging().offset().orElse(0) + individuals().count() < - paging().count().orElse(Long.MAX_VALUE) + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + val totalCount = + paging().flatMap { it._count().getOptional("count") }.getOrDefault(Long.MAX_VALUE) + return offset + individuals().size < totalCount } fun getNextPageParams(): Optional { @@ -60,144 +50,80 @@ private constructor( return Optional.empty() } - return Optional.of( - HrisDirectoryListParams.builder() - .from(params) - .offset(paging().offset().orElse(0) + individuals().count()) - .build() - ) + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + return Optional.of(params.toBuilder().offset(offset + individuals().size).build()) } - fun getNextPage(): Optional { - return getNextPageParams().map { directoryService.list(it) } - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - directoryService: DirectoryService, - params: HrisDirectoryListParams, - response: Response, - ) = HrisDirectoryListPage(directoryService, params, response) - } - - class Response( - private val individuals: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("individuals") - individuals: JsonField> = JsonMissing.of(), - @JsonProperty("paging") paging: JsonField = JsonMissing.of(), - ) : this(individuals, paging, mutableMapOf()) - - fun individuals(): List = - individuals.getOptional("individuals").getOrNull() ?: listOf() - - fun paging(): Paging = paging.getRequired("paging") - - @JsonProperty("individuals") - fun _individuals(): Optional>> = - Optional.ofNullable(individuals) - - @JsonProperty("paging") - fun _paging(): Optional> = Optional.ofNullable(paging) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - individuals().map { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListParams = params - fun toBuilder() = Builder().from(this) + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListPageResponse = response - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun toBuilder() = Builder().from(this) - return /* spotless:off */ other is Response && individuals == other.individuals && paging == other.paging && additionalProperties == other.additionalProperties /* spotless:on */ - } + companion object { - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individuals, paging, additionalProperties) /* spotless:on */ + /** + * Returns a mutable builder for constructing an instance of [HrisDirectoryListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun toString() = - "Response{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" + /** A builder for [HrisDirectoryListPage]. */ + class Builder internal constructor() { - companion object { + private var service: DirectoryService? = null + private var params: HrisDirectoryListParams? = null + private var response: HrisDirectoryListPageResponse? = null - /** - * Returns a mutable builder for constructing an instance of [HrisDirectoryListPage]. - */ - @JvmStatic fun builder() = Builder() + @JvmSynthetic + internal fun from(hrisDirectoryListPage: HrisDirectoryListPage) = apply { + service = hrisDirectoryListPage.service + params = hrisDirectoryListPage.params + response = hrisDirectoryListPage.response } - class Builder { - - private var individuals: JsonField> = JsonMissing.of() - private var paging: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.individuals = page.individuals - this.paging = page.paging - this.additionalProperties.putAll(page.additionalProperties) - } - - fun individuals(individuals: List) = - individuals(JsonField.of(individuals)) - - fun individuals(individuals: JsonField>) = apply { - this.individuals = individuals - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = - Response(individuals, paging, additionalProperties.toMutableMap()) - } + fun service(service: DirectoryService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisDirectoryListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisDirectoryListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [HrisDirectoryListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisDirectoryListPage = + HrisDirectoryListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisDirectoryListPage) : @@ -219,4 +145,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisDirectoryListPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisDirectoryListPage{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt index 44ea4e6e..bc8d9645 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt @@ -2,58 +2,48 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.DirectoryServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrDefault import kotlin.jvm.optionals.getOrNull -/** Read company directory and organization structure */ +/** @see [DirectoryServiceAsync.list] */ class HrisDirectoryListPageAsync private constructor( - private val directoryService: DirectoryServiceAsync, + private val service: DirectoryServiceAsync, private val params: HrisDirectoryListParams, - private val response: Response, + private val response: HrisDirectoryListPageResponse, ) { - fun response(): Response = response - - fun individuals(): List = response().individuals() - - fun paging(): Paging = response().paging() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisDirectoryListPageAsync && directoryService == other.directoryService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(directoryService, params, response) /* spotless:on */ - - override fun toString() = - "HrisDirectoryListPageAsync{directoryService=$directoryService, params=$params, response=$response}" + /** + * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListPageResponse.individuals] + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() + + /** + * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListPageResponse.paging] + */ + fun paging(): Optional = response._paging().getOptional("paging") fun hasNextPage(): Boolean { if (individuals().isEmpty()) { return false } - return paging().offset().orElse(0) + individuals().count() < - paging().count().orElse(Long.MAX_VALUE) + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + val totalCount = + paging().flatMap { it._count().getOptional("count") }.getOrDefault(Long.MAX_VALUE) + return offset + individuals().size < totalCount } fun getNextPageParams(): Optional { @@ -61,147 +51,82 @@ private constructor( return Optional.empty() } - return Optional.of( - HrisDirectoryListParams.builder() - .from(params) - .offset(paging().offset().orElse(0) + individuals().count()) - .build() - ) + val offset = paging().flatMap { it._offset().getOptional("offset") }.getOrDefault(0) + return Optional.of(params.toBuilder().offset(offset + individuals().size).build()) } - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { directoryService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - directoryService: DirectoryServiceAsync, - params: HrisDirectoryListParams, - response: Response, - ) = HrisDirectoryListPageAsync(directoryService, params, response) - } - - class Response( - private val individuals: JsonField>, - private val paging: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("individuals") - individuals: JsonField> = JsonMissing.of(), - @JsonProperty("paging") paging: JsonField = JsonMissing.of(), - ) : this(individuals, paging, mutableMapOf()) - - fun individuals(): List = - individuals.getOptional("individuals").getOrNull() ?: listOf() - - fun paging(): Paging = paging.getRequired("paging") - - @JsonProperty("individuals") - fun _individuals(): Optional>> = - Optional.ofNullable(individuals) - - @JsonProperty("paging") - fun _paging(): Optional> = Optional.ofNullable(paging) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListParams = params - fun validate(): Response = apply { - if (validated) { - return@apply - } + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListPageResponse = response - individuals().map { it.validate() } - paging().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun toBuilder() = Builder().from(this) - return /* spotless:off */ other is Response && individuals == other.individuals && paging == other.paging && additionalProperties == other.additionalProperties /* spotless:on */ - } + companion object { - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individuals, paging, additionalProperties) /* spotless:on */ + /** + * Returns a mutable builder for constructing an instance of [HrisDirectoryListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun toString() = - "Response{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" + /** A builder for [HrisDirectoryListPageAsync]. */ + class Builder internal constructor() { - companion object { + private var service: DirectoryServiceAsync? = null + private var params: HrisDirectoryListParams? = null + private var response: HrisDirectoryListPageResponse? = null - /** - * Returns a mutable builder for constructing an instance of - * [HrisDirectoryListPageAsync]. - */ - @JvmStatic fun builder() = Builder() + @JvmSynthetic + internal fun from(hrisDirectoryListPageAsync: HrisDirectoryListPageAsync) = apply { + service = hrisDirectoryListPageAsync.service + params = hrisDirectoryListPageAsync.params + response = hrisDirectoryListPageAsync.response } - class Builder { - - private var individuals: JsonField> = JsonMissing.of() - private var paging: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.individuals = page.individuals - this.paging = page.paging - this.additionalProperties.putAll(page.additionalProperties) - } - - fun individuals(individuals: List) = - individuals(JsonField.of(individuals)) - - fun individuals(individuals: JsonField>) = apply { - this.individuals = individuals - } - - fun paging(paging: Paging) = paging(JsonField.of(paging)) - - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = - Response(individuals, paging, additionalProperties.toMutableMap()) - } + fun service(service: DirectoryServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisDirectoryListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisDirectoryListPageResponse) = apply { this.response = response } + + /** + * Returns an immutable instance of [HrisDirectoryListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisDirectoryListPageAsync = + HrisDirectoryListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisDirectoryListPageAsync) { @@ -232,4 +157,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisDirectoryListPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisDirectoryListPageAsync{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponse.kt new file mode 100644 index 00000000..ff001b25 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponse.kt @@ -0,0 +1,230 @@ +// 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.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class HrisDirectoryListPageResponse +private constructor( + private val individuals: JsonField>, + private val paging: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("individuals") + @ExcludeMissing + individuals: JsonField> = JsonMissing.of(), + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + ) : this(individuals, paging, mutableMapOf()) + + /** + * The array of employees. + * + * @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 individuals(): List = individuals.getRequired("individuals") + + /** + * @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(): Paging = paging.getRequired("paging") + + /** + * Returns the raw JSON value of [individuals]. + * + * Unlike [individuals], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("individuals") + @ExcludeMissing + fun _individuals(): JsonField> = individuals + + /** + * Returns the raw JSON value of [paging]. + * + * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisDirectoryListPageResponse]. + * + * The following fields are required: + * ```java + * .individuals() + * .paging() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisDirectoryListPageResponse]. */ + class Builder internal constructor() { + + private var individuals: JsonField>? = null + private var paging: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(hrisDirectoryListPageResponse: HrisDirectoryListPageResponse) = apply { + individuals = hrisDirectoryListPageResponse.individuals.map { it.toMutableList() } + paging = hrisDirectoryListPageResponse.paging + additionalProperties = hrisDirectoryListPageResponse.additionalProperties.toMutableMap() + } + + /** The array of employees. */ + fun individuals(individuals: List) = + individuals(JsonField.of(individuals)) + + /** + * Sets [Builder.individuals] to an arbitrary JSON value. + * + * You should usually call [Builder.individuals] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun individuals(individuals: JsonField>) = apply { + this.individuals = individuals.map { it.toMutableList() } + } + + /** + * Adds a single [IndividualInDirectory] to [individuals]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addIndividual(individual: IndividualInDirectory) = apply { + individuals = + (individuals ?: JsonField.of(mutableListOf())).also { + checkKnown("individuals", it).add(individual) + } + } + + fun paging(paging: Paging) = paging(JsonField.of(paging)) + + /** + * Sets [Builder.paging] to an arbitrary JSON value. + * + * You should usually call [Builder.paging] with a well-typed [Paging] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun paging(paging: JsonField) = apply { this.paging = paging } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [HrisDirectoryListPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .individuals() + * .paging() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisDirectoryListPageResponse = + HrisDirectoryListPageResponse( + checkRequired("individuals", individuals).map { it.toImmutable() }, + checkRequired("paging", paging), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HrisDirectoryListPageResponse = apply { + if (validated) { + return@apply + } + + individuals().forEach { it.validate() } + paging().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (individuals.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (paging.asKnown().getOrNull()?.validity() ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisDirectoryListPageResponse && individuals == other.individuals && paging == other.paging && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(individuals, paging, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HrisDirectoryListPageResponse{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" +} 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 eae6a1f5..9987671a 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 @@ -2,172 +2,107 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.EmploymentService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** Read individual employment and income data */ +/** @see [EmploymentService.retrieveMany] */ class HrisEmploymentRetrieveManyPage private constructor( - private val employmentsService: EmploymentService, + private val service: EmploymentService, private val params: HrisEmploymentRetrieveManyParams, - private val response: Response, + private val response: HrisEmploymentRetrieveManyPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisEmploymentRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisEmploymentRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisEmploymentRetrieveManyPage && employmentsService == other.employmentsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(employmentsService, params, response) /* spotless:on */ + fun getNextPage(): Optional = + getNextPageParams().map { service.retrieveMany(it) } - override fun toString() = - "HrisEmploymentRetrieveManyPage{employmentsService=$employmentsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisEmploymentRetrieveManyParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { employmentsService.retrieveMany(it) } - } + /** The response that this page was parsed from. */ + fun response(): HrisEmploymentRetrieveManyPageResponse = response - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of( - employmentsService: EmploymentService, - params: HrisEmploymentRetrieveManyParams, - response: Response, - ) = HrisEmploymentRetrieveManyPage(employmentsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisEmploymentRetrieveManyPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** A builder for [HrisEmploymentRetrieveManyPage]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) + private var service: EmploymentService? = null + private var params: HrisEmploymentRetrieveManyParams? = null + private var response: HrisEmploymentRetrieveManyPageResponse? = null - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - responses().map { it.validate() } - validated = true + @JvmSynthetic + internal fun from(hrisEmploymentRetrieveManyPage: HrisEmploymentRetrieveManyPage) = apply { + service = hrisEmploymentRetrieveManyPage.service + params = hrisEmploymentRetrieveManyPage.params + response = hrisEmploymentRetrieveManyPage.response } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) + fun service(service: EmploymentService) = apply { this.service = service } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The parameters that were used to request this page. */ + fun params(params: HrisEmploymentRetrieveManyParams) = apply { this.params = params } - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + /** The response that this page was parsed from. */ + fun response(response: HrisEmploymentRetrieveManyPageResponse) = apply { + this.response = response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisEmploymentRetrieveManyPage]. - */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = - responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisEmploymentRetrieveManyPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisEmploymentRetrieveManyPage = + HrisEmploymentRetrieveManyPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisEmploymentRetrieveManyPage) : @@ -189,4 +124,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisEmploymentRetrieveManyPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisEmploymentRetrieveManyPage{service=$service, params=$params, response=$response}" } 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 b786e90f..83f3ed95 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 @@ -2,17 +2,8 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.EmploymentServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -20,157 +11,103 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** Read individual employment and income data */ +/** @see [EmploymentServiceAsync.retrieveMany] */ class HrisEmploymentRetrieveManyPageAsync private constructor( - private val employmentsService: EmploymentServiceAsync, + private val service: EmploymentServiceAsync, private val params: HrisEmploymentRetrieveManyParams, - private val response: Response, + private val response: HrisEmploymentRetrieveManyPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisEmploymentRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisEmploymentRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisEmploymentRetrieveManyPageAsync && employmentsService == other.employmentsService && params == other.params && response == other.response /* spotless:on */ - } + fun getNextPageParams(): Optional = Optional.empty() - override fun hashCode(): Int = /* spotless:off */ Objects.hash(employmentsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisEmploymentRetrieveManyPageAsync{employmentsService=$employmentsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { employmentsService.retrieveMany(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.retrieveMany(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - employmentsService: EmploymentServiceAsync, - params: HrisEmploymentRetrieveManyParams, - response: Response, - ) = HrisEmploymentRetrieveManyPageAsync(employmentsService, params, response) - } - - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) - - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The parameters that were used to request this page. */ + fun params(): HrisEmploymentRetrieveManyParams = params - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The response that this page was parsed from. */ + fun response(): HrisEmploymentRetrieveManyPageResponse = response - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - fun validate(): Response = apply { - if (validated) { - return@apply - } - - responses().map { it.validate() } - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisEmploymentRetrieveManyPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [HrisEmploymentRetrieveManyPageAsync]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var service: EmploymentServiceAsync? = null + private var params: HrisEmploymentRetrieveManyParams? = null + private var response: HrisEmploymentRetrieveManyPageResponse? = null - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from( + hrisEmploymentRetrieveManyPageAsync: HrisEmploymentRetrieveManyPageAsync + ) = apply { + service = hrisEmploymentRetrieveManyPageAsync.service + params = hrisEmploymentRetrieveManyPageAsync.params + response = hrisEmploymentRetrieveManyPageAsync.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" + fun service(service: EmploymentServiceAsync) = apply { this.service = service } - companion object { + /** The parameters that were used to request this page. */ + fun params(params: HrisEmploymentRetrieveManyParams) = apply { this.params = params } - /** - * Returns a mutable builder for constructing an instance of - * [HrisEmploymentRetrieveManyPageAsync]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun response(response: HrisEmploymentRetrieveManyPageResponse) = apply { + this.response = response } - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = - responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisEmploymentRetrieveManyPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisEmploymentRetrieveManyPageAsync = + HrisEmploymentRetrieveManyPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisEmploymentRetrieveManyPageAsync) { @@ -201,4 +138,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisEmploymentRetrieveManyPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisEmploymentRetrieveManyPageAsync{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponse.kt new file mode 100644 index 00000000..aa5e9e40 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponse.kt @@ -0,0 +1,197 @@ +// 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.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class HrisEmploymentRetrieveManyPageResponse +private constructor( + private val responses: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("responses") + @ExcludeMissing + responses: JsonField> = JsonMissing.of() + ) : this(responses, 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 responses(): List = responses.getRequired("responses") + + /** + * Returns the raw JSON value of [responses]. + * + * Unlike [responses], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("responses") + @ExcludeMissing + fun _responses(): JsonField> = responses + + @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 + * [HrisEmploymentRetrieveManyPageResponse]. + * + * The following fields are required: + * ```java + * .responses() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisEmploymentRetrieveManyPageResponse]. */ + class Builder internal constructor() { + + private var responses: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + hrisEmploymentRetrieveManyPageResponse: HrisEmploymentRetrieveManyPageResponse + ) = apply { + responses = hrisEmploymentRetrieveManyPageResponse.responses.map { it.toMutableList() } + additionalProperties = + hrisEmploymentRetrieveManyPageResponse.additionalProperties.toMutableMap() + } + + fun responses(responses: List) = responses(JsonField.of(responses)) + + /** + * Sets [Builder.responses] to an arbitrary JSON value. + * + * You should usually call [Builder.responses] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun responses(responses: JsonField>) = apply { + this.responses = responses.map { it.toMutableList() } + } + + /** + * Adds a single [EmploymentDataResponse] to [responses]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponse(response: EmploymentDataResponse) = apply { + responses = + (responses ?: JsonField.of(mutableListOf())).also { + checkKnown("responses", it).add(response) + } + } + + 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 [HrisEmploymentRetrieveManyPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .responses() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisEmploymentRetrieveManyPageResponse = + HrisEmploymentRetrieveManyPageResponse( + checkRequired("responses", responses).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HrisEmploymentRetrieveManyPageResponse = apply { + if (validated) { + return@apply + } + + responses().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 = + (responses.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisEmploymentRetrieveManyPageResponse && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(responses, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HrisEmploymentRetrieveManyPageResponse{responses=$responses, additionalProperties=$additionalProperties}" +} 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 9b2e156d..e9c57c27 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 @@ -2,171 +2,107 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.IndividualService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** Read individual data, excluding income and employment data */ +/** @see [IndividualService.retrieveMany] */ class HrisIndividualRetrieveManyPage private constructor( - private val individualsService: IndividualService, + private val service: IndividualService, private val params: HrisIndividualRetrieveManyParams, - private val response: Response, + private val response: HrisIndividualRetrieveManyPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisIndividualRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisIndividualRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisIndividualRetrieveManyPage && individualsService == other.individualsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ + fun getNextPage(): Optional = + getNextPageParams().map { service.retrieveMany(it) } - override fun toString() = - "HrisIndividualRetrieveManyPage{individualsService=$individualsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisIndividualRetrieveManyParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { individualsService.retrieveMany(it) } - } + /** The response that this page was parsed from. */ + fun response(): HrisIndividualRetrieveManyPageResponse = response - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of( - individualsService: IndividualService, - params: HrisIndividualRetrieveManyParams, - response: Response, - ) = HrisIndividualRetrieveManyPage(individualsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisIndividualRetrieveManyPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** A builder for [HrisIndividualRetrieveManyPage]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) + private var service: IndividualService? = null + private var params: HrisIndividualRetrieveManyParams? = null + private var response: HrisIndividualRetrieveManyPageResponse? = null - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - responses().map { it.validate() } - validated = true + @JvmSynthetic + internal fun from(hrisIndividualRetrieveManyPage: HrisIndividualRetrieveManyPage) = apply { + service = hrisIndividualRetrieveManyPage.service + params = hrisIndividualRetrieveManyPage.params + response = hrisIndividualRetrieveManyPage.response } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) + fun service(service: IndividualService) = apply { this.service = service } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The parameters that were used to request this page. */ + fun params(params: HrisIndividualRetrieveManyParams) = apply { this.params = params } - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + /** The response that this page was parsed from. */ + fun response(response: HrisIndividualRetrieveManyPageResponse) = apply { + this.response = response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisIndividualRetrieveManyPage]. - */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisIndividualRetrieveManyPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisIndividualRetrieveManyPage = + HrisIndividualRetrieveManyPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisIndividualRetrieveManyPage) : @@ -188,4 +124,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisIndividualRetrieveManyPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisIndividualRetrieveManyPage{service=$service, params=$params, response=$response}" } 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 8ac7b9d6..77678253 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 @@ -2,17 +2,8 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.IndividualServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -20,156 +11,103 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** Read individual data, excluding income and employment data */ +/** @see [IndividualServiceAsync.retrieveMany] */ class HrisIndividualRetrieveManyPageAsync private constructor( - private val individualsService: IndividualServiceAsync, + private val service: IndividualServiceAsync, private val params: HrisIndividualRetrieveManyParams, - private val response: Response, + private val response: HrisIndividualRetrieveManyPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisIndividualRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisIndividualRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisIndividualRetrieveManyPageAsync && individualsService == other.individualsService && params == other.params && response == other.response /* spotless:on */ - } + fun getNextPageParams(): Optional = Optional.empty() - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisIndividualRetrieveManyPageAsync{individualsService=$individualsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { individualsService.retrieveMany(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.retrieveMany(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - individualsService: IndividualServiceAsync, - params: HrisIndividualRetrieveManyParams, - response: Response, - ) = HrisIndividualRetrieveManyPageAsync(individualsService, params, response) - } - - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) - - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The parameters that were used to request this page. */ + fun params(): HrisIndividualRetrieveManyParams = params - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The response that this page was parsed from. */ + fun response(): HrisIndividualRetrieveManyPageResponse = response - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - fun validate(): Response = apply { - if (validated) { - return@apply - } - - responses().map { it.validate() } - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisIndividualRetrieveManyPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [HrisIndividualRetrieveManyPageAsync]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var service: IndividualServiceAsync? = null + private var params: HrisIndividualRetrieveManyParams? = null + private var response: HrisIndividualRetrieveManyPageResponse? = null - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from( + hrisIndividualRetrieveManyPageAsync: HrisIndividualRetrieveManyPageAsync + ) = apply { + service = hrisIndividualRetrieveManyPageAsync.service + params = hrisIndividualRetrieveManyPageAsync.params + response = hrisIndividualRetrieveManyPageAsync.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" + fun service(service: IndividualServiceAsync) = apply { this.service = service } - companion object { + /** The parameters that were used to request this page. */ + fun params(params: HrisIndividualRetrieveManyParams) = apply { this.params = params } - /** - * Returns a mutable builder for constructing an instance of - * [HrisIndividualRetrieveManyPageAsync]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun response(response: HrisIndividualRetrieveManyPageResponse) = apply { + this.response = response } - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisIndividualRetrieveManyPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisIndividualRetrieveManyPageAsync = + HrisIndividualRetrieveManyPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisIndividualRetrieveManyPageAsync) { @@ -200,4 +138,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisIndividualRetrieveManyPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisIndividualRetrieveManyPageAsync{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponse.kt new file mode 100644 index 00000000..62000290 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponse.kt @@ -0,0 +1,197 @@ +// 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.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class HrisIndividualRetrieveManyPageResponse +private constructor( + private val responses: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("responses") + @ExcludeMissing + responses: JsonField> = JsonMissing.of() + ) : this(responses, 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 responses(): List = responses.getRequired("responses") + + /** + * Returns the raw JSON value of [responses]. + * + * Unlike [responses], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("responses") + @ExcludeMissing + fun _responses(): JsonField> = responses + + @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 + * [HrisIndividualRetrieveManyPageResponse]. + * + * The following fields are required: + * ```java + * .responses() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisIndividualRetrieveManyPageResponse]. */ + class Builder internal constructor() { + + private var responses: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + hrisIndividualRetrieveManyPageResponse: HrisIndividualRetrieveManyPageResponse + ) = apply { + responses = hrisIndividualRetrieveManyPageResponse.responses.map { it.toMutableList() } + additionalProperties = + hrisIndividualRetrieveManyPageResponse.additionalProperties.toMutableMap() + } + + fun responses(responses: List) = responses(JsonField.of(responses)) + + /** + * Sets [Builder.responses] to an arbitrary JSON value. + * + * You should usually call [Builder.responses] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun responses(responses: JsonField>) = apply { + this.responses = responses.map { it.toMutableList() } + } + + /** + * Adds a single [IndividualResponse] to [responses]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponse(response: IndividualResponse) = apply { + responses = + (responses ?: JsonField.of(mutableListOf())).also { + checkKnown("responses", it).add(response) + } + } + + 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 [HrisIndividualRetrieveManyPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .responses() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisIndividualRetrieveManyPageResponse = + HrisIndividualRetrieveManyPageResponse( + checkRequired("responses", responses).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HrisIndividualRetrieveManyPageResponse = apply { + if (validated) { + return@apply + } + + responses().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 = + (responses.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisIndividualRetrieveManyPageResponse && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(responses, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HrisIndividualRetrieveManyPageResponse{responses=$responses, additionalProperties=$additionalProperties}" +} 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 865968a0..f8a43307 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 @@ -2,176 +2,108 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.PayStatementService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** - * Read detailed pay statements for each individual. - * - * Deduction and contribution types are supported by the payroll systems that supports Benefits. - */ +/** @see [PayStatementService.retrieveMany] */ class HrisPayStatementRetrieveManyPage private constructor( - private val payStatementsService: PayStatementService, + private val service: PayStatementService, private val params: HrisPayStatementRetrieveManyParams, - private val response: Response, + private val response: HrisPayStatementRetrieveManyPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisPayStatementRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisPayStatementRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisPayStatementRetrieveManyPage && payStatementsService == other.payStatementsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payStatementsService, params, response) /* spotless:on */ + fun getNextPage(): Optional = + getNextPageParams().map { service.retrieveMany(it) } - override fun toString() = - "HrisPayStatementRetrieveManyPage{payStatementsService=$payStatementsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisPayStatementRetrieveManyParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { payStatementsService.retrieveMany(it) } - } + /** The response that this page was parsed from. */ + fun response(): HrisPayStatementRetrieveManyPageResponse = response - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of( - payStatementsService: PayStatementService, - params: HrisPayStatementRetrieveManyParams, - response: Response, - ) = HrisPayStatementRetrieveManyPage(payStatementsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisPayStatementRetrieveManyPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** A builder for [HrisPayStatementRetrieveManyPage]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) + private var service: PayStatementService? = null + private var params: HrisPayStatementRetrieveManyParams? = null + private var response: HrisPayStatementRetrieveManyPageResponse? = null - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply + @JvmSynthetic + internal fun from(hrisPayStatementRetrieveManyPage: HrisPayStatementRetrieveManyPage) = + apply { + service = hrisPayStatementRetrieveManyPage.service + params = hrisPayStatementRetrieveManyPage.params + response = hrisPayStatementRetrieveManyPage.response } - responses().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + fun service(service: PayStatementService) = apply { this.service = service } - fun toBuilder() = Builder().from(this) + /** The parameters that were used to request this page. */ + fun params(params: HrisPayStatementRetrieveManyParams) = apply { this.params = params } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + /** The response that this page was parsed from. */ + fun response(response: HrisPayStatementRetrieveManyPageResponse) = apply { + this.response = response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisPayStatementRetrieveManyPage]. - */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = - responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisPayStatementRetrieveManyPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisPayStatementRetrieveManyPage = + HrisPayStatementRetrieveManyPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisPayStatementRetrieveManyPage) : @@ -193,4 +125,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisPayStatementRetrieveManyPage && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisPayStatementRetrieveManyPage{service=$service, params=$params, response=$response}" } 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 8ec74337..2ec1929c 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 @@ -2,17 +2,8 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.PayStatementServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -20,161 +11,103 @@ import java.util.concurrent.Executor import java.util.function.Predicate import kotlin.jvm.optionals.getOrNull -/** - * Read detailed pay statements for each individual. - * - * Deduction and contribution types are supported by the payroll systems that supports Benefits. - */ +/** @see [PayStatementServiceAsync.retrieveMany] */ class HrisPayStatementRetrieveManyPageAsync private constructor( - private val payStatementsService: PayStatementServiceAsync, + private val service: PayStatementServiceAsync, private val params: HrisPayStatementRetrieveManyParams, - private val response: Response, + private val response: HrisPayStatementRetrieveManyPageResponse, ) { - fun response(): Response = response + /** + * Delegates to [HrisPayStatementRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisPayStatementRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() - fun responses(): List = response().responses() + fun hasNextPage(): Boolean = responses().isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisPayStatementRetrieveManyPageAsync && payStatementsService == other.payStatementsService && params == other.params && response == other.response /* spotless:on */ - } + fun getNextPageParams(): Optional = Optional.empty() - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payStatementsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisPayStatementRetrieveManyPageAsync{payStatementsService=$payStatementsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { payStatementsService.retrieveMany(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.retrieveMany(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - payStatementsService: PayStatementServiceAsync, - params: HrisPayStatementRetrieveManyParams, - response: Response, - ) = HrisPayStatementRetrieveManyPageAsync(payStatementsService, params, response) - } - - class Response( - private val responses: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("responses") - responses: JsonField> = JsonMissing.of() - ) : this(responses, mutableMapOf()) - - fun responses(): List = - responses.getOptional("responses").getOrNull() ?: listOf() - - @JsonProperty("responses") - fun _responses(): Optional>> = - Optional.ofNullable(responses) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** The parameters that were used to request this page. */ + fun params(): HrisPayStatementRetrieveManyParams = params - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The response that this page was parsed from. */ + fun response(): HrisPayStatementRetrieveManyPageResponse = response - private var validated: Boolean = false + fun toBuilder() = Builder().from(this) - fun validate(): Response = apply { - if (validated) { - return@apply - } - - responses().map { it.validate() } - validated = true - } + companion object { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** + * Returns a mutable builder for constructing an instance of + * [HrisPayStatementRetrieveManyPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun toBuilder() = Builder().from(this) + /** A builder for [HrisPayStatementRetrieveManyPageAsync]. */ + class Builder internal constructor() { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var service: PayStatementServiceAsync? = null + private var params: HrisPayStatementRetrieveManyParams? = null + private var response: HrisPayStatementRetrieveManyPageResponse? = null - return /* spotless:off */ other is Response && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + @JvmSynthetic + internal fun from( + hrisPayStatementRetrieveManyPageAsync: HrisPayStatementRetrieveManyPageAsync + ) = apply { + service = hrisPayStatementRetrieveManyPageAsync.service + params = hrisPayStatementRetrieveManyPageAsync.params + response = hrisPayStatementRetrieveManyPageAsync.response } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(responses, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{responses=$responses, additionalProperties=$additionalProperties}" + fun service(service: PayStatementServiceAsync) = apply { this.service = service } - companion object { + /** The parameters that were used to request this page. */ + fun params(params: HrisPayStatementRetrieveManyParams) = apply { this.params = params } - /** - * Returns a mutable builder for constructing an instance of - * [HrisPayStatementRetrieveManyPageAsync]. - */ - @JvmStatic fun builder() = Builder() + /** The response that this page was parsed from. */ + fun response(response: HrisPayStatementRetrieveManyPageResponse) = apply { + this.response = response } - class Builder { - - private var responses: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.responses = page.responses - this.additionalProperties.putAll(page.additionalProperties) - } - - fun responses(responses: List) = - responses(JsonField.of(responses)) - - fun responses(responses: JsonField>) = apply { - this.responses = responses - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(responses, additionalProperties.toMutableMap()) - } + /** + * Returns an immutable instance of [HrisPayStatementRetrieveManyPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisPayStatementRetrieveManyPageAsync = + HrisPayStatementRetrieveManyPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("response", response), + ) } class AutoPager(private val firstPage: HrisPayStatementRetrieveManyPageAsync) { @@ -205,4 +138,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisPayStatementRetrieveManyPageAsync && service == other.service && params == other.params && response == other.response /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, response) /* spotless:on */ + + override fun toString() = + "HrisPayStatementRetrieveManyPageAsync{service=$service, params=$params, response=$response}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponse.kt new file mode 100644 index 00000000..4d46ab7e --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponse.kt @@ -0,0 +1,198 @@ +// 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.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class HrisPayStatementRetrieveManyPageResponse +private constructor( + private val responses: JsonField>, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("responses") + @ExcludeMissing + responses: JsonField> = JsonMissing.of() + ) : this(responses, 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 responses(): List = responses.getRequired("responses") + + /** + * Returns the raw JSON value of [responses]. + * + * Unlike [responses], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("responses") + @ExcludeMissing + fun _responses(): JsonField> = responses + + @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 + * [HrisPayStatementRetrieveManyPageResponse]. + * + * The following fields are required: + * ```java + * .responses() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisPayStatementRetrieveManyPageResponse]. */ + class Builder internal constructor() { + + private var responses: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + hrisPayStatementRetrieveManyPageResponse: HrisPayStatementRetrieveManyPageResponse + ) = apply { + responses = + hrisPayStatementRetrieveManyPageResponse.responses.map { it.toMutableList() } + additionalProperties = + hrisPayStatementRetrieveManyPageResponse.additionalProperties.toMutableMap() + } + + fun responses(responses: List) = responses(JsonField.of(responses)) + + /** + * Sets [Builder.responses] to an arbitrary JSON value. + * + * You should usually call [Builder.responses] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun responses(responses: JsonField>) = apply { + this.responses = responses.map { it.toMutableList() } + } + + /** + * Adds a single [PayStatementResponse] to [responses]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addResponse(response: PayStatementResponse) = apply { + responses = + (responses ?: JsonField.of(mutableListOf())).also { + checkKnown("responses", it).add(response) + } + } + + 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 [HrisPayStatementRetrieveManyPageResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .responses() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisPayStatementRetrieveManyPageResponse = + HrisPayStatementRetrieveManyPageResponse( + checkRequired("responses", responses).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): HrisPayStatementRetrieveManyPageResponse = apply { + if (validated) { + return@apply + } + + responses().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 = + (responses.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisPayStatementRetrieveManyPageResponse && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(responses, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "HrisPayStatementRetrieveManyPageResponse{responses=$responses, additionalProperties=$additionalProperties}" +} 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 ba026277..82892fa1 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 @@ -2,160 +2,95 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.PaymentService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** Read payroll and contractor related payments by the company. */ +/** @see [PaymentService.list] */ class HrisPaymentListPage private constructor( - private val paymentsService: PaymentService, + private val service: PaymentService, private val params: HrisPaymentListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisPaymentListPage && paymentsService == other.paymentsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(paymentsService, params, response) /* spotless:on */ + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } - override fun toString() = - "HrisPaymentListPage{paymentsService=$paymentsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): HrisPaymentListParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { paymentsService.list(it) } - } + /** The response that this page was parsed from. */ + fun items(): List = items - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of(paymentsService: PaymentService, params: HrisPaymentListParams, response: Response) = - HrisPaymentListPage(paymentsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [HrisPaymentListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** A builder for [HrisPaymentListPage]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) + private var service: PaymentService? = null + private var params: HrisPaymentListParams? = null + private var items: List? = null - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JvmSynthetic + internal fun from(hrisPaymentListPage: HrisPaymentListPage) = apply { + service = hrisPaymentListPage.service + params = hrisPaymentListPage.params + items = hrisPaymentListPage.items } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" - - companion object { - - /** Returns a mutable builder for constructing an instance of [HrisPaymentListPage]. */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + fun service(service: PaymentService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisPaymentListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [HrisPaymentListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisPaymentListPage = + HrisPaymentListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: HrisPaymentListPage) : Iterable { @@ -176,4 +111,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisPaymentListPage && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = "HrisPaymentListPage{service=$service, params=$params, items=$items}" } 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 c4f2c62f..236a00f1 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 @@ -2,168 +2,98 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.PaymentServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -/** Read payroll and contractor related payments by the company. */ +/** @see [PaymentServiceAsync.list] */ class HrisPaymentListPageAsync private constructor( - private val paymentsService: PaymentServiceAsync, + private val service: PaymentServiceAsync, private val params: HrisPaymentListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisPaymentListPageAsync && paymentsService == other.paymentsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(paymentsService, params, response) /* spotless:on */ - - override fun toString() = - "HrisPaymentListPageAsync{paymentsService=$paymentsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { paymentsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - paymentsService: PaymentServiceAsync, - params: HrisPaymentListParams, - response: Response, - ) = HrisPaymentListPageAsync(paymentsService, params, response) - } - - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The parameters that were used to request this page. */ + fun params(): HrisPaymentListParams = params - private var validated: Boolean = false + /** The response that this page was parsed from. */ + fun items(): List = items - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } + companion object { - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ + /** + * Returns a mutable builder for constructing an instance of [HrisPaymentListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" + /** A builder for [HrisPaymentListPageAsync]. */ + class Builder internal constructor() { - companion object { + private var service: PaymentServiceAsync? = null + private var params: HrisPaymentListParams? = null + private var items: List? = null - /** - * Returns a mutable builder for constructing an instance of [HrisPaymentListPageAsync]. - */ - @JvmStatic fun builder() = Builder() + @JvmSynthetic + internal fun from(hrisPaymentListPageAsync: HrisPaymentListPageAsync) = apply { + service = hrisPaymentListPageAsync.service + params = hrisPaymentListPageAsync.params + items = hrisPaymentListPageAsync.items } - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + fun service(service: PaymentServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisPaymentListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [HrisPaymentListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): HrisPaymentListPageAsync = + HrisPaymentListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: HrisPaymentListPageAsync) { @@ -191,4 +121,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is HrisPaymentListPageAsync && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "HrisPaymentListPageAsync{service=$service, params=$params, items=$items}" } 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 45c9b544..a6556ac8 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 @@ -2,165 +2,96 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.payroll.PayGroupService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** Read company pay groups and frequencies */ +/** @see [PayGroupService.list] */ class PayrollPayGroupListPage private constructor( - private val payGroupsService: PayGroupService, + private val service: PayGroupService, private val params: PayrollPayGroupListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PayrollPayGroupListPage && payGroupsService == other.payGroupsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payGroupsService, params, response) /* spotless:on */ + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } - override fun toString() = - "PayrollPayGroupListPage{payGroupsService=$payGroupsService, params=$params, response=$response}" + fun autoPager(): AutoPager = AutoPager(this) - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + /** The parameters that were used to request this page. */ + fun params(): PayrollPayGroupListParams = params - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPage(): Optional { - return getNextPageParams().map { payGroupsService.list(it) } - } - - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of( - payGroupsService: PayGroupService, - params: PayrollPayGroupListParams, - response: Response, - ) = PayrollPayGroupListPage(payGroupsService, params, response) + /** + * Returns a mutable builder for constructing an instance of [PayrollPayGroupListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** A builder for [PayrollPayGroupListPage]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) + private var service: PayGroupService? = null + private var params: PayrollPayGroupListParams? = null + private var items: List? = null - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JvmSynthetic + internal fun from(payrollPayGroupListPage: PayrollPayGroupListPage) = apply { + service = payrollPayGroupListPage.service + params = payrollPayGroupListPage.params + items = payrollPayGroupListPage.items } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [PayrollPayGroupListPage]. - */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + fun service(service: PayGroupService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: PayrollPayGroupListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [PayrollPayGroupListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PayrollPayGroupListPage = + PayrollPayGroupListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: PayrollPayGroupListPage) : @@ -182,4 +113,17 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PayrollPayGroupListPage && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "PayrollPayGroupListPage{service=$service, params=$params, items=$items}" } 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 d280c90d..98a97b4f 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 @@ -2,169 +2,98 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.payroll.PayGroupServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -/** Read company pay groups and frequencies */ +/** @see [PayGroupServiceAsync.list] */ class PayrollPayGroupListPageAsync private constructor( - private val payGroupsService: PayGroupServiceAsync, + private val service: PayGroupServiceAsync, private val params: PayrollPayGroupListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PayrollPayGroupListPageAsync && payGroupsService == other.payGroupsService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payGroupsService, params, response) /* spotless:on */ - - override fun toString() = - "PayrollPayGroupListPageAsync{payGroupsService=$payGroupsService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { payGroupsService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - payGroupsService: PayGroupServiceAsync, - params: PayrollPayGroupListParams, - response: Response, - ) = PayrollPayGroupListPageAsync(payGroupsService, params, response) - } - - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The parameters that were used to request this page. */ + fun params(): PayrollPayGroupListParams = params - private var validated: Boolean = false + /** The response that this page was parsed from. */ + fun items(): List = items - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } + companion object { - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ + /** + * Returns a mutable builder for constructing an instance of [PayrollPayGroupListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" + /** A builder for [PayrollPayGroupListPageAsync]. */ + class Builder internal constructor() { - companion object { + private var service: PayGroupServiceAsync? = null + private var params: PayrollPayGroupListParams? = null + private var items: List? = null - /** - * Returns a mutable builder for constructing an instance of - * [PayrollPayGroupListPageAsync]. - */ - @JvmStatic fun builder() = Builder() + @JvmSynthetic + internal fun from(payrollPayGroupListPageAsync: PayrollPayGroupListPageAsync) = apply { + service = payrollPayGroupListPageAsync.service + params = payrollPayGroupListPageAsync.params + items = payrollPayGroupListPageAsync.items } - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + fun service(service: PayGroupServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: PayrollPayGroupListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [PayrollPayGroupListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PayrollPayGroupListPageAsync = + PayrollPayGroupListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: PayrollPayGroupListPageAsync) { @@ -195,4 +124,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PayrollPayGroupListPageAsync && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "PayrollPayGroupListPageAsync{service=$service, params=$params, items=$items}" } 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 211ce9e1..fddd8a63 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 @@ -2,160 +2,95 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.ProviderService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream import java.util.stream.StreamSupport import kotlin.jvm.optionals.getOrNull -/** Return details on all available payroll and HR systems. */ +/** @see [ProviderService.list] */ class ProviderListPage private constructor( - private val providersService: ProviderService, + private val service: ProviderService, private val params: ProviderListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProviderListPage && providersService == other.providersService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(providersService, params, response) /* spotless:on */ + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } - override fun toString() = - "ProviderListPage{providersService=$providersService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun autoPager(): AutoPager = AutoPager(this) - fun getNextPageParams(): Optional { - return Optional.empty() - } + /** The parameters that were used to request this page. */ + fun params(): ProviderListParams = params - fun getNextPage(): Optional { - return getNextPageParams().map { providersService.list(it) } - } + /** The response that this page was parsed from. */ + fun items(): List = items - fun autoPager(): AutoPager = AutoPager(this) + fun toBuilder() = Builder().from(this) companion object { - @JvmStatic - fun of(providersService: ProviderService, params: ProviderListParams, response: Response) = - ProviderListPage(providersService, params, response) + /** + * Returns a mutable builder for constructing an instance of [ProviderListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { + /** A builder for [ProviderListPage]. */ + class Builder internal constructor() { - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) + private var service: ProviderService? = null + private var params: ProviderListParams? = null + private var items: List? = null - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) + @JvmSynthetic + internal fun from(providerListPage: ProviderListPage) = apply { + service = providerListPage.service + params = providerListPage.params + items = providerListPage.items } - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - private var validated: Boolean = false - - fun validate(): Response = apply { - if (validated) { - return@apply - } - - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ - - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" - - companion object { - - /** Returns a mutable builder for constructing an instance of [ProviderListPage]. */ - @JvmStatic fun builder() = Builder() - } - - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + fun service(service: ProviderService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: ProviderListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [ProviderListPage]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProviderListPage = + ProviderListPage( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: ProviderListPage) : Iterable { @@ -176,4 +111,16 @@ private constructor( return StreamSupport.stream(spliterator(), false) } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProviderListPage && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = "ProviderListPage{service=$service, params=$params, items=$items}" } 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 d8d7a8e1..bdb79fb7 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 @@ -2,168 +2,98 @@ 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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.ProviderServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -import kotlin.jvm.optionals.getOrNull -/** Return details on all available payroll and HR systems. */ +/** @see [ProviderServiceAsync.list] */ class ProviderListPageAsync private constructor( - private val providersService: ProviderServiceAsync, + private val service: ProviderServiceAsync, private val params: ProviderListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + fun hasNextPage(): Boolean = items.isNotEmpty() - fun items(): List = response().items() + fun getNextPageParams(): Optional = Optional.empty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is ProviderListPageAsync && providersService == other.providersService && params == other.params && response == other.response /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(providersService, params, response) /* spotless:on */ - - override fun toString() = - "ProviderListPageAsync{providersService=$providersService, params=$params, response=$response}" - - fun hasNextPage(): Boolean { - return !items().isEmpty() - } - - fun getNextPageParams(): Optional { - return Optional.empty() - } - - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { providersService.list(it).thenApply { Optional.of(it) } } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - } fun autoPager(): AutoPager = AutoPager(this) - companion object { - - @JvmStatic - fun of( - providersService: ProviderServiceAsync, - params: ProviderListParams, - response: Response, - ) = ProviderListPageAsync(providersService, params, response) - } - - class Response( - private val items: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() - ) : this(items, mutableMapOf()) - - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() - - @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + /** The parameters that were used to request this page. */ + fun params(): ProviderListParams = params - private var validated: Boolean = false + /** The response that this page was parsed from. */ + fun items(): List = items - fun validate(): Response = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - items().map { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Response && items == other.items && additionalProperties == other.additionalProperties /* spotless:on */ - } + companion object { - override fun hashCode(): Int = /* spotless:off */ Objects.hash(items, additionalProperties) /* spotless:on */ + /** + * Returns a mutable builder for constructing an instance of [ProviderListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun toString() = - "Response{items=$items, additionalProperties=$additionalProperties}" + /** A builder for [ProviderListPageAsync]. */ + class Builder internal constructor() { - companion object { + private var service: ProviderServiceAsync? = null + private var params: ProviderListParams? = null + private var items: List? = null - /** - * Returns a mutable builder for constructing an instance of [ProviderListPageAsync]. - */ - @JvmStatic fun builder() = Builder() + @JvmSynthetic + internal fun from(providerListPageAsync: ProviderListPageAsync) = apply { + service = providerListPageAsync.service + params = providerListPageAsync.params + items = providerListPageAsync.items } - class Builder { - - private var items: JsonField> = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(page: Response) = apply { - this.items = page.items - this.additionalProperties.putAll(page.additionalProperties) - } - - fun items(items: List) = items(JsonField.of(items)) - - fun items(items: JsonField>) = apply { this.items = items } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - this.additionalProperties.put(key, value) - } - - /** - * Returns an immutable instance of [Response]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Response = Response(items, additionalProperties.toMutableMap()) - } + fun service(service: ProviderServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: ProviderListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: List) = apply { this.items = items } + + /** + * Returns an immutable instance of [ProviderListPageAsync]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): ProviderListPageAsync = + ProviderListPageAsync( + checkRequired("service", service), + checkRequired("params", params), + checkRequired("items", items), + ) } class AutoPager(private val firstPage: ProviderListPageAsync) { @@ -191,4 +121,17 @@ private constructor( return forEach(values::add, executor).thenApply { values } } } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is ProviderListPageAsync && service == other.service && params == other.params && items == other.items /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(service, params, items) /* spotless:on */ + + override fun toString() = + "ProviderListPageAsync{service=$service, params=$params, items=$items}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt index f16b14b7..c5160b47 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt @@ -28,7 +28,6 @@ private constructor( private val employeeDeduction: JsonField>, private val frequencies: JsonField>, private val hsaContributionLimit: JsonField>, - private val type: JsonField, private val additionalProperties: MutableMap, ) { @@ -53,7 +52,6 @@ private constructor( @JsonProperty("hsa_contribution_limit") @ExcludeMissing hsaContributionLimit: JsonField> = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), ) : this( annualMaximum, catchUp, @@ -62,7 +60,6 @@ private constructor( employeeDeduction, frequencies, hsaContributionLimit, - type, mutableMapOf(), ) @@ -125,14 +122,6 @@ private constructor( fun hsaContributionLimit(): Optional> = hsaContributionLimit.getOptional("hsa_contribution_limit") - /** - * 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") - /** * Returns the raw JSON value of [annualMaximum]. * @@ -195,13 +184,6 @@ private constructor( @ExcludeMissing fun _hsaContributionLimit(): JsonField> = hsaContributionLimit - /** - * 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) @@ -230,7 +212,6 @@ private constructor( private var employeeDeduction: JsonField>? = null private var frequencies: JsonField>? = null private var hsaContributionLimit: JsonField>? = null - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -242,7 +223,6 @@ private constructor( employeeDeduction = supportedBenefit.employeeDeduction.map { it.toMutableList() } frequencies = supportedBenefit.frequencies.map { it.toMutableList() } hsaContributionLimit = supportedBenefit.hsaContributionLimit.map { it.toMutableList() } - type = supportedBenefit.type additionalProperties = supportedBenefit.additionalProperties.toMutableMap() } @@ -442,21 +422,6 @@ private constructor( } } - /** 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()) - - /** - * 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. - */ - fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -490,7 +455,6 @@ private constructor( (employeeDeduction ?: JsonMissing.of()).map { it.toImmutable() }, (frequencies ?: JsonMissing.of()).map { it.toImmutable() }, (hsaContributionLimit ?: JsonMissing.of()).map { it.toImmutable() }, - type, additionalProperties.toMutableMap(), ) } @@ -509,7 +473,6 @@ private constructor( employeeDeduction().ifPresent { it.forEach { it?.validate() } } frequencies().ifPresent { it.forEach { it?.validate() } } hsaContributionLimit().ifPresent { it.forEach { it?.validate() } } - type().ifPresent { it.validate() } validated = true } @@ -537,8 +500,7 @@ private constructor( ?: 0) + (frequencies.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + (hsaContributionLimit.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + ?: 0) class CompanyContribution @JsonCreator @@ -932,15 +894,15 @@ private constructor( return true } - return /* spotless:off */ other is SupportedBenefit && annualMaximum == other.annualMaximum && catchUp == other.catchUp && companyContribution == other.companyContribution && description == other.description && employeeDeduction == other.employeeDeduction && frequencies == other.frequencies && hsaContributionLimit == other.hsaContributionLimit && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is SupportedBenefit && 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, type, additionalProperties) } + 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() = - "SupportedBenefit{annualMaximum=$annualMaximum, catchUp=$catchUp, companyContribution=$companyContribution, description=$description, employeeDeduction=$employeeDeduction, frequencies=$frequencies, hsaContributionLimit=$hsaContributionLimit, type=$type, additionalProperties=$additionalProperties}" + "SupportedBenefit{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/UnenrolledIndividual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt deleted file mode 100644 index 2ced037c..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt +++ /dev/null @@ -1,442 +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.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.errors.FinchInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class UnenrolledIndividual -private constructor( - private val body: JsonField, - private val code: JsonField, - private val individualId: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), - @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), - @JsonProperty("individual_id") - @ExcludeMissing - individualId: JsonField = JsonMissing.of(), - ) : this(body, code, individualId, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun body(): Optional = body.getOptional("body") - - /** - * HTTP status code - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun code(): Optional = code.getOptional("code") - - /** - * @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") - - /** - * 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 - - /** - * 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 [individualId]. - * - * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("individual_id") - @ExcludeMissing - fun _individualId(): JsonField = individualId - - @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 [UnenrolledIndividual]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnenrolledIndividual]. */ - class Builder internal constructor() { - - private var body: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unenrolledIndividual: UnenrolledIndividual) = apply { - body = unenrolledIndividual.body - code = unenrolledIndividual.code - individualId = unenrolledIndividual.individualId - additionalProperties = unenrolledIndividual.additionalProperties.toMutableMap() - } - - 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 [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 } - - /** HTTP status code */ - fun code(code: Long) = code(JsonField.of(code)) - - /** - * Sets [Builder.code] to an arbitrary JSON value. - * - * You should usually call [Builder.code] with a well-typed [Long] 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 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 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 [UnenrolledIndividual]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): UnenrolledIndividual = - UnenrolledIndividual(body, code, individualId, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): UnenrolledIndividual = apply { - if (validated) { - return@apply - } - - body().ifPresent { it.validate() } - code() - individualId() - 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 = - (body.asKnown().getOrNull()?.validity() ?: 0) + - (if (code.asKnown().isPresent) 1 else 0) + - (if (individualId.asKnown().isPresent) 1 else 0) - - class Body - private constructor( - private val finchCode: JsonField, - private val message: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("finch_code") - @ExcludeMissing - finchCode: JsonField = JsonMissing.of(), - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(finchCode, message, name, mutableMapOf()) - - /** - * A descriptive identifier for the response. - * - * @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") - - /** - * Short description in English that provides more information about the response. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun message(): Optional = message.getOptional("message") - - /** - * Identifier indicating whether the benefit was newly enrolled or updated. - * - * @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 [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 [Body]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Body]. */ - class Builder internal constructor() { - - private var finchCode: JsonField = JsonMissing.of() - private var message: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(body: Body) = apply { - finchCode = body.finchCode - message = body.message - name = body.name - additionalProperties = body.additionalProperties.toMutableMap() - } - - /** A descriptive identifier for the response. */ - fun finchCode(finchCode: String?) = finchCode(JsonField.ofNullable(finchCode)) - - /** Alias for calling [Builder.finchCode] with `finchCode.orElse(null)`. */ - fun finchCode(finchCode: Optional) = finchCode(finchCode.getOrNull()) - - /** - * 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 } - - /** Short description in English that provides more information about the response. */ - fun message(message: String?) = message(JsonField.ofNullable(message)) - - /** Alias for calling [Builder.message] with `message.orElse(null)`. */ - fun message(message: Optional) = message(message.getOrNull()) - - /** - * 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 } - - /** Identifier indicating whether the benefit was newly enrolled or updated. */ - 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 [Body]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Body = Body(finchCode, message, name, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Body = apply { - if (validated) { - return@apply - } - - finchCode() - message() - 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 (finchCode.asKnown().isPresent) 1 else 0) + - (if (message.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Body && finchCode == other.finchCode && message == other.message && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(finchCode, message, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Body{finchCode=$finchCode, message=$message, name=$name, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnenrolledIndividual && body == other.body && code == other.code && individualId == other.individualId && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(body, code, individualId, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnenrolledIndividual{body=$body, code=$code, individualId=$individualId, additionalProperties=$additionalProperties}" -} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt new file mode 100644 index 00000000..308a775e --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt @@ -0,0 +1,173 @@ +// 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.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 + +class UnenrolledIndividualBenefitResponse +private constructor( + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("job_id") @ExcludeMissing jobId: JsonField = JsonMissing.of() + ) : this(jobId, 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 jobId(): String = jobId.getRequired("job_id") + + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId + + @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 + * [UnenrolledIndividualBenefitResponse]. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnenrolledIndividualBenefitResponse]. */ + class Builder internal constructor() { + + private var jobId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + unenrolledIndividualBenefitResponse: UnenrolledIndividualBenefitResponse + ) = apply { + jobId = unenrolledIndividualBenefitResponse.jobId + additionalProperties = + unenrolledIndividualBenefitResponse.additionalProperties.toMutableMap() + } + + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + + 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 [UnenrolledIndividualBenefitResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnenrolledIndividualBenefitResponse = + UnenrolledIndividualBenefitResponse( + checkRequired("jobId", jobId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnenrolledIndividualBenefitResponse = apply { + if (validated) { + return@apply + } + + jobId() + 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 (jobId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnenrolledIndividualBenefitResponse && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(jobId, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnenrolledIndividualBenefitResponse{jobId=$jobId, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt index fc71a1bc..675a1d25 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt @@ -18,13 +18,15 @@ import java.util.Objects class UpdateCompanyBenefitResponse private constructor( private val benefitId: JsonField, + private val jobId: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("benefit_id") @ExcludeMissing benefitId: JsonField = JsonMissing.of() - ) : this(benefitId, mutableMapOf()) + @JsonProperty("benefit_id") @ExcludeMissing benefitId: JsonField = JsonMissing.of(), + @JsonProperty("job_id") @ExcludeMissing jobId: JsonField = JsonMissing.of(), + ) : this(benefitId, jobId, mutableMapOf()) /** * The id of the benefit. @@ -34,6 +36,12 @@ private constructor( */ fun benefitId(): String = benefitId.getRequired("benefit_id") + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun jobId(): String = jobId.getRequired("job_id") + /** * Returns the raw JSON value of [benefitId]. * @@ -41,6 +49,13 @@ private constructor( */ @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId(): JsonField = benefitId + /** + * Returns the raw JSON value of [jobId]. + * + * Unlike [jobId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -61,6 +76,7 @@ private constructor( * The following fields are required: * ```java * .benefitId() + * .jobId() * ``` */ @JvmStatic fun builder() = Builder() @@ -70,11 +86,13 @@ private constructor( class Builder internal constructor() { private var benefitId: JsonField? = null + private var jobId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(updateCompanyBenefitResponse: UpdateCompanyBenefitResponse) = apply { benefitId = updateCompanyBenefitResponse.benefitId + jobId = updateCompanyBenefitResponse.jobId additionalProperties = updateCompanyBenefitResponse.additionalProperties.toMutableMap() } @@ -90,6 +108,16 @@ private constructor( */ fun benefitId(benefitId: JsonField) = apply { this.benefitId = benefitId } + fun jobId(jobId: String) = jobId(JsonField.of(jobId)) + + /** + * Sets [Builder.jobId] to an arbitrary JSON value. + * + * You should usually call [Builder.jobId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun jobId(jobId: JsonField) = apply { this.jobId = jobId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -117,6 +145,7 @@ private constructor( * The following fields are required: * ```java * .benefitId() + * .jobId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -124,6 +153,7 @@ private constructor( fun build(): UpdateCompanyBenefitResponse = UpdateCompanyBenefitResponse( checkRequired("benefitId", benefitId), + checkRequired("jobId", jobId), additionalProperties.toMutableMap(), ) } @@ -136,6 +166,7 @@ private constructor( } benefitId() + jobId() validated = true } @@ -152,22 +183,24 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = (if (benefitId.asKnown().isPresent) 1 else 0) + @JvmSynthetic + internal fun validity(): Int = + (if (benefitId.asKnown().isPresent) 1 else 0) + (if (jobId.asKnown().isPresent) 1 else 0) override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is UpdateCompanyBenefitResponse && benefitId == other.benefitId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UpdateCompanyBenefitResponse && benefitId == other.benefitId && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(benefitId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(benefitId, jobId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "UpdateCompanyBenefitResponse{benefitId=$benefitId, additionalProperties=$additionalProperties}" + "UpdateCompanyBenefitResponse{benefitId=$benefitId, jobId=$jobId, additionalProperties=$additionalProperties}" } 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 a4579fe2..faaef5e4 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 @@ -66,11 +66,11 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C } } .let { - ProviderListPageAsync.of( - ProviderServiceAsyncImpl(clientOptions), - params, - ProviderListPageAsync.Response.builder().items(it).build(), - ) + ProviderListPageAsync.builder() + .service(ProviderServiceAsyncImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } 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 b44c2818..3eefa17d 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 @@ -15,6 +15,7 @@ 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 @@ -24,10 +25,10 @@ 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 class BenefitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -209,18 +210,21 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl } } .let { - HrisBenefitListPageAsync.of( - BenefitServiceAsyncImpl(clientOptions), - params, - HrisBenefitListPageAsync.Response.builder().items(it).build(), - ) + HrisBenefitListPageAsync.builder() + .service(BenefitServiceAsyncImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } } - private val listSupportedBenefitsHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listSupportedBenefitsHandler: + Handler>> = + jsonHandler>>( + clientOptions.jsonMapper + ) .withErrorHandler(errorHandler) override fun listSupportedBenefits( @@ -242,17 +246,15 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl .use { listSupportedBenefitsHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } + it.ifPresent { it.forEach { it.validate() } } } } .let { - HrisBenefitListSupportedBenefitsPageAsync.of( - BenefitServiceAsyncImpl(clientOptions), - params, - HrisBenefitListSupportedBenefitsPageAsync.Response.builder() - .items(it) - .build(), - ) + HrisBenefitListSupportedBenefitsPageAsync.builder() + .service(BenefitServiceAsyncImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } 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 9bc43a06..dfe58374 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 @@ -15,8 +15,10 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.HrisDirectoryListIndividualsPageAsync +import com.tryfinch.api.models.HrisDirectoryListIndividualsPageResponse import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPageAsync +import com.tryfinch.api.models.HrisDirectoryListPageResponse import com.tryfinch.api.models.HrisDirectoryListParams import java.util.concurrent.CompletableFuture @@ -49,8 +51,8 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun list( @@ -76,19 +78,18 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: } } .let { - HrisDirectoryListPageAsync.of( - DirectoryServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisDirectoryListPageAsync.builder() + .service(DirectoryServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } } - private val listIndividualsHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) + private val listIndividualsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @Deprecated("use `list` instead") @@ -115,11 +116,11 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: } } .let { - HrisDirectoryListIndividualsPageAsync.of( - DirectoryServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisDirectoryListIndividualsPageAsync.builder() + .service(DirectoryServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 c78b6123..395a53ff 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 @@ -16,6 +16,7 @@ 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.HrisEmploymentRetrieveManyPageAsync +import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageResponse import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams import java.util.concurrent.CompletableFuture @@ -40,8 +41,8 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveManyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun retrieveMany( @@ -68,11 +69,11 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: } } .let { - HrisEmploymentRetrieveManyPageAsync.of( - EmploymentServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisEmploymentRetrieveManyPageAsync.builder() + .service(EmploymentServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 8b1f0eb0..20b0435f 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 @@ -16,6 +16,7 @@ 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.HrisIndividualRetrieveManyPageAsync +import com.tryfinch.api.models.HrisIndividualRetrieveManyPageResponse import com.tryfinch.api.models.HrisIndividualRetrieveManyParams import java.util.concurrent.CompletableFuture @@ -40,8 +41,8 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveManyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun retrieveMany( @@ -68,11 +69,11 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: } } .let { - HrisIndividualRetrieveManyPageAsync.of( - IndividualServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisIndividualRetrieveManyPageAsync.builder() + .service(IndividualServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 3a2366f1..cfae8dc4 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 @@ -16,6 +16,7 @@ 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.HrisPayStatementRetrieveManyPageAsync +import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageResponse import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams import java.util.concurrent.CompletableFuture @@ -40,8 +41,8 @@ class PayStatementServiceAsyncImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveManyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun retrieveMany( @@ -68,11 +69,11 @@ class PayStatementServiceAsyncImpl internal constructor(private val clientOption } } .let { - HrisPayStatementRetrieveManyPageAsync.of( - PayStatementServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisPayStatementRetrieveManyPageAsync.builder() + .service(PayStatementServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 fb986187..35690383 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 @@ -66,11 +66,11 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl } } .let { - HrisPaymentListPageAsync.of( - PaymentServiceAsyncImpl(clientOptions), - params, - HrisPaymentListPageAsync.Response.builder().items(it).build(), - ) + HrisPaymentListPageAsync.builder() + .service(PaymentServiceAsyncImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } 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 989961fa..5999c68e 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 @@ -8,9 +8,9 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPageAsync import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams -import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyPageAsync import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualEnrolledIdsResponse +import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse import java.util.concurrent.CompletableFuture interface IndividualServiceAsync { @@ -46,14 +46,14 @@ interface IndividualServiceAsync { /** Unenroll individuals from a deduction or contribution */ fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams - ): CompletableFuture = + ): CompletableFuture = unenrollMany(params, RequestOptions.none()) /** @see [unenrollMany] */ fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture + ): CompletableFuture /** * A view of [IndividualServiceAsync] that provides access to raw HTTP responses for each @@ -102,7 +102,7 @@ interface IndividualServiceAsync { @MustBeClosed fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams - ): CompletableFuture> = + ): CompletableFuture> = unenrollMany(params, RequestOptions.none()) /** @see [unenrollMany] */ @@ -110,6 +110,6 @@ interface IndividualServiceAsync { fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): CompletableFuture> + ): CompletableFuture> } } 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 3c10a2e7..0fa6358a 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 @@ -18,11 +18,10 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPageAsync import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams -import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyPageAsync import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualBenefit import com.tryfinch.api.models.IndividualEnrolledIdsResponse -import com.tryfinch.api.models.UnenrolledIndividual +import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse import java.util.concurrent.CompletableFuture class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -51,7 +50,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: override fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions, - ): CompletableFuture = + ): CompletableFuture = // delete /employer/benefits/{benefit_id}/individuals withRawResponse().unenrollMany(params, requestOptions).thenApply { it.parse() } @@ -117,27 +116,24 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: } } .let { - HrisBenefitIndividualRetrieveManyBenefitsPageAsync.of( - IndividualServiceAsyncImpl(clientOptions), - params, - HrisBenefitIndividualRetrieveManyBenefitsPageAsync.Response - .builder() - .items(it) - .build(), - ) + HrisBenefitIndividualRetrieveManyBenefitsPageAsync.builder() + .service(IndividualServiceAsyncImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } } - private val unenrollManyHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val unenrollManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions, - ): CompletableFuture> { + ): CompletableFuture> { val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -154,18 +150,9 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: .use { unenrollManyHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } + it.validate() } } - .let { - HrisBenefitIndividualUnenrollManyPageAsync.of( - IndividualServiceAsyncImpl(clientOptions), - params, - HrisBenefitIndividualUnenrollManyPageAsync.Response.builder() - .items(it) - .build(), - ) - } } } } 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 fd4b52bf..c7b25159 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 @@ -15,6 +15,7 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.HrisCompanyPayStatementItemListPageAsync +import com.tryfinch.api.models.HrisCompanyPayStatementItemListPageResponse 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 @@ -51,8 +52,8 @@ internal constructor(private val clientOptions: ClientOptions) : PayStatementIte override fun rules(): RuleServiceAsync.WithRawResponse = rules - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun list( @@ -78,11 +79,11 @@ internal constructor(private val clientOptions: ClientOptions) : PayStatementIte } } .let { - HrisCompanyPayStatementItemListPageAsync.of( - PayStatementItemServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisCompanyPayStatementItemListPageAsync.builder() + .service(PayStatementItemServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 1f3cb3b0..3d5e6225 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleCreateParams import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleDeleteParams import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleListPageAsync +import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleListPageResponse import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleListParams import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleUpdateParams import com.tryfinch.api.models.RuleCreateResponse @@ -127,10 +128,8 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien } } - private val listHandler: Handler = - jsonHandler( - clientOptions.jsonMapper - ) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun list( @@ -156,11 +155,11 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien } } .let { - HrisCompanyPayStatementItemRuleListPageAsync.of( - RuleServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisCompanyPayStatementItemRuleListPageAsync.builder() + .service(RuleServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 e293c454..1807f79b 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 @@ -106,13 +106,11 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C } } .let { - PayrollPayGroupListPageAsync.of( - PayGroupServiceAsyncImpl(clientOptions), - params, - PayrollPayGroupListPageAsync.Response.builder() - .items(it) - .build(), - ) + PayrollPayGroupListPageAsync.builder() + .service(PayGroupServiceAsyncImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } 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 ccfb0392..0e75130d 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 @@ -63,11 +63,11 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client } } .let { - ProviderListPage.of( - ProviderServiceImpl(clientOptions), - params, - ProviderListPage.Response.builder().items(it).build(), - ) + ProviderListPage.builder() + .service(ProviderServiceImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } 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 dc678dfd..98cd9792 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 @@ -15,6 +15,7 @@ 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 @@ -24,10 +25,10 @@ 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 class BenefitServiceImpl internal constructor(private val clientOptions: ClientOptions) : BenefitService { @@ -195,17 +196,20 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO } } .let { - HrisBenefitListPage.of( - BenefitServiceImpl(clientOptions), - params, - HrisBenefitListPage.Response.builder().items(it).build(), - ) + HrisBenefitListPage.builder() + .service(BenefitServiceImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } - private val listSupportedBenefitsHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listSupportedBenefitsHandler: + Handler>> = + jsonHandler>>( + clientOptions.jsonMapper + ) .withErrorHandler(errorHandler) override fun listSupportedBenefits( @@ -225,17 +229,15 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO .use { listSupportedBenefitsHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } + it.ifPresent { it.forEach { it.validate() } } } } .let { - HrisBenefitListSupportedBenefitsPage.of( - BenefitServiceImpl(clientOptions), - params, - HrisBenefitListSupportedBenefitsPage.Response.builder() - .items(it) - .build(), - ) + HrisBenefitListSupportedBenefitsPage.builder() + .service(BenefitServiceImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } 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 f286831f..b4ecac79 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 @@ -15,8 +15,10 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisDirectoryListIndividualsPage +import com.tryfinch.api.models.HrisDirectoryListIndividualsPageResponse import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPage +import com.tryfinch.api.models.HrisDirectoryListPageResponse import com.tryfinch.api.models.HrisDirectoryListParams class DirectoryServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -48,8 +50,8 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun list( @@ -73,13 +75,17 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien } } .let { - HrisDirectoryListPage.of(DirectoryServiceImpl(clientOptions), params, it) + HrisDirectoryListPage.builder() + .service(DirectoryServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } - private val listIndividualsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listIndividualsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @Deprecated("use `list` instead") @@ -104,11 +110,11 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien } } .let { - HrisDirectoryListIndividualsPage.of( - DirectoryServiceImpl(clientOptions), - params, - it, - ) + HrisDirectoryListIndividualsPage.builder() + .service(DirectoryServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 6f5c4811..b3fbd9b9 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 @@ -16,6 +16,7 @@ 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.HrisEmploymentRetrieveManyPage +import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageResponse import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams class EmploymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -39,8 +40,8 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveManyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun retrieveMany( @@ -65,11 +66,11 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie } } .let { - HrisEmploymentRetrieveManyPage.of( - EmploymentServiceImpl(clientOptions), - params, - it, - ) + HrisEmploymentRetrieveManyPage.builder() + .service(EmploymentServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 1eb3e10c..150aaa04 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 @@ -16,6 +16,7 @@ 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.HrisIndividualRetrieveManyPage +import com.tryfinch.api.models.HrisIndividualRetrieveManyPageResponse import com.tryfinch.api.models.HrisIndividualRetrieveManyParams class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -39,8 +40,8 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveManyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun retrieveMany( @@ -65,11 +66,11 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie } } .let { - HrisIndividualRetrieveManyPage.of( - IndividualServiceImpl(clientOptions), - params, - it, - ) + HrisIndividualRetrieveManyPage.builder() + .service(IndividualServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 2f34f4c3..6cfadcaf 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 @@ -16,6 +16,7 @@ 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.HrisPayStatementRetrieveManyPage +import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageResponse import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams class PayStatementServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -39,8 +40,8 @@ class PayStatementServiceImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) - private val retrieveManyHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val retrieveManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun retrieveMany( @@ -65,11 +66,11 @@ class PayStatementServiceImpl internal constructor(private val clientOptions: Cl } } .let { - HrisPayStatementRetrieveManyPage.of( - PayStatementServiceImpl(clientOptions), - params, - it, - ) + HrisPayStatementRetrieveManyPage.builder() + .service(PayStatementServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 2718c030..7cb22ea4 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 @@ -63,11 +63,11 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO } } .let { - HrisPaymentListPage.of( - PaymentServiceImpl(clientOptions), - params, - HrisPaymentListPage.Response.builder().items(it).build(), - ) + HrisPaymentListPage.builder() + .service(PaymentServiceImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } 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 f0f36e43..5352666e 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 @@ -8,9 +8,9 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPage import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams -import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyPage import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualEnrolledIdsResponse +import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse interface IndividualService { @@ -44,13 +44,13 @@ interface IndividualService { /** Unenroll individuals from a deduction or contribution */ fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams - ): HrisBenefitIndividualUnenrollManyPage = unenrollMany(params, RequestOptions.none()) + ): UnenrolledIndividualBenefitResponse = unenrollMany(params, RequestOptions.none()) /** @see [unenrollMany] */ fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HrisBenefitIndividualUnenrollManyPage + ): UnenrolledIndividualBenefitResponse /** A view of [IndividualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { @@ -96,7 +96,7 @@ interface IndividualService { @MustBeClosed fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams - ): HttpResponseFor = + ): HttpResponseFor = unenrollMany(params, RequestOptions.none()) /** @see [unenrollMany] */ @@ -104,6 +104,6 @@ interface IndividualService { fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HttpResponseFor + ): HttpResponseFor } } 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 34bf610b..403030dd 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 @@ -18,11 +18,10 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPage import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams -import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyPage import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualBenefit import com.tryfinch.api.models.IndividualEnrolledIdsResponse -import com.tryfinch.api.models.UnenrolledIndividual +import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : IndividualService { @@ -50,7 +49,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions, - ): HrisBenefitIndividualUnenrollManyPage = + ): UnenrolledIndividualBenefitResponse = // delete /employer/benefits/{benefit_id}/individuals withRawResponse().unenrollMany(params, requestOptions).parse() @@ -111,25 +110,23 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie } } .let { - HrisBenefitIndividualRetrieveManyBenefitsPage.of( - IndividualServiceImpl(clientOptions), - params, - HrisBenefitIndividualRetrieveManyBenefitsPage.Response.builder() - .items(it) - .build(), - ) + HrisBenefitIndividualRetrieveManyBenefitsPage.builder() + .service(IndividualServiceImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } - private val unenrollManyHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val unenrollManyHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions, - ): HttpResponseFor { + ): HttpResponseFor { val request = HttpRequest.builder() .method(HttpMethod.DELETE) @@ -144,18 +141,9 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie .use { unenrollManyHandler.handle(it) } .also { if (requestOptions.responseValidation!!) { - it.forEach { it.validate() } + it.validate() } } - .let { - HrisBenefitIndividualUnenrollManyPage.of( - IndividualServiceImpl(clientOptions), - params, - HrisBenefitIndividualUnenrollManyPage.Response.builder() - .items(it) - .build(), - ) - } } } } 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 3deb88a5..87dd1814 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 @@ -15,6 +15,7 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisCompanyPayStatementItemListPage +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 @@ -50,8 +51,8 @@ class PayStatementItemServiceImpl internal constructor(private val clientOptions override fun rules(): RuleService.WithRawResponse = rules - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun list( @@ -75,11 +76,11 @@ class PayStatementItemServiceImpl internal constructor(private val clientOptions } } .let { - HrisCompanyPayStatementItemListPage.of( - PayStatementItemServiceImpl(clientOptions), - params, - it, - ) + HrisCompanyPayStatementItemListPage.builder() + .service(PayStatementItemServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 d13e4f22..370263d4 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 @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleCreateParams import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleDeleteParams import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleListPage +import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleListPageResponse import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleListParams import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleUpdateParams import com.tryfinch.api.models.RuleCreateResponse @@ -119,8 +120,8 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti } } - private val listHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun list( @@ -144,11 +145,11 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti } } .let { - HrisCompanyPayStatementItemRuleListPage.of( - RuleServiceImpl(clientOptions), - params, - it, - ) + HrisCompanyPayStatementItemRuleListPage.builder() + .service(RuleServiceImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } 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 92c6cbcc..085c2bc4 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 @@ -100,11 +100,11 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client } } .let { - PayrollPayGroupListPage.of( - PayGroupServiceImpl(clientOptions), - params, - PayrollPayGroupListPage.Response.builder().items(it).build(), - ) + PayrollPayGroupListPage.builder() + .service(PayGroupServiceImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } 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 new file mode 100644 index 00000000..ae8dc665 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt @@ -0,0 +1,70 @@ +// 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/CreateCompanyBenefitsResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponseTest.kt index ea9b034c..79284ea2 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponseTest.kt @@ -14,10 +14,13 @@ internal class CreateCompanyBenefitsResponseTest { val createCompanyBenefitsResponse = CreateCompanyBenefitsResponse.builder() .benefitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(createCompanyBenefitsResponse.benefitId()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(createCompanyBenefitsResponse.jobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test @@ -26,6 +29,7 @@ internal class CreateCompanyBenefitsResponseTest { val createCompanyBenefitsResponse = CreateCompanyBenefitsResponse.builder() .benefitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val roundtrippedCreateCompanyBenefitsResponse = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponseTest.kt new file mode 100644 index 00000000..b4a0bd16 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponseTest.kt @@ -0,0 +1,40 @@ +// 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 EnrolledIndividualBenefitResponseTest { + + @Test + fun create() { + val enrolledIndividualBenefitResponse = + EnrolledIndividualBenefitResponse.builder() + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(enrolledIndividualBenefitResponse.jobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val enrolledIndividualBenefitResponse = + EnrolledIndividualBenefitResponse.builder() + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedEnrolledIndividualBenefitResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(enrolledIndividualBenefitResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEnrolledIndividualBenefitResponse) + .isEqualTo(enrolledIndividualBenefitResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualTest.kt deleted file mode 100644 index 73c9547e..00000000 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualTest.kt +++ /dev/null @@ -1,63 +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 org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class EnrolledIndividualTest { - - @Test - fun create() { - val enrolledIndividual = - EnrolledIndividual.builder() - .body( - EnrolledIndividual.Body.builder() - .finchCode("finch_code") - .message("message") - .name("name") - .build() - ) - .code(EnrolledIndividual.Code.OK) - .individualId("individual_id") - .build() - - assertThat(enrolledIndividual.body()) - .contains( - EnrolledIndividual.Body.builder() - .finchCode("finch_code") - .message("message") - .name("name") - .build() - ) - assertThat(enrolledIndividual.code()).contains(EnrolledIndividual.Code.OK) - assertThat(enrolledIndividual.individualId()).contains("individual_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val enrolledIndividual = - EnrolledIndividual.builder() - .body( - EnrolledIndividual.Body.builder() - .finchCode("finch_code") - .message("message") - .name("name") - .build() - ) - .code(EnrolledIndividual.Code.OK) - .individualId("individual_id") - .build() - - val roundtrippedEnrolledIndividual = - jsonMapper.readValue( - jsonMapper.writeValueAsString(enrolledIndividual), - jacksonTypeRef(), - ) - - assertThat(roundtrippedEnrolledIndividual).isEqualTo(enrolledIndividual) - } -} 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 new file mode 100644 index 00000000..96aa8b83 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt @@ -0,0 +1,80 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HrisCompanyPayStatementItemListPageResponseTest { + + @Test + fun create() { + val hrisCompanyPayStatementItemListPageResponse = + HrisCompanyPayStatementItemListPageResponse.builder() + .addResponse( + PayStatementItemListResponse.builder() + .attributes( + PayStatementItemListResponse.Attributes.builder() + .employer(true) + .metadata(JsonValue.from(mapOf())) + .preTax(true) + .type("type") + .build() + ) + .category(PayStatementItemListResponse.Category.EARNINGS) + .name("name") + .build() + ) + .build() + + assertThat(hrisCompanyPayStatementItemListPageResponse.responses()) + .containsExactly( + PayStatementItemListResponse.builder() + .attributes( + PayStatementItemListResponse.Attributes.builder() + .employer(true) + .metadata(JsonValue.from(mapOf())) + .preTax(true) + .type("type") + .build() + ) + .category(PayStatementItemListResponse.Category.EARNINGS) + .name("name") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val hrisCompanyPayStatementItemListPageResponse = + HrisCompanyPayStatementItemListPageResponse.builder() + .addResponse( + PayStatementItemListResponse.builder() + .attributes( + PayStatementItemListResponse.Attributes.builder() + .employer(true) + .metadata(JsonValue.from(mapOf())) + .preTax(true) + .type("type") + .build() + ) + .category(PayStatementItemListResponse.Category.EARNINGS) + .name("name") + .build() + ) + .build() + + val roundtrippedHrisCompanyPayStatementItemListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(hrisCompanyPayStatementItemListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHrisCompanyPayStatementItemListPageResponse) + .isEqualTo(hrisCompanyPayStatementItemListPageResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponseTest.kt new file mode 100644 index 00000000..ef8efe32 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponseTest.kt @@ -0,0 +1,120 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.jsonMapper +import java.time.OffsetDateTime +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HrisCompanyPayStatementItemRuleListPageResponseTest { + + @Test + fun create() { + val hrisCompanyPayStatementItemRuleListPageResponse = + HrisCompanyPayStatementItemRuleListPageResponse.builder() + .addResponse( + RuleListResponse.builder() + .id("id") + .attributes( + RuleListResponse.Attributes.builder() + .metadata( + RuleListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + .addCondition( + RuleListResponse.Condition.builder() + .field("field") + .operator(RuleListResponse.Condition.Operator.EQUALS) + .value("value") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveEndDate("effective_end_date") + .effectiveStartDate("effective_start_date") + .entityType(RuleListResponse.EntityType.PAY_STATEMENT_ITEM) + .priority(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + assertThat(hrisCompanyPayStatementItemRuleListPageResponse.responses()) + .containsExactly( + RuleListResponse.builder() + .id("id") + .attributes( + RuleListResponse.Attributes.builder() + .metadata( + RuleListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + .addCondition( + RuleListResponse.Condition.builder() + .field("field") + .operator(RuleListResponse.Condition.Operator.EQUALS) + .value("value") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveEndDate("effective_end_date") + .effectiveStartDate("effective_start_date") + .entityType(RuleListResponse.EntityType.PAY_STATEMENT_ITEM) + .priority(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val hrisCompanyPayStatementItemRuleListPageResponse = + HrisCompanyPayStatementItemRuleListPageResponse.builder() + .addResponse( + RuleListResponse.builder() + .id("id") + .attributes( + RuleListResponse.Attributes.builder() + .metadata( + RuleListResponse.Attributes.Metadata.builder() + .putAdditionalProperty("foo", JsonValue.from("bar")) + .build() + ) + .build() + ) + .addCondition( + RuleListResponse.Condition.builder() + .field("field") + .operator(RuleListResponse.Condition.Operator.EQUALS) + .value("value") + .build() + ) + .createdAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .effectiveEndDate("effective_end_date") + .effectiveStartDate("effective_start_date") + .entityType(RuleListResponse.EntityType.PAY_STATEMENT_ITEM) + .priority(0L) + .updatedAt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .build() + ) + .build() + + val roundtrippedHrisCompanyPayStatementItemRuleListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(hrisCompanyPayStatementItemRuleListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHrisCompanyPayStatementItemRuleListPageResponse) + .isEqualTo(hrisCompanyPayStatementItemRuleListPageResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt new file mode 100644 index 00000000..6c4a338d --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt @@ -0,0 +1,86 @@ +// 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 HrisDirectoryListIndividualsPageResponseTest { + + @Test + fun create() { + val hrisDirectoryListIndividualsPageResponse = + HrisDirectoryListIndividualsPageResponse.builder() + .addIndividual( + IndividualInDirectory.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .department(IndividualInDirectory.Department.builder().name("name").build()) + .firstName("first_name") + .isActive(true) + .lastName("last_name") + .manager( + IndividualInDirectory.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .build() + ) + .paging(Paging.builder().count(0L).offset(0L).build()) + .build() + + assertThat(hrisDirectoryListIndividualsPageResponse.individuals()) + .containsExactly( + IndividualInDirectory.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .department(IndividualInDirectory.Department.builder().name("name").build()) + .firstName("first_name") + .isActive(true) + .lastName("last_name") + .manager( + IndividualInDirectory.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .build() + ) + assertThat(hrisDirectoryListIndividualsPageResponse.paging()) + .isEqualTo(Paging.builder().count(0L).offset(0L).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val hrisDirectoryListIndividualsPageResponse = + HrisDirectoryListIndividualsPageResponse.builder() + .addIndividual( + IndividualInDirectory.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .department(IndividualInDirectory.Department.builder().name("name").build()) + .firstName("first_name") + .isActive(true) + .lastName("last_name") + .manager( + IndividualInDirectory.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .build() + ) + .paging(Paging.builder().count(0L).offset(0L).build()) + .build() + + val roundtrippedHrisDirectoryListIndividualsPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(hrisDirectoryListIndividualsPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHrisDirectoryListIndividualsPageResponse) + .isEqualTo(hrisDirectoryListIndividualsPageResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponseTest.kt new file mode 100644 index 00000000..5149910b --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponseTest.kt @@ -0,0 +1,86 @@ +// 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 HrisDirectoryListPageResponseTest { + + @Test + fun create() { + val hrisDirectoryListPageResponse = + HrisDirectoryListPageResponse.builder() + .addIndividual( + IndividualInDirectory.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .department(IndividualInDirectory.Department.builder().name("name").build()) + .firstName("first_name") + .isActive(true) + .lastName("last_name") + .manager( + IndividualInDirectory.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .build() + ) + .paging(Paging.builder().count(0L).offset(0L).build()) + .build() + + assertThat(hrisDirectoryListPageResponse.individuals()) + .containsExactly( + IndividualInDirectory.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .department(IndividualInDirectory.Department.builder().name("name").build()) + .firstName("first_name") + .isActive(true) + .lastName("last_name") + .manager( + IndividualInDirectory.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .build() + ) + assertThat(hrisDirectoryListPageResponse.paging()) + .isEqualTo(Paging.builder().count(0L).offset(0L).build()) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val hrisDirectoryListPageResponse = + HrisDirectoryListPageResponse.builder() + .addIndividual( + IndividualInDirectory.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .department(IndividualInDirectory.Department.builder().name("name").build()) + .firstName("first_name") + .isActive(true) + .lastName("last_name") + .manager( + IndividualInDirectory.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .build() + ) + .paging(Paging.builder().count(0L).offset(0L).build()) + .build() + + val roundtrippedHrisDirectoryListPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(hrisDirectoryListPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHrisDirectoryListPageResponse) + .isEqualTo(hrisDirectoryListPageResponse) + } +} 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 new file mode 100644 index 00000000..21c2d616 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt @@ -0,0 +1,249 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HrisEmploymentRetrieveManyPageResponseTest { + + @Test + fun create() { + val hrisEmploymentRetrieveManyPageResponse = + HrisEmploymentRetrieveManyPageResponse.builder() + .addResponse( + EmploymentDataResponse.builder() + .body( + EmploymentData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .classCode("class_code") + .addCustomField( + EmploymentData.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() + ) + .department( + EmploymentData.Department.builder().name("name").build() + ) + .employment( + EmploymentData.Employment.builder() + .subtype(EmploymentData.Employment.Subtype.FULL_TIME) + .type(EmploymentData.Employment.Type.EMPLOYEE) + .build() + ) + .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .endDate("end_date") + .firstName("first_name") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .isActive(true) + .lastName("last_name") + .latestRehireDate("latest_rehire_date") + .location( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .manager( + EmploymentData.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .sourceId("source_id") + .startDate("start_date") + .title("title") + .workId("work_id") + .build() + ) + .code(0L) + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + assertThat(hrisEmploymentRetrieveManyPageResponse.responses()) + .containsExactly( + EmploymentDataResponse.builder() + .body( + EmploymentData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .classCode("class_code") + .addCustomField( + EmploymentData.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() + ) + .department(EmploymentData.Department.builder().name("name").build()) + .employment( + EmploymentData.Employment.builder() + .subtype(EmploymentData.Employment.Subtype.FULL_TIME) + .type(EmploymentData.Employment.Type.EMPLOYEE) + .build() + ) + .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .endDate("end_date") + .firstName("first_name") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .isActive(true) + .lastName("last_name") + .latestRehireDate("latest_rehire_date") + .location( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .manager( + EmploymentData.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .sourceId("source_id") + .startDate("start_date") + .title("title") + .workId("work_id") + .build() + ) + .code(0L) + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val hrisEmploymentRetrieveManyPageResponse = + HrisEmploymentRetrieveManyPageResponse.builder() + .addResponse( + EmploymentDataResponse.builder() + .body( + EmploymentData.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .classCode("class_code") + .addCustomField( + EmploymentData.CustomField.builder() + .name("name") + .value(JsonValue.from(mapOf())) + .build() + ) + .department( + EmploymentData.Department.builder().name("name").build() + ) + .employment( + EmploymentData.Employment.builder() + .subtype(EmploymentData.Employment.Subtype.FULL_TIME) + .type(EmploymentData.Employment.Type.EMPLOYEE) + .build() + ) + .employmentStatus(EmploymentData.EmploymentStatus.ACTIVE) + .endDate("end_date") + .firstName("first_name") + .income( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .addIncomeHistory( + Income.builder() + .amount(0L) + .currency("currency") + .effectiveDate("effective_date") + .unit(Income.Unit.YEARLY) + .build() + ) + .isActive(true) + .lastName("last_name") + .latestRehireDate("latest_rehire_date") + .location( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .manager( + EmploymentData.Manager.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .middleName("middle_name") + .sourceId("source_id") + .startDate("start_date") + .title("title") + .workId("work_id") + .build() + ) + .code(0L) + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + .build() + + val roundtrippedHrisEmploymentRetrieveManyPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(hrisEmploymentRetrieveManyPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHrisEmploymentRetrieveManyPageResponse) + .isEqualTo(hrisEmploymentRetrieveManyPageResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt new file mode 100644 index 00000000..4b16d20c --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt @@ -0,0 +1,169 @@ +// 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 HrisIndividualRetrieveManyPageResponseTest { + + @Test + fun create() { + val hrisIndividualRetrieveManyPageResponse = + HrisIndividualRetrieveManyPageResponse.builder() + .addResponse( + IndividualResponse.builder() + .body( + Individual.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dob("dob") + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") + .ethnicity(Individual.Ethnicity.ASIAN) + .firstName("first_name") + .gender(Individual.Gender.FEMALE) + .lastName("last_name") + .middleName("middle_name") + .addPhoneNumber( + Individual.PhoneNumber.builder() + .data("data") + .type(Individual.PhoneNumber.Type.WORK) + .build() + ) + .preferredName("preferred_name") + .residence( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .ssn("ssn") + .build() + ) + .code(0L) + .individualId("individual_id") + .build() + ) + .build() + + assertThat(hrisIndividualRetrieveManyPageResponse.responses()) + .containsExactly( + IndividualResponse.builder() + .body( + Individual.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dob("dob") + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") + .ethnicity(Individual.Ethnicity.ASIAN) + .firstName("first_name") + .gender(Individual.Gender.FEMALE) + .lastName("last_name") + .middleName("middle_name") + .addPhoneNumber( + Individual.PhoneNumber.builder() + .data("data") + .type(Individual.PhoneNumber.Type.WORK) + .build() + ) + .preferredName("preferred_name") + .residence( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .ssn("ssn") + .build() + ) + .code(0L) + .individualId("individual_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val hrisIndividualRetrieveManyPageResponse = + HrisIndividualRetrieveManyPageResponse.builder() + .addResponse( + IndividualResponse.builder() + .body( + Individual.builder() + .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .dob("dob") + .addEmail( + Individual.Email.builder() + .data("data") + .type(Individual.Email.Type.WORK) + .build() + ) + .encryptedSsn("encrypted_ssn") + .ethnicity(Individual.Ethnicity.ASIAN) + .firstName("first_name") + .gender(Individual.Gender.FEMALE) + .lastName("last_name") + .middleName("middle_name") + .addPhoneNumber( + Individual.PhoneNumber.builder() + .data("data") + .type(Individual.PhoneNumber.Type.WORK) + .build() + ) + .preferredName("preferred_name") + .residence( + Location.builder() + .city("city") + .country("country") + .line1("line1") + .line2("line2") + .name("name") + .postalCode("postal_code") + .sourceId("source_id") + .state("state") + .build() + ) + .ssn("ssn") + .build() + ) + .code(0L) + .individualId("individual_id") + .build() + ) + .build() + + val roundtrippedHrisIndividualRetrieveManyPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(hrisIndividualRetrieveManyPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHrisIndividualRetrieveManyPageResponse) + .isEqualTo(hrisIndividualRetrieveManyPageResponse) + } +} 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 new file mode 100644 index 00000000..0ce7087a --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt @@ -0,0 +1,478 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class HrisPayStatementRetrieveManyPageResponseTest { + + @Test + fun create() { + val hrisPayStatementRetrieveManyPageResponse = + HrisPayStatementRetrieveManyPageResponse.builder() + .addResponse( + PayStatementResponse.builder() + .body( + PayStatementResponseBody.builder() + .paging(Paging.builder().count(0L).offset(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("bar"), + ) + .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("bar"), + ) + .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("bar"), + ) + .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("bar"), + ) + .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() + ) + .code(0L) + .paymentId("payment_id") + .build() + ) + .build() + + assertThat(hrisPayStatementRetrieveManyPageResponse.responses()) + .containsExactly( + PayStatementResponse.builder() + .body( + PayStatementResponseBody.builder() + .paging(Paging.builder().count(0L).offset(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("bar"), + ) + .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("bar"), + ) + .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("bar"), + ) + .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("bar"), + ) + .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() + ) + .code(0L) + .paymentId("payment_id") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val hrisPayStatementRetrieveManyPageResponse = + HrisPayStatementRetrieveManyPageResponse.builder() + .addResponse( + PayStatementResponse.builder() + .body( + PayStatementResponseBody.builder() + .paging(Paging.builder().count(0L).offset(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("bar"), + ) + .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("bar"), + ) + .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("bar"), + ) + .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("bar"), + ) + .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() + ) + .code(0L) + .paymentId("payment_id") + .build() + ) + .build() + + val roundtrippedHrisPayStatementRetrieveManyPageResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(hrisPayStatementRetrieveManyPageResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedHrisPayStatementRetrieveManyPageResponse) + .isEqualTo(hrisPayStatementRetrieveManyPageResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SupportedBenefitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SupportedBenefitTest.kt index 147c8735..234efa3a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SupportedBenefitTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SupportedBenefitTest.kt @@ -21,7 +21,6 @@ internal class SupportedBenefitTest { .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) - .type(BenefitType._401K) .build() assertThat(supportedBenefit.annualMaximum()).contains(true) @@ -35,7 +34,6 @@ internal class SupportedBenefitTest { .containsExactly(BenefitFrequency.ONE_TIME) assertThat(supportedBenefit.hsaContributionLimit().getOrNull()) .containsExactly(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) - assertThat(supportedBenefit.type()).contains(BenefitType._401K) } @Test @@ -50,7 +48,6 @@ internal class SupportedBenefitTest { .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) - .type(BenefitType._401K) .build() val roundtrippedSupportedBenefit = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponseTest.kt new file mode 100644 index 00000000..b6800b15 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponseTest.kt @@ -0,0 +1,40 @@ +// 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 UnenrolledIndividualBenefitResponseTest { + + @Test + fun create() { + val unenrolledIndividualBenefitResponse = + UnenrolledIndividualBenefitResponse.builder() + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(unenrolledIndividualBenefitResponse.jobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val unenrolledIndividualBenefitResponse = + UnenrolledIndividualBenefitResponse.builder() + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedUnenrolledIndividualBenefitResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(unenrolledIndividualBenefitResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedUnenrolledIndividualBenefitResponse) + .isEqualTo(unenrolledIndividualBenefitResponse) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UnenrolledIndividualTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UnenrolledIndividualTest.kt deleted file mode 100644 index 98753d93..00000000 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UnenrolledIndividualTest.kt +++ /dev/null @@ -1,63 +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 org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class UnenrolledIndividualTest { - - @Test - fun create() { - val unenrolledIndividual = - UnenrolledIndividual.builder() - .body( - UnenrolledIndividual.Body.builder() - .finchCode("finch_code") - .message("message") - .name("name") - .build() - ) - .code(0L) - .individualId("individual_id") - .build() - - assertThat(unenrolledIndividual.body()) - .contains( - UnenrolledIndividual.Body.builder() - .finchCode("finch_code") - .message("message") - .name("name") - .build() - ) - assertThat(unenrolledIndividual.code()).contains(0L) - assertThat(unenrolledIndividual.individualId()).contains("individual_id") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val unenrolledIndividual = - UnenrolledIndividual.builder() - .body( - UnenrolledIndividual.Body.builder() - .finchCode("finch_code") - .message("message") - .name("name") - .build() - ) - .code(0L) - .individualId("individual_id") - .build() - - val roundtrippedUnenrolledIndividual = - jsonMapper.readValue( - jsonMapper.writeValueAsString(unenrolledIndividual), - jacksonTypeRef(), - ) - - assertThat(roundtrippedUnenrolledIndividual).isEqualTo(unenrolledIndividual) - } -} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponseTest.kt index dcbaa6e5..d698a678 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponseTest.kt @@ -14,10 +14,13 @@ internal class UpdateCompanyBenefitResponseTest { val updateCompanyBenefitResponse = UpdateCompanyBenefitResponse.builder() .benefitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() assertThat(updateCompanyBenefitResponse.benefitId()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(updateCompanyBenefitResponse.jobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test @@ -26,6 +29,7 @@ internal class UpdateCompanyBenefitResponseTest { val updateCompanyBenefitResponse = UpdateCompanyBenefitResponse.builder() .benefitId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val roundtrippedUpdateCompanyBenefitResponse = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncTest.kt index a929fd64..ec7439ec 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncTest.kt @@ -22,6 +22,6 @@ internal class ProviderServiceAsyncTest { val pageFuture = providerServiceAsync.list() val page = pageFuture.get() - page.response().validate() + page.items().forEach { it.validate() } } } 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 549630a8..93d19f5a 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 @@ -88,7 +88,7 @@ internal class BenefitServiceAsyncTest { val pageFuture = benefitServiceAsync.list() val page = pageFuture.get() - page.response().validate() + page.items().forEach { it.validate() } } @Test @@ -103,6 +103,6 @@ internal class BenefitServiceAsyncTest { val pageFuture = benefitServiceAsync.listSupportedBenefits() val page = pageFuture.get() - page.response().validate() + page.items().forEach { it.validate() } } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncTest.kt index 8d872e71..09f5348a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncTest.kt @@ -30,6 +30,6 @@ internal class PaymentServiceAsyncTest { ) val page = pageFuture.get() - page.response().validate() + page.items().forEach { it.validate() } } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt index 28f057fa..84962f36 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt @@ -48,7 +48,7 @@ internal class IndividualServiceAsyncTest { ) val page = pageFuture.get() - page.response().validate() + page.items().forEach { it.validate() } } @Test @@ -60,12 +60,15 @@ internal class IndividualServiceAsyncTest { .build() val individualServiceAsync = client.hris().benefits().individuals() - val pageFuture = + val unenrolledIndividualBenefitResponseFuture = individualServiceAsync.unenrollMany( - HrisBenefitIndividualUnenrollManyParams.builder().benefitId("benefit_id").build() + HrisBenefitIndividualUnenrollManyParams.builder() + .benefitId("benefit_id") + .addIndividualId("string") + .build() ) - val page = pageFuture.get() - page.response().validate() + val unenrolledIndividualBenefitResponse = unenrolledIndividualBenefitResponseFuture.get() + unenrolledIndividualBenefitResponse.validate() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncTest.kt index c7bf8d63..6e52fb2f 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncTest.kt @@ -41,6 +41,6 @@ internal class PayGroupServiceAsyncTest { val pageFuture = payGroupServiceAsync.list() val page = pageFuture.get() - page.response().validate() + page.items().forEach { it.validate() } } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/ProviderServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/ProviderServiceTest.kt index ef8de16e..1c98aeb0 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/ProviderServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/ProviderServiceTest.kt @@ -21,6 +21,6 @@ internal class ProviderServiceTest { val page = providerService.list() - page.response().validate() + page.items().forEach { it.validate() } } } 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 e4b2635e..f04e7929 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 @@ -84,7 +84,7 @@ internal class BenefitServiceTest { val page = benefitService.list() - page.response().validate() + page.items().forEach { it.validate() } } @Test @@ -98,6 +98,6 @@ internal class BenefitServiceTest { val page = benefitService.listSupportedBenefits() - page.response().validate() + page.items().forEach { it.validate() } } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceTest.kt index 81898391..d590c56d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceTest.kt @@ -29,6 +29,6 @@ internal class PaymentServiceTest { .build() ) - page.response().validate() + page.items().forEach { it.validate() } } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceTest.kt index 14051f3f..911b8d1e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceTest.kt @@ -46,7 +46,7 @@ internal class IndividualServiceTest { .build() ) - page.response().validate() + page.items().forEach { it.validate() } } @Test @@ -58,11 +58,14 @@ internal class IndividualServiceTest { .build() val individualService = client.hris().benefits().individuals() - val page = + val unenrolledIndividualBenefitResponse = individualService.unenrollMany( - HrisBenefitIndividualUnenrollManyParams.builder().benefitId("benefit_id").build() + HrisBenefitIndividualUnenrollManyParams.builder() + .benefitId("benefit_id") + .addIndividualId("string") + .build() ) - page.response().validate() + unenrolledIndividualBenefitResponse.validate() } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceTest.kt index 5c257d37..b64d3e99 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceTest.kt @@ -39,6 +39,6 @@ internal class PayGroupServiceTest { val page = payGroupService.list() - page.response().validate() + page.items().forEach { it.validate() } } }