From a7c802c84dff751a252c17ea3d4b19624792cba1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 13:49:47 +0000 Subject: [PATCH 01/13] feat(api): api update (#533) --- .stats.yml | 4 +- .../BenefitListSupportedBenefitsResponse.kt | 918 ++++++++++++++++++ .../models/CreateCompanyBenefitsResponse.kt | 45 +- .../tryfinch/api/models/EnrolledIndividual.kt | 579 ----------- .../HrisBenefitIndividualUnenrollManyPage.kt | 27 +- ...sBenefitIndividualUnenrollManyPageAsync.kt | 29 +- .../HrisBenefitListSupportedBenefitsPage.kt | 29 +- ...isBenefitListSupportedBenefitsPageAsync.kt | 33 +- .../models/IndividualUnenrollManyResponse.kt | 120 +++ .../tryfinch/api/models/SupportedBenefit.kt | 46 +- .../api/models/UnenrolledIndividual.kt | 442 --------- .../models/UpdateCompanyBenefitResponse.kt | 45 +- .../async/hris/BenefitServiceAsyncImpl.kt | 9 +- .../benefits/IndividualServiceAsyncImpl.kt | 6 +- .../blocking/hris/BenefitServiceImpl.kt | 9 +- .../hris/benefits/IndividualServiceImpl.kt | 6 +- ...enefitListSupportedBenefitsResponseTest.kt | 70 ++ .../CreateCompanyBenefitsResponseTest.kt | 4 + .../api/models/EnrolledIndividualTest.kt | 63 -- .../IndividualUnenrollManyResponseTest.kt | 31 + .../api/models/SupportedBenefitTest.kt | 3 - .../api/models/UnenrolledIndividualTest.kt | 63 -- .../UpdateCompanyBenefitResponseTest.kt | 4 + 23 files changed, 1319 insertions(+), 1266 deletions(-) create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt delete mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt delete mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt delete mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt delete mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/UnenrolledIndividualTest.kt diff --git a/.stats.yml b/.stats.yml index e3e52833..543e5ffc 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 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-8c83f0eae70d2a02ed3e2059fc251affdccd2f848f45445e4fed64dfd9ca5985.yml +openapi_spec_hash: 2523952a32436e3c7fd3b55508c2e7ee config_hash: ce10384813f68ba3fed61c7b601b396b 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/HrisBenefitIndividualUnenrollManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt index 2b7b92b4..8ad68578 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt @@ -29,7 +29,7 @@ private constructor( fun response(): Response = response - fun items(): List = response().items() + fun items(): List = response().items() override fun equals(other: Any?): Boolean { if (this === other) { @@ -69,19 +69,22 @@ private constructor( } class Response( - private val items: JsonField>, + private val items: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() + @JsonProperty("items") + items: JsonField> = JsonMissing.of() ) : this(items, mutableMapOf()) - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() + fun items(): List = + items.getOptional("items").getOrNull() ?: listOf() @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) + fun _items(): Optional>> = + Optional.ofNullable(items) @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -138,7 +141,7 @@ private constructor( class Builder { - private var items: JsonField> = JsonMissing.of() + private var items: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -147,9 +150,11 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun items(items: List) = items(JsonField.of(items)) + fun items(items: List) = items(JsonField.of(items)) - fun items(items: JsonField>) = apply { this.items = items } + fun items(items: JsonField>) = apply { + this.items = items + } fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) @@ -165,9 +170,9 @@ private constructor( } class AutoPager(private val firstPage: HrisBenefitIndividualUnenrollManyPage) : - Iterable { + Iterable { - override fun iterator(): Iterator = iterator { + override fun iterator(): Iterator = iterator { var page = firstPage var index = 0 while (true) { @@ -179,7 +184,7 @@ private constructor( } } - fun stream(): Stream { + 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 index e569d5ee..bdf64d32 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt @@ -30,7 +30,7 @@ private constructor( fun response(): Response = response - fun items(): List = response().items() + fun items(): List = response().items() override fun equals(other: Any?): Boolean { if (this === other) { @@ -72,19 +72,22 @@ private constructor( } class Response( - private val items: JsonField>, + private val items: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() + @JsonProperty("items") + items: JsonField> = JsonMissing.of() ) : this(items, mutableMapOf()) - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() + fun items(): List = + items.getOptional("items").getOrNull() ?: listOf() @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) + fun _items(): Optional>> = + Optional.ofNullable(items) @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -141,7 +144,7 @@ private constructor( class Builder { - private var items: JsonField> = JsonMissing.of() + private var items: JsonField> = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -150,9 +153,11 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun items(items: List) = items(JsonField.of(items)) + fun items(items: List) = items(JsonField.of(items)) - fun items(items: JsonField>) = apply { this.items = items } + fun items(items: JsonField>) = apply { + this.items = items + } fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) @@ -170,11 +175,11 @@ private constructor( class AutoPager(private val firstPage: HrisBenefitIndividualUnenrollManyPageAsync) { fun forEach( - action: Predicate, + action: Predicate, executor: Executor, ): CompletableFuture { fun CompletableFuture>.forEach( - action: (UnenrolledIndividual) -> Boolean, + action: (IndividualUnenrollManyResponse) -> Boolean, executor: Executor, ): CompletableFuture = thenComposeAsync( @@ -190,8 +195,8 @@ 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 } } } 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..5a9a8f87 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 @@ -29,7 +29,7 @@ private constructor( fun response(): Response = response - fun items(): List = response().items() + fun items(): List = response().items() override fun equals(other: Any?): Boolean { if (this === other) { @@ -69,19 +69,22 @@ private constructor( } class Response( - private val items: JsonField>, + private val items: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() + @JsonProperty("items") + items: JsonField> = JsonMissing.of() ) : this(items, mutableMapOf()) - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() + fun items(): List = + items.getOptional("items").getOrNull() ?: listOf() @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) + fun _items(): Optional>> = + Optional.ofNullable(items) @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -138,7 +141,8 @@ private constructor( class Builder { - private var items: JsonField> = JsonMissing.of() + private var items: JsonField> = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -147,9 +151,12 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun items(items: List) = items(JsonField.of(items)) + fun items(items: List) = + items(JsonField.of(items)) - fun items(items: JsonField>) = apply { this.items = items } + fun items(items: JsonField>) = apply { + this.items = items + } fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) @@ -165,9 +172,9 @@ private constructor( } 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,7 +186,7 @@ private constructor( } } - fun stream(): Stream { + fun stream(): Stream { return StreamSupport.stream(spliterator(), false) } } 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..c3938a65 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 @@ -30,7 +30,7 @@ private constructor( fun response(): Response = response - fun items(): List = response().items() + fun items(): List = response().items() override fun equals(other: Any?): Boolean { if (this === other) { @@ -72,19 +72,22 @@ private constructor( } class Response( - private val items: JsonField>, + private val items: JsonField>, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("items") items: JsonField> = JsonMissing.of() + @JsonProperty("items") + items: JsonField> = JsonMissing.of() ) : this(items, mutableMapOf()) - fun items(): List = items.getOptional("items").getOrNull() ?: listOf() + fun items(): List = + items.getOptional("items").getOrNull() ?: listOf() @JsonProperty("items") - fun _items(): Optional>> = Optional.ofNullable(items) + fun _items(): Optional>> = + Optional.ofNullable(items) @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -141,7 +144,8 @@ private constructor( class Builder { - private var items: JsonField> = JsonMissing.of() + private var items: JsonField> = + JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -150,9 +154,12 @@ private constructor( this.additionalProperties.putAll(page.additionalProperties) } - fun items(items: List) = items(JsonField.of(items)) + fun items(items: List) = + items(JsonField.of(items)) - fun items(items: JsonField>) = apply { this.items = items } + fun items(items: JsonField>) = apply { + this.items = items + } fun putAdditionalProperty(key: String, value: JsonValue) = apply { this.additionalProperties.put(key, value) @@ -170,11 +177,11 @@ private constructor( 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,8 +197,10 @@ 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 } } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt new file mode 100644 index 00000000..f568b3c3 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt @@ -0,0 +1,120 @@ +// 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.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects + +class IndividualUnenrollManyResponse +private constructor(private val additionalProperties: MutableMap) { + + @JsonCreator private constructor() : this(mutableMapOf()) + + @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 + * [IndividualUnenrollManyResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [IndividualUnenrollManyResponse]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(individualUnenrollManyResponse: IndividualUnenrollManyResponse) = apply { + additionalProperties = + individualUnenrollManyResponse.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [IndividualUnenrollManyResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): IndividualUnenrollManyResponse = + IndividualUnenrollManyResponse(additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): IndividualUnenrollManyResponse = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = 0 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is IndividualUnenrollManyResponse && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "IndividualUnenrollManyResponse{additionalProperties=$additionalProperties}" +} 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/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/hris/BenefitServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt index b44c2818..56017ac8 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,7 +25,6 @@ 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 @@ -219,8 +219,9 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val listSupportedBenefitsHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listSupportedBenefitsHandler: + Handler> = + jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun listSupportedBenefits( @@ -242,7 +243,7 @@ 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 { 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..600a881e 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 @@ -22,7 +22,7 @@ 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.IndividualUnenrollManyResponse import java.util.concurrent.CompletableFuture class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -130,8 +130,8 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: } } - private val unenrollManyHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val unenrollManyHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun unenrollMany( 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..e7ee97d4 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,7 +25,6 @@ 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 @@ -204,8 +204,9 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO } } - private val listSupportedBenefitsHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val listSupportedBenefitsHandler: + Handler> = + jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun listSupportedBenefits( @@ -225,7 +226,7 @@ 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 { 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..a7e80361 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 @@ -22,7 +22,7 @@ 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.IndividualUnenrollManyResponse class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : IndividualService { @@ -122,8 +122,8 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie } } - private val unenrollManyHandler: Handler> = - jsonHandler>(clientOptions.jsonMapper) + private val unenrollManyHandler: Handler> = + jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun unenrollMany( 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/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/IndividualUnenrollManyResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt new file mode 100644 index 00000000..fca952aa --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt @@ -0,0 +1,31 @@ +// 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 IndividualUnenrollManyResponseTest { + + @Test + fun create() { + val individualUnenrollManyResponse = IndividualUnenrollManyResponse.builder().build() + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val individualUnenrollManyResponse = IndividualUnenrollManyResponse.builder().build() + + val roundtrippedIndividualUnenrollManyResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(individualUnenrollManyResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedIndividualUnenrollManyResponse) + .isEqualTo(individualUnenrollManyResponse) + } +} 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/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 = From 2a19f7ec2159e69798afdb92f6f220254276a5fe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 15:40:07 +0000 Subject: [PATCH 02/13] feat(client): support setting base URL via env var (#535) --- README.md | 21 ++++++++++--------- .../api/client/okhttp/FinchOkHttpClient.kt | 8 ++----- .../client/okhttp/FinchOkHttpClientAsync.kt | 8 ++----- .../com/tryfinch/api/core/ClientOptions.kt | 3 +++ 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index e0b9c13b..40b26b41 100644 --- a/README.md +++ b/README.md @@ -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/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/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) } From ed704657d81ca00bc2e0baf40291d754b343d2aa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 16:32:45 +0000 Subject: [PATCH 03/13] chore(internal): expand CI branch coverage (#536) --- .github/workflows/ci.yml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 94046873..5a6ae118 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,18 +1,18 @@ name: CI on: push: - branches: - - main - pull_request: - branches: - - main - - next + branches-ignore: + - 'generated' + - 'codegen/**' + - 'integrated/**' + - 'preview-head/**' + - 'preview-base/**' + - 'preview/**' jobs: lint: name: lint runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 @@ -34,7 +34,6 @@ jobs: test: name: test runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 From 4b3bc8d9e5a06356889f49afd96b19085c0aedfe Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 17:57:02 +0000 Subject: [PATCH 04/13] fix(client): bump to better jackson version (#537) --- finch-java-core/build.gradle.kts | 12 ++++++------ .../src/main/kotlin/com/tryfinch/api/core/Check.kt | 4 ++++ 2 files changed, 10 insertions(+), 6 deletions(-) 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, From c054662ddf6e98fb805574d6851f8f81933bc07a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 18:06:34 +0000 Subject: [PATCH 05/13] refactor(client): deduplicate page response classes (#538) feat(client): make pagination robust to missing data docs: add comments for page methods --- ...nefitIndividualRetrieveManyBenefitsPage.kt | 132 +---- ...IndividualRetrieveManyBenefitsPageAsync.kt | 133 +---- .../HrisBenefitIndividualUnenrollManyPage.kt | 139 +---- ...sBenefitIndividualUnenrollManyPageAsync.kt | 139 +---- .../api/models/HrisBenefitListPage.kt | 131 +---- .../api/models/HrisBenefitListPageAsync.kt | 131 +---- .../HrisBenefitListSupportedBenefitsPage.kt | 138 +---- ...isBenefitListSupportedBenefitsPageAsync.kt | 139 +---- .../HrisCompanyPayStatementItemListPage.kt | 136 +---- ...risCompanyPayStatementItemListPageAsync.kt | 136 +---- ...CompanyPayStatementItemListPageResponse.kt | 199 ++++++++ ...HrisCompanyPayStatementItemRuleListPage.kt | 135 +---- ...ompanyPayStatementItemRuleListPageAsync.kt | 135 +---- ...anyPayStatementItemRuleListPageResponse.kt | 199 ++++++++ .../HrisDirectoryListIndividualsPage.kt | 164 +----- .../HrisDirectoryListIndividualsPageAsync.kt | 164 +----- ...risDirectoryListIndividualsPageResponse.kt | 234 +++++++++ .../api/models/HrisDirectoryListPage.kt | 163 +----- .../api/models/HrisDirectoryListPageAsync.kt | 164 +----- .../models/HrisDirectoryListPageResponse.kt | 230 +++++++++ .../models/HrisEmploymentRetrieveManyPage.kt | 135 +---- .../HrisEmploymentRetrieveManyPageAsync.kt | 135 +---- .../HrisEmploymentRetrieveManyPageResponse.kt | 197 ++++++++ .../models/HrisIndividualRetrieveManyPage.kt | 134 +---- .../HrisIndividualRetrieveManyPageAsync.kt | 134 +---- .../HrisIndividualRetrieveManyPageResponse.kt | 197 ++++++++ .../HrisPayStatementRetrieveManyPage.kt | 135 +---- .../HrisPayStatementRetrieveManyPageAsync.kt | 135 +---- ...risPayStatementRetrieveManyPageResponse.kt | 198 ++++++++ .../api/models/HrisPaymentListPage.kt | 131 +---- .../api/models/HrisPaymentListPageAsync.kt | 131 +---- .../api/models/PayrollPayGroupListPage.kt | 130 +---- .../models/PayrollPayGroupListPageAsync.kt | 132 +---- .../tryfinch/api/models/ProviderListPage.kt | 131 +---- .../api/models/ProviderListPageAsync.kt | 131 +---- .../async/ProviderServiceAsyncImpl.kt | 2 +- .../async/hris/BenefitServiceAsyncImpl.kt | 13 +- .../async/hris/DirectoryServiceAsyncImpl.kt | 11 +- .../async/hris/EmploymentServiceAsyncImpl.kt | 5 +- .../async/hris/IndividualServiceAsyncImpl.kt | 5 +- .../hris/PayStatementServiceAsyncImpl.kt | 5 +- .../async/hris/PaymentServiceAsyncImpl.kt | 2 +- .../benefits/IndividualServiceAsyncImpl.kt | 9 +- .../PayStatementItemServiceAsyncImpl.kt | 5 +- .../payStatementItem/RuleServiceAsyncImpl.kt | 7 +- .../async/payroll/PayGroupServiceAsyncImpl.kt | 4 +- .../services/blocking/ProviderServiceImpl.kt | 8 +- .../blocking/hris/BenefitServiceImpl.kt | 19 +- .../blocking/hris/DirectoryServiceImpl.kt | 10 +- .../blocking/hris/EmploymentServiceImpl.kt | 5 +- .../blocking/hris/IndividualServiceImpl.kt | 5 +- .../blocking/hris/PayStatementServiceImpl.kt | 5 +- .../blocking/hris/PaymentServiceImpl.kt | 8 +- .../hris/benefits/IndividualServiceImpl.kt | 8 +- .../company/PayStatementItemServiceImpl.kt | 5 +- .../payStatementItem/RuleServiceImpl.kt | 5 +- .../blocking/payroll/PayGroupServiceImpl.kt | 6 +- ...anyPayStatementItemListPageResponseTest.kt | 80 +++ ...ayStatementItemRuleListPageResponseTest.kt | 120 +++++ ...irectoryListIndividualsPageResponseTest.kt | 86 ++++ .../HrisDirectoryListPageResponseTest.kt | 86 ++++ ...sEmploymentRetrieveManyPageResponseTest.kt | 249 +++++++++ ...sIndividualRetrieveManyPageResponseTest.kt | 169 +++++++ ...ayStatementRetrieveManyPageResponseTest.kt | 478 ++++++++++++++++++ .../async/ProviderServiceAsyncTest.kt | 2 +- .../async/hris/BenefitServiceAsyncTest.kt | 4 +- .../async/hris/PaymentServiceAsyncTest.kt | 2 +- .../benefits/IndividualServiceAsyncTest.kt | 4 +- .../async/payroll/PayGroupServiceAsyncTest.kt | 2 +- .../services/blocking/ProviderServiceTest.kt | 2 +- .../blocking/hris/BenefitServiceTest.kt | 4 +- .../blocking/hris/PaymentServiceTest.kt | 2 +- .../hris/benefits/IndividualServiceTest.kt | 4 +- .../blocking/payroll/PayGroupServiceTest.kt | 2 +- 74 files changed, 3191 insertions(+), 3584 deletions(-) create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponse.kt create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponse.kt create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponse.kt create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponse.kt create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponse.kt create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponse.kt create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponse.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageResponseTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageResponseTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisDirectoryListPageResponseTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageResponseTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt 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..0dd2f3f0 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,17 +2,7 @@ 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 @@ -24,33 +14,29 @@ class HrisBenefitIndividualRetrieveManyBenefitsPage private constructor( private val individualsService: IndividualService, private val params: HrisBenefitIndividualRetrieveManyBenefitsParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPage && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, items) /* spotless:on */ override fun toString() = - "HrisBenefitIndividualRetrieveManyBenefitsPage{individualsService=$individualsService, params=$params, response=$response}" + "HrisBenefitIndividualRetrieveManyBenefitsPage{individualsService=$individualsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = + Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { individualsService.retrieveManyBenefits(it) } @@ -64,104 +50,8 @@ private constructor( fun of( individualsService: IndividualService, params: HrisBenefitIndividualRetrieveManyBenefitsParams, - response: Response, - ) = HrisBenefitIndividualRetrieveManyBenefitsPage(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 - * [HrisBenefitIndividualRetrieveManyBenefitsPage]. - */ - @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()) - } + items: List, + ) = HrisBenefitIndividualRetrieveManyBenefitsPage(individualsService, params, items) } class AutoPager(private val firstPage: HrisBenefitIndividualRetrieveManyBenefitsPage) : 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..af12a0b0 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,56 +2,41 @@ 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 /** Get enrollment information for the given individuals. */ class HrisBenefitIndividualRetrieveManyBenefitsPageAsync private constructor( private val individualsService: IndividualServiceAsync, private val params: HrisBenefitIndividualRetrieveManyBenefitsParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = 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 */ + return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPageAsync && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, items) /* spotless:on */ override fun toString() = - "HrisBenefitIndividualRetrieveManyBenefitsPageAsync{individualsService=$individualsService, params=$params, response=$response}" + "HrisBenefitIndividualRetrieveManyBenefitsPageAsync{individualsService=$individualsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = + Optional.empty() fun getNextPage(): CompletableFuture> { @@ -68,104 +53,8 @@ private constructor( 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) - - 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 - * [HrisBenefitIndividualRetrieveManyBenefitsPageAsync]. - */ - @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()) - } + items: List, + ) = HrisBenefitIndividualRetrieveManyBenefitsPageAsync(individualsService, params, items) } class AutoPager(private val firstPage: HrisBenefitIndividualRetrieveManyBenefitsPageAsync) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt index 8ad68578..ae03ec8f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt @@ -2,55 +2,45 @@ 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 +import kotlin.jvm.optionals.toList /** Unenroll individuals from a deduction or contribution */ class HrisBenefitIndividualUnenrollManyPage private constructor( private val individualsService: IndividualService, private val params: HrisBenefitIndividualUnenrollManyParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun items(): List = items - fun items(): List = response().items() + /** Delegates to [List], but gracefully handles missing data. */ + fun items(): List = + items.flatMap { it.toList() }.getOrNull() ?: emptyList() 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 */ + return /* spotless:off */ other is HrisBenefitIndividualUnenrollManyPage && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, items) /* spotless:on */ override fun toString() = - "HrisBenefitIndividualUnenrollManyPage{individualsService=$individualsService, params=$params, response=$response}" + "HrisBenefitIndividualUnenrollManyPage{individualsService=$individualsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { individualsService.unenrollMany(it) } @@ -64,109 +54,8 @@ private constructor( 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()) - } + items: List, + ) = HrisBenefitIndividualUnenrollManyPage(individualsService, params, items) } class AutoPager(private val firstPage: HrisBenefitIndividualUnenrollManyPage) : diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt index bdf64d32..88f96491 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt @@ -2,56 +2,46 @@ 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 +import kotlin.jvm.optionals.toList /** Unenroll individuals from a deduction or contribution */ class HrisBenefitIndividualUnenrollManyPageAsync private constructor( private val individualsService: IndividualServiceAsync, private val params: HrisBenefitIndividualUnenrollManyParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun items(): List = items - fun items(): List = response().items() + /** Delegates to [List], but gracefully handles missing data. */ + fun items(): List = + items.flatMap { it.toList() }.getOrNull() ?: emptyList() 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 */ + return /* spotless:off */ other is HrisBenefitIndividualUnenrollManyPageAsync && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, items) /* spotless:on */ override fun toString() = - "HrisBenefitIndividualUnenrollManyPageAsync{individualsService=$individualsService, params=$params, response=$response}" + "HrisBenefitIndividualUnenrollManyPageAsync{individualsService=$individualsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -67,109 +57,8 @@ private constructor( 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()) - } + items: List, + ) = HrisBenefitIndividualUnenrollManyPageAsync(individualsService, params, items) } class AutoPager(private val firstPage: HrisBenefitIndividualUnenrollManyPageAsync) { 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..f99c7aed 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,17 +2,7 @@ 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.BenefitService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -24,33 +14,28 @@ class HrisBenefitListPage private constructor( private val benefitsService: BenefitService, private val params: HrisBenefitListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is HrisBenefitListPage && benefitsService == other.benefitsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, items) /* spotless:on */ override fun toString() = - "HrisBenefitListPage{benefitsService=$benefitsService, params=$params, response=$response}" + "HrisBenefitListPage{benefitsService=$benefitsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { benefitsService.list(it) } @@ -61,101 +46,11 @@ private constructor( companion object { @JvmStatic - fun of(benefitsService: BenefitService, params: HrisBenefitListParams, response: Response) = - HrisBenefitListPage(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) - - 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 of( + benefitsService: BenefitService, + params: HrisBenefitListParams, + items: List, + ) = HrisBenefitListPage(benefitsService, params, items) } class AutoPager(private val firstPage: HrisBenefitListPage) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt index 1dd66c6b..5274b3a9 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,56 +2,40 @@ 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.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. */ class HrisBenefitListPageAsync private constructor( private val benefitsService: BenefitServiceAsync, private val params: HrisBenefitListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is HrisBenefitListPageAsync && benefitsService == other.benefitsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, items) /* spotless:on */ override fun toString() = - "HrisBenefitListPageAsync{benefitsService=$benefitsService, params=$params, response=$response}" + "HrisBenefitListPageAsync{benefitsService=$benefitsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -67,103 +51,8 @@ private constructor( 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) - - 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 [HrisBenefitListPageAsync]. - */ - @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()) - } + items: List, + ) = HrisBenefitListPageAsync(benefitsService, params, items) } class AutoPager(private val firstPage: HrisBenefitListPageAsync) { 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 5a9a8f87..65bc601f 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,17 +2,7 @@ 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.BenefitService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -24,33 +14,28 @@ class HrisBenefitListSupportedBenefitsPage private constructor( private val benefitsService: BenefitService, private val params: HrisBenefitListSupportedBenefitsParams, - private val response: Response, + private val items: Optional>, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): Optional> = items 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 */ + return /* spotless:off */ other is HrisBenefitListSupportedBenefitsPage && benefitsService == other.benefitsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, items) /* spotless:on */ override fun toString() = - "HrisBenefitListSupportedBenefitsPage{benefitsService=$benefitsService, params=$params, response=$response}" + "HrisBenefitListSupportedBenefitsPage{benefitsService=$benefitsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { benefitsService.listSupportedBenefits(it) } @@ -64,111 +49,8 @@ private constructor( fun of( benefitsService: BenefitService, params: HrisBenefitListSupportedBenefitsParams, - response: Response, - ) = HrisBenefitListSupportedBenefitsPage(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) - - 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 - * [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()) - } + items: Optional>, + ) = HrisBenefitListSupportedBenefitsPage(benefitsService, params, items) } class AutoPager(private val firstPage: HrisBenefitListSupportedBenefitsPage) : diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt index c3938a65..08dea534 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,56 +2,40 @@ 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.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 /** Get deductions metadata */ class HrisBenefitListSupportedBenefitsPageAsync private constructor( private val benefitsService: BenefitServiceAsync, private val params: HrisBenefitListSupportedBenefitsParams, - private val response: Response, + private val items: Optional>, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): Optional> = items 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 */ + return /* spotless:off */ other is HrisBenefitListSupportedBenefitsPageAsync && benefitsService == other.benefitsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, items) /* spotless:on */ override fun toString() = - "HrisBenefitListSupportedBenefitsPageAsync{benefitsService=$benefitsService, params=$params, response=$response}" + "HrisBenefitListSupportedBenefitsPageAsync{benefitsService=$benefitsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -67,111 +51,8 @@ private constructor( 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) - - 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 - * [HrisBenefitListSupportedBenefitsPageAsync]. - */ - @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()) - } + items: Optional>, + ) = HrisBenefitListSupportedBenefitsPageAsync(benefitsService, params, items) } class AutoPager(private val firstPage: HrisBenefitListSupportedBenefitsPageAsync) { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt index fc858012..ce55af68 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,17 +2,7 @@ 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.company.PayStatementItemService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -28,12 +18,20 @@ class HrisCompanyPayStatementItemListPage private constructor( private val payStatementItemService: PayStatementItemService, private val params: HrisCompanyPayStatementItemListParams, - private val response: Response, + private val response: HrisCompanyPayStatementItemListPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemListPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisCompanyPayStatementItemListPageResponse], but gracefully handles missing + * data. + * + * @see [HrisCompanyPayStatementItemListPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -48,13 +46,9 @@ private constructor( override fun toString() = "HrisCompanyPayStatementItemListPage{payStatementItemService=$payStatementItemService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { payStatementItemService.list(it) } @@ -68,112 +62,10 @@ private constructor( fun of( payStatementItemService: PayStatementItemService, params: HrisCompanyPayStatementItemListParams, - response: Response, + response: HrisCompanyPayStatementItemListPageResponse, ) = HrisCompanyPayStatementItemListPage(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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisCompanyPayStatementItemListPage) : Iterable { 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..55743717 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,7 @@ 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.company.PayStatementItemServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -29,12 +19,20 @@ class HrisCompanyPayStatementItemListPageAsync private constructor( private val payStatementItemService: PayStatementItemServiceAsync, private val params: HrisCompanyPayStatementItemListParams, - private val response: Response, + private val response: HrisCompanyPayStatementItemListPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemListPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisCompanyPayStatementItemListPageResponse], but gracefully handles missing + * data. + * + * @see [HrisCompanyPayStatementItemListPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -49,13 +47,9 @@ private constructor( override fun toString() = "HrisCompanyPayStatementItemListPageAsync{payStatementItemService=$payStatementItemService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -71,112 +65,10 @@ private constructor( fun of( payStatementItemService: PayStatementItemServiceAsync, params: HrisCompanyPayStatementItemListParams, - response: Response, + response: HrisCompanyPayStatementItemListPageResponse, ) = 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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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 - * [HrisCompanyPayStatementItemListPageAsync]. - */ - @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()) - } - } - class AutoPager(private val firstPage: HrisCompanyPayStatementItemListPageAsync) { fun forEach( 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..2d27aa04 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,17 +2,7 @@ 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.company.payStatementItem.RuleService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -27,12 +17,20 @@ class HrisCompanyPayStatementItemRuleListPage private constructor( private val rulesService: RuleService, private val params: HrisCompanyPayStatementItemRuleListParams, - private val response: Response, + private val response: HrisCompanyPayStatementItemRuleListPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemRuleListPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisCompanyPayStatementItemRuleListPageResponse], but gracefully handles + * missing data. + * + * @see [HrisCompanyPayStatementItemRuleListPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -47,13 +45,9 @@ private constructor( override fun toString() = "HrisCompanyPayStatementItemRuleListPage{rulesService=$rulesService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { rulesService.list(it) } @@ -67,111 +61,10 @@ private constructor( fun of( rulesService: RuleService, params: HrisCompanyPayStatementItemRuleListParams, - response: Response, + response: HrisCompanyPayStatementItemRuleListPageResponse, ) = HrisCompanyPayStatementItemRuleListPage(rulesService, 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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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() - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisCompanyPayStatementItemRuleListPage) : Iterable { 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..510961b7 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,7 @@ 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.company.payStatementItem.RuleServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -28,12 +18,20 @@ class HrisCompanyPayStatementItemRuleListPageAsync private constructor( private val rulesService: RuleServiceAsync, private val params: HrisCompanyPayStatementItemRuleListParams, - private val response: Response, + private val response: HrisCompanyPayStatementItemRuleListPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemRuleListPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisCompanyPayStatementItemRuleListPageResponse], but gracefully handles + * missing data. + * + * @see [HrisCompanyPayStatementItemRuleListPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -48,13 +46,9 @@ private constructor( override fun toString() = "HrisCompanyPayStatementItemRuleListPageAsync{rulesService=$rulesService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -70,111 +64,10 @@ private constructor( fun of( rulesService: RuleServiceAsync, params: HrisCompanyPayStatementItemRuleListParams, - response: Response, + response: HrisCompanyPayStatementItemRuleListPageResponse, ) = HrisCompanyPayStatementItemRuleListPageAsync(rulesService, 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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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() - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisCompanyPayStatementItemRuleListPageAsync) { fun forEach( 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..976f4206 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,21 +2,12 @@ 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.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 */ @@ -25,14 +16,26 @@ class HrisDirectoryListIndividualsPage private constructor( private val directoryService: DirectoryService, private val params: HrisDirectoryListIndividualsParams, - private val response: Response, + private val response: HrisDirectoryListIndividualsPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisDirectoryListIndividualsPageResponse = response - fun individuals(): List = response().individuals() + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListIndividualsPageResponse.individuals] + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() - fun paging(): Paging = response().paging() + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListIndividualsPageResponse.paging] + */ + fun paging(): Optional = response._paging().getOptional("paging") override fun equals(other: Any?): Boolean { if (this === other) { @@ -52,8 +55,10 @@ private constructor( 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,12 +66,8 @@ 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 { @@ -81,127 +82,10 @@ private constructor( fun of( directoryService: DirectoryService, params: HrisDirectoryListIndividualsParams, - response: Response, + response: HrisDirectoryListIndividualsPageResponse, ) = 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() - - 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 - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - 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 */ - - override fun toString() = - "Response{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisDirectoryListIndividualsPage]. - */ - @JvmStatic fun builder() = Builder() - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisDirectoryListIndividualsPage) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPageAsync.kt index cf3abdf6..58819226 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,22 +2,13 @@ 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.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 */ @@ -26,14 +17,26 @@ class HrisDirectoryListIndividualsPageAsync private constructor( private val directoryService: DirectoryServiceAsync, private val params: HrisDirectoryListIndividualsParams, - private val response: Response, + private val response: HrisDirectoryListIndividualsPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisDirectoryListIndividualsPageResponse = response - fun individuals(): List = response().individuals() + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListIndividualsPageResponse.individuals] + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() - fun paging(): Paging = response().paging() + /** + * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListIndividualsPageResponse.paging] + */ + fun paging(): Optional = response._paging().getOptional("paging") override fun equals(other: Any?): Boolean { if (this === other) { @@ -53,8 +56,10 @@ private constructor( 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,12 +67,8 @@ 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> { @@ -84,127 +85,10 @@ private constructor( fun of( directoryService: DirectoryServiceAsync, params: HrisDirectoryListIndividualsParams, - response: Response, + response: HrisDirectoryListIndividualsPageResponse, ) = 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) - - 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 - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - 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 */ - - override fun toString() = - "Response{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisDirectoryListIndividualsPageAsync]. - */ - @JvmStatic fun builder() = Builder() - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisDirectoryListIndividualsPageAsync) { fun forEach( 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..838dcd26 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,21 +2,12 @@ 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.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 */ @@ -24,14 +15,26 @@ class HrisDirectoryListPage private constructor( private val directoryService: DirectoryService, private val params: HrisDirectoryListParams, - private val response: Response, + private val response: HrisDirectoryListPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisDirectoryListPageResponse = response - fun individuals(): List = response().individuals() + /** + * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListPageResponse.individuals] + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() - fun paging(): Paging = response().paging() + /** + * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListPageResponse.paging] + */ + fun paging(): Optional = response._paging().getOptional("paging") override fun equals(other: Any?): Boolean { if (this === other) { @@ -51,8 +54,10 @@ private constructor( 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,12 +65,8 @@ 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 { @@ -80,126 +81,10 @@ private constructor( fun of( directoryService: DirectoryService, params: HrisDirectoryListParams, - response: Response, + response: HrisDirectoryListPageResponse, ) = 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 - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - 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 */ - - override fun toString() = - "Response{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [HrisDirectoryListPage]. - */ - @JvmStatic fun builder() = Builder() - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisDirectoryListPage) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPageAsync.kt index 44ea4e6e..7c1035e1 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,22 +2,13 @@ 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.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 */ @@ -25,14 +16,26 @@ class HrisDirectoryListPageAsync private constructor( private val directoryService: DirectoryServiceAsync, private val params: HrisDirectoryListParams, - private val response: Response, + private val response: HrisDirectoryListPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisDirectoryListPageResponse = response - fun individuals(): List = response().individuals() + /** + * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListPageResponse.individuals] + */ + fun individuals(): List = + response._individuals().getOptional("individuals").getOrNull() ?: emptyList() - fun paging(): Paging = response().paging() + /** + * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. + * + * @see [HrisDirectoryListPageResponse.paging] + */ + fun paging(): Optional = response._paging().getOptional("paging") override fun equals(other: Any?): Boolean { if (this === other) { @@ -52,8 +55,10 @@ private constructor( 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,12 +66,8 @@ 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> { @@ -83,127 +84,10 @@ private constructor( fun of( directoryService: DirectoryServiceAsync, params: HrisDirectoryListParams, - response: Response, + response: HrisDirectoryListPageResponse, ) = 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 - - 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 - } - - fun toBuilder() = Builder().from(this) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - 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 */ - - override fun toString() = - "Response{individuals=$individuals, paging=$paging, additionalProperties=$additionalProperties}" - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [HrisDirectoryListPageAsync]. - */ - @JvmStatic fun builder() = Builder() - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisDirectoryListPageAsync) { fun forEach( 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..128f6ce1 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,17 +2,7 @@ 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.EmploymentService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -24,12 +14,19 @@ class HrisEmploymentRetrieveManyPage private constructor( private val employmentsService: EmploymentService, private val params: HrisEmploymentRetrieveManyParams, - private val response: Response, + private val response: HrisEmploymentRetrieveManyPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisEmploymentRetrieveManyPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisEmploymentRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisEmploymentRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -44,13 +41,9 @@ private constructor( override fun toString() = "HrisEmploymentRetrieveManyPage{employmentsService=$employmentsService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { employmentsService.retrieveMany(it) } @@ -64,112 +57,10 @@ private constructor( fun of( employmentsService: EmploymentService, params: HrisEmploymentRetrieveManyParams, - response: Response, + response: HrisEmploymentRetrieveManyPageResponse, ) = HrisEmploymentRetrieveManyPage(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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisEmploymentRetrieveManyPage) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt index b786e90f..8298a799 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,7 @@ 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.EmploymentServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -25,12 +15,19 @@ class HrisEmploymentRetrieveManyPageAsync private constructor( private val employmentsService: EmploymentServiceAsync, private val params: HrisEmploymentRetrieveManyParams, - private val response: Response, + private val response: HrisEmploymentRetrieveManyPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisEmploymentRetrieveManyPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisEmploymentRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisEmploymentRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -45,13 +42,9 @@ private constructor( override fun toString() = "HrisEmploymentRetrieveManyPageAsync{employmentsService=$employmentsService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -67,112 +60,10 @@ private constructor( fun of( employmentsService: EmploymentServiceAsync, params: HrisEmploymentRetrieveManyParams, - response: Response, + response: HrisEmploymentRetrieveManyPageResponse, ) = 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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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 - * [HrisEmploymentRetrieveManyPageAsync]. - */ - @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()) - } - } - class AutoPager(private val firstPage: HrisEmploymentRetrieveManyPageAsync) { fun forEach( 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..4ce3f385 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,17 +2,7 @@ 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.IndividualService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -24,12 +14,19 @@ class HrisIndividualRetrieveManyPage private constructor( private val individualsService: IndividualService, private val params: HrisIndividualRetrieveManyParams, - private val response: Response, + private val response: HrisIndividualRetrieveManyPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisIndividualRetrieveManyPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisIndividualRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisIndividualRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -44,13 +41,9 @@ private constructor( override fun toString() = "HrisIndividualRetrieveManyPage{individualsService=$individualsService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { individualsService.retrieveMany(it) } @@ -64,111 +57,10 @@ private constructor( fun of( individualsService: IndividualService, params: HrisIndividualRetrieveManyParams, - response: Response, + response: HrisIndividualRetrieveManyPageResponse, ) = HrisIndividualRetrieveManyPage(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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisIndividualRetrieveManyPage) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt index 8ac7b9d6..c76563e1 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,7 @@ 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.IndividualServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -25,12 +15,19 @@ class HrisIndividualRetrieveManyPageAsync private constructor( private val individualsService: IndividualServiceAsync, private val params: HrisIndividualRetrieveManyParams, - private val response: Response, + private val response: HrisIndividualRetrieveManyPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisIndividualRetrieveManyPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisIndividualRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisIndividualRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -45,13 +42,9 @@ private constructor( override fun toString() = "HrisIndividualRetrieveManyPageAsync{individualsService=$individualsService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -67,111 +60,10 @@ private constructor( fun of( individualsService: IndividualServiceAsync, params: HrisIndividualRetrieveManyParams, - response: Response, + response: HrisIndividualRetrieveManyPageResponse, ) = 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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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 - * [HrisIndividualRetrieveManyPageAsync]. - */ - @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()) - } - } - class AutoPager(private val firstPage: HrisIndividualRetrieveManyPageAsync) { fun forEach( 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..84c61ad2 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,17 +2,7 @@ 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.PayStatementService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -28,12 +18,19 @@ class HrisPayStatementRetrieveManyPage private constructor( private val payStatementsService: PayStatementService, private val params: HrisPayStatementRetrieveManyParams, - private val response: Response, + private val response: HrisPayStatementRetrieveManyPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisPayStatementRetrieveManyPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisPayStatementRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisPayStatementRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -48,13 +45,9 @@ private constructor( override fun toString() = "HrisPayStatementRetrieveManyPage{payStatementsService=$payStatementsService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { payStatementsService.retrieveMany(it) } @@ -68,112 +61,10 @@ private constructor( fun of( payStatementsService: PayStatementService, params: HrisPayStatementRetrieveManyParams, - response: Response, + response: HrisPayStatementRetrieveManyPageResponse, ) = HrisPayStatementRetrieveManyPage(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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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()) - } - } - class AutoPager(private val firstPage: HrisPayStatementRetrieveManyPage) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt index 8ec74337..369a9ee7 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,7 @@ 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.PayStatementServiceAsync -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.concurrent.CompletableFuture @@ -29,12 +19,19 @@ class HrisPayStatementRetrieveManyPageAsync private constructor( private val payStatementsService: PayStatementServiceAsync, private val params: HrisPayStatementRetrieveManyParams, - private val response: Response, + private val response: HrisPayStatementRetrieveManyPageResponse, ) { - fun response(): Response = response + /** Returns the response that this page was parsed from. */ + fun response(): HrisPayStatementRetrieveManyPageResponse = response - fun responses(): List = response().responses() + /** + * Delegates to [HrisPayStatementRetrieveManyPageResponse], but gracefully handles missing data. + * + * @see [HrisPayStatementRetrieveManyPageResponse.responses] + */ + fun responses(): List = + response._responses().getOptional("responses").getOrNull() ?: emptyList() override fun equals(other: Any?): Boolean { if (this === other) { @@ -49,13 +46,9 @@ private constructor( override fun toString() = "HrisPayStatementRetrieveManyPageAsync{payStatementsService=$payStatementsService, params=$params, response=$response}" - fun hasNextPage(): Boolean { - return !responses().isEmpty() - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -71,112 +64,10 @@ private constructor( fun of( payStatementsService: PayStatementServiceAsync, params: HrisPayStatementRetrieveManyParams, - response: Response, + response: HrisPayStatementRetrieveManyPageResponse, ) = 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) - } - - @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 - } - - 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 && responses == other.responses && additionalProperties == other.additionalProperties /* spotless:on */ - } - - 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 - * [HrisPayStatementRetrieveManyPageAsync]. - */ - @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()) - } - } - class AutoPager(private val firstPage: HrisPayStatementRetrieveManyPageAsync) { fun forEach( 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..abfb1a64 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,17 +2,7 @@ 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.PaymentService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -24,33 +14,28 @@ class HrisPaymentListPage private constructor( private val paymentsService: PaymentService, private val params: HrisPaymentListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is HrisPaymentListPage && paymentsService == other.paymentsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(paymentsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(paymentsService, params, items) /* spotless:on */ override fun toString() = - "HrisPaymentListPage{paymentsService=$paymentsService, params=$params, response=$response}" + "HrisPaymentListPage{paymentsService=$paymentsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { paymentsService.list(it) } @@ -61,101 +46,11 @@ private constructor( companion object { @JvmStatic - fun of(paymentsService: PaymentService, params: HrisPaymentListParams, response: Response) = - HrisPaymentListPage(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) - - 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 of( + paymentsService: PaymentService, + params: HrisPaymentListParams, + items: List, + ) = HrisPaymentListPage(paymentsService, params, items) } class AutoPager(private val firstPage: HrisPaymentListPage) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt index c4f2c62f..327da14f 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,56 +2,40 @@ 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.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. */ class HrisPaymentListPageAsync private constructor( private val paymentsService: PaymentServiceAsync, private val params: HrisPaymentListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is HrisPaymentListPageAsync && paymentsService == other.paymentsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(paymentsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(paymentsService, params, items) /* spotless:on */ override fun toString() = - "HrisPaymentListPageAsync{paymentsService=$paymentsService, params=$params, response=$response}" + "HrisPaymentListPageAsync{paymentsService=$paymentsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -67,103 +51,8 @@ private constructor( 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) - - 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 [HrisPaymentListPageAsync]. - */ - @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()) - } + items: List, + ) = HrisPaymentListPageAsync(paymentsService, params, items) } class AutoPager(private val firstPage: HrisPaymentListPageAsync) { 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..9de2c369 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,17 +2,7 @@ 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.payroll.PayGroupService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -24,33 +14,28 @@ class PayrollPayGroupListPage private constructor( private val payGroupsService: PayGroupService, private val params: PayrollPayGroupListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is PayrollPayGroupListPage && payGroupsService == other.payGroupsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payGroupsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(payGroupsService, params, items) /* spotless:on */ override fun toString() = - "PayrollPayGroupListPage{payGroupsService=$payGroupsService, params=$params, response=$response}" + "PayrollPayGroupListPage{payGroupsService=$payGroupsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { payGroupsService.list(it) } @@ -64,103 +49,8 @@ private constructor( fun of( payGroupsService: PayGroupService, params: PayrollPayGroupListParams, - response: Response, - ) = PayrollPayGroupListPage(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) - - 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()) - } + items: List, + ) = PayrollPayGroupListPage(payGroupsService, params, items) } class AutoPager(private val firstPage: PayrollPayGroupListPage) : 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..40752dec 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,56 +2,40 @@ 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.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 */ class PayrollPayGroupListPageAsync private constructor( private val payGroupsService: PayGroupServiceAsync, private val params: PayrollPayGroupListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is PayrollPayGroupListPageAsync && payGroupsService == other.payGroupsService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payGroupsService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(payGroupsService, params, items) /* spotless:on */ override fun toString() = - "PayrollPayGroupListPageAsync{payGroupsService=$payGroupsService, params=$params, response=$response}" + "PayrollPayGroupListPageAsync{payGroupsService=$payGroupsService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -67,104 +51,8 @@ private constructor( 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) - - 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 - * [PayrollPayGroupListPageAsync]. - */ - @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()) - } + items: List, + ) = PayrollPayGroupListPageAsync(payGroupsService, params, items) } class AutoPager(private val firstPage: PayrollPayGroupListPageAsync) { 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..946b84fe 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,17 +2,7 @@ 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.ProviderService -import java.util.Collections import java.util.Objects import java.util.Optional import java.util.stream.Stream @@ -24,33 +14,28 @@ class ProviderListPage private constructor( private val providersService: ProviderService, private val params: ProviderListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is ProviderListPage && providersService == other.providersService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(providersService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(providersService, params, items) /* spotless:on */ override fun toString() = - "ProviderListPage{providersService=$providersService, params=$params, response=$response}" + "ProviderListPage{providersService=$providersService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): Optional { return getNextPageParams().map { providersService.list(it) } @@ -61,101 +46,11 @@ private constructor( companion object { @JvmStatic - fun of(providersService: ProviderService, params: ProviderListParams, response: Response) = - ProviderListPage(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) - - 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 of( + providersService: ProviderService, + params: ProviderListParams, + items: List, + ) = ProviderListPage(providersService, params, items) } class AutoPager(private val firstPage: ProviderListPage) : Iterable { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt index d8d7a8e1..1e416f73 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,56 +2,40 @@ 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.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. */ class ProviderListPageAsync private constructor( private val providersService: ProviderServiceAsync, private val params: ProviderListParams, - private val response: Response, + private val items: List, ) { - fun response(): Response = response - - fun items(): List = response().items() + /** Returns the response that this page was parsed from. */ + fun items(): List = items 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 */ + return /* spotless:off */ other is ProviderListPageAsync && providersService == other.providersService && params == other.params && items == other.items /* spotless:on */ } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(providersService, params, response) /* spotless:on */ + override fun hashCode(): Int = /* spotless:off */ Objects.hash(providersService, params, items) /* spotless:on */ override fun toString() = - "ProviderListPageAsync{providersService=$providersService, params=$params, response=$response}" + "ProviderListPageAsync{providersService=$providersService, params=$params, items=$items}" - fun hasNextPage(): Boolean { - return !items().isEmpty() - } + fun hasNextPage(): Boolean = items.isNotEmpty() - fun getNextPageParams(): Optional { - return Optional.empty() - } + fun getNextPageParams(): Optional = Optional.empty() fun getNextPage(): CompletableFuture> { return getNextPageParams() @@ -67,103 +51,8 @@ private constructor( 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) - - 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 [ProviderListPageAsync]. - */ - @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()) - } + items: List, + ) = ProviderListPageAsync(providersService, params, items) } class AutoPager(private val firstPage: ProviderListPageAsync) { 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..1aed912f 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 @@ -69,7 +69,7 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C ProviderListPageAsync.of( ProviderServiceAsyncImpl(clientOptions), params, - ProviderListPageAsync.Response.builder().items(it).build(), + it, ) } } 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 56017ac8..3bca46b9 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 @@ -28,6 +28,7 @@ import com.tryfinch.api.models.HrisBenefitUpdateParams 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) : @@ -212,7 +213,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl HrisBenefitListPageAsync.of( BenefitServiceAsyncImpl(clientOptions), params, - HrisBenefitListPageAsync.Response.builder().items(it).build(), + it, ) } } @@ -220,8 +221,10 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl } private val listSupportedBenefitsHandler: - Handler> = - jsonHandler>(clientOptions.jsonMapper) + Handler>> = + jsonHandler>>( + clientOptions.jsonMapper + ) .withErrorHandler(errorHandler) override fun listSupportedBenefits( @@ -250,9 +253,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl HrisBenefitListSupportedBenefitsPageAsync.of( BenefitServiceAsyncImpl(clientOptions), params, - HrisBenefitListSupportedBenefitsPageAsync.Response.builder() - .items(it) - .build(), + it, ) } } 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..00974814 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( @@ -86,9 +88,8 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: } } - private val listIndividualsHandler: - Handler = - jsonHandler(clientOptions.jsonMapper) + private val listIndividualsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @Deprecated("use `list` instead") 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..d7b724b3 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( 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..f8bffb62 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( 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..b022515e 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( 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..1865fb77 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 @@ -69,7 +69,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl HrisPaymentListPageAsync.of( PaymentServiceAsyncImpl(clientOptions), params, - HrisPaymentListPageAsync.Response.builder().items(it).build(), + it, ) } } 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 600a881e..f7e4750d 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 @@ -120,10 +120,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: HrisBenefitIndividualRetrieveManyBenefitsPageAsync.of( IndividualServiceAsyncImpl(clientOptions), params, - HrisBenefitIndividualRetrieveManyBenefitsPageAsync.Response - .builder() - .items(it) - .build(), + it, ) } } @@ -161,9 +158,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: HrisBenefitIndividualUnenrollManyPageAsync.of( IndividualServiceAsyncImpl(clientOptions), params, - HrisBenefitIndividualUnenrollManyPageAsync.Response.builder() - .items(it) - .build(), + it, ) } } 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..5c9634dd 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( 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..d3d5726f 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( 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..4059ca8b 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 @@ -109,9 +109,7 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C PayrollPayGroupListPageAsync.of( PayGroupServiceAsyncImpl(clientOptions), params, - PayrollPayGroupListPageAsync.Response.builder() - .items(it) - .build(), + it, ) } } 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..c371b21c 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 @@ -62,13 +62,7 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client it.forEach { it.validate() } } } - .let { - ProviderListPage.of( - ProviderServiceImpl(clientOptions), - params, - ProviderListPage.Response.builder().items(it).build(), - ) - } + .let { ProviderListPage.of(ProviderServiceImpl(clientOptions), params, it) } } } } 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 e7ee97d4..08445899 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 @@ -28,6 +28,7 @@ import com.tryfinch.api.models.HrisBenefitUpdateParams 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 { @@ -194,19 +195,15 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO it.forEach { it.validate() } } } - .let { - HrisBenefitListPage.of( - BenefitServiceImpl(clientOptions), - params, - HrisBenefitListPage.Response.builder().items(it).build(), - ) - } + .let { HrisBenefitListPage.of(BenefitServiceImpl(clientOptions), params, it) } } } private val listSupportedBenefitsHandler: - Handler> = - jsonHandler>(clientOptions.jsonMapper) + Handler>> = + jsonHandler>>( + clientOptions.jsonMapper + ) .withErrorHandler(errorHandler) override fun listSupportedBenefits( @@ -233,9 +230,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO HrisBenefitListSupportedBenefitsPage.of( BenefitServiceImpl(clientOptions), params, - HrisBenefitListSupportedBenefitsPage.Response.builder() - .items(it) - .build(), + it, ) } } 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..ed699622 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( @@ -78,8 +80,8 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien } } - private val listIndividualsHandler: Handler = - jsonHandler(clientOptions.jsonMapper) + private val listIndividualsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) @Deprecated("use `list` instead") 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..804b5376 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( 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..09dbfe4c 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( 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..56cd9d5d 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( 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..a28d1aed 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 @@ -62,13 +62,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO it.forEach { it.validate() } } } - .let { - HrisPaymentListPage.of( - PaymentServiceImpl(clientOptions), - params, - HrisPaymentListPage.Response.builder().items(it).build(), - ) - } + .let { HrisPaymentListPage.of(PaymentServiceImpl(clientOptions), params, it) } } } } 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 a7e80361..a7b88f24 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 @@ -114,9 +114,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie HrisBenefitIndividualRetrieveManyBenefitsPage.of( IndividualServiceImpl(clientOptions), params, - HrisBenefitIndividualRetrieveManyBenefitsPage.Response.builder() - .items(it) - .build(), + it, ) } } @@ -151,9 +149,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie HrisBenefitIndividualUnenrollManyPage.of( IndividualServiceImpl(clientOptions), params, - HrisBenefitIndividualUnenrollManyPage.Response.builder() - .items(it) - .build(), + it, ) } } 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..3868e4bb 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( 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..af2941f2 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( 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..3be34de8 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,7 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client } } .let { - PayrollPayGroupListPage.of( - PayGroupServiceImpl(clientOptions), - params, - PayrollPayGroupListPage.Response.builder().items(it).build(), - ) + PayrollPayGroupListPage.of(PayGroupServiceImpl(clientOptions), params, it) } } } 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/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..bb31f78d 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 @@ -66,6 +66,6 @@ internal class IndividualServiceAsyncTest { ) 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/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..8a74402c 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 @@ -63,6 +63,6 @@ internal class IndividualServiceTest { HrisBenefitIndividualUnenrollManyParams.builder().benefitId("benefit_id").build() ) - page.response().validate() + page.items().forEach { it.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() } } } From 4d1722feebfff70b762a41c6ea7c7a72299de8a8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:08:40 +0000 Subject: [PATCH 06/13] feat(api): benefits mutation API endpoints (create benefit, update benefit, enroll individual, unenroll individual) now properly return async response types (#539) --- .stats.yml | 4 +- .../api/models/EnrolledIndividualBenifit.kt | 169 ++++++++++++++++++ .../HrisBenefitIndividualUnenrollManyPage.kt | 80 --------- ...sBenefitIndividualUnenrollManyPageAsync.kt | 92 ---------- .../models/IndividualUnenrollManyResponse.kt | 65 ++++++- .../hris/benefits/IndividualServiceAsync.kt | 10 +- .../benefits/IndividualServiceAsyncImpl.kt | 18 +- .../hris/benefits/IndividualService.kt | 10 +- .../hris/benefits/IndividualServiceImpl.kt | 18 +- .../models/EnrolledIndividualBenifitTest.kt | 39 ++++ .../IndividualUnenrollManyResponseTest.kt | 13 +- .../benefits/IndividualServiceAsyncTest.kt | 11 +- .../hris/benefits/IndividualServiceTest.kt | 9 +- 13 files changed, 312 insertions(+), 226 deletions(-) create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifit.kt delete mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt delete mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifitTest.kt diff --git a/.stats.yml b/.stats.yml index 543e5ffc..60191858 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-8c83f0eae70d2a02ed3e2059fc251affdccd2f848f45445e4fed64dfd9ca5985.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bf858f37d7ab420841ddc6329dad8c46377308b6a5c8e935908011d0f9845e22.yml openapi_spec_hash: 2523952a32436e3c7fd3b55508c2e7ee -config_hash: ce10384813f68ba3fed61c7b601b396b +config_hash: 4a8def48077df6382ed9fe00588baecf diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifit.kt new file mode 100644 index 00000000..29b0494d --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifit.kt @@ -0,0 +1,169 @@ +// 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 EnrolledIndividualBenifit +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 [EnrolledIndividualBenifit]. + * + * The following fields are required: + * ```java + * .jobId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EnrolledIndividualBenifit]. */ + class Builder internal constructor() { + + private var jobId: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(enrolledIndividualBenifit: EnrolledIndividualBenifit) = apply { + jobId = enrolledIndividualBenifit.jobId + additionalProperties = enrolledIndividualBenifit.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 [EnrolledIndividualBenifit]. + * + * 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(): EnrolledIndividualBenifit = + EnrolledIndividualBenifit( + checkRequired("jobId", jobId), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EnrolledIndividualBenifit = 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 EnrolledIndividualBenifit && 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() = + "EnrolledIndividualBenifit{jobId=$jobId, additionalProperties=$additionalProperties}" +} 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 ae03ec8f..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPage.kt +++ /dev/null @@ -1,80 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.tryfinch.api.models - -import com.tryfinch.api.services.blocking.hris.benefits.IndividualService -import java.util.Objects -import java.util.Optional -import java.util.stream.Stream -import java.util.stream.StreamSupport -import kotlin.jvm.optionals.getOrNull -import kotlin.jvm.optionals.toList - -/** Unenroll individuals from a deduction or contribution */ -class HrisBenefitIndividualUnenrollManyPage -private constructor( - private val individualsService: IndividualService, - private val params: HrisBenefitIndividualUnenrollManyParams, - private val items: List, -) { - - /** Returns the response that this page was parsed from. */ - fun items(): List = items - - /** Delegates to [List], but gracefully handles missing data. */ - fun items(): List = - items.flatMap { it.toList() }.getOrNull() ?: emptyList() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitIndividualUnenrollManyPage && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, items) /* spotless:on */ - - override fun toString() = - "HrisBenefitIndividualUnenrollManyPage{individualsService=$individualsService, params=$params, items=$items}" - - fun hasNextPage(): Boolean = items.isNotEmpty() - - fun getNextPageParams(): Optional = 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, - items: List, - ) = HrisBenefitIndividualUnenrollManyPage(individualsService, params, items) - } - - 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 88f96491..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyPageAsync.kt +++ /dev/null @@ -1,92 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.tryfinch.api.models - -import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync -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 -import kotlin.jvm.optionals.toList - -/** Unenroll individuals from a deduction or contribution */ -class HrisBenefitIndividualUnenrollManyPageAsync -private constructor( - private val individualsService: IndividualServiceAsync, - private val params: HrisBenefitIndividualUnenrollManyParams, - private val items: List, -) { - - /** Returns the response that this page was parsed from. */ - fun items(): List = items - - /** Delegates to [List], but gracefully handles missing data. */ - fun items(): List = - items.flatMap { it.toList() }.getOrNull() ?: emptyList() - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitIndividualUnenrollManyPageAsync && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, items) /* spotless:on */ - - override fun toString() = - "HrisBenefitIndividualUnenrollManyPageAsync{individualsService=$individualsService, params=$params, items=$items}" - - fun hasNextPage(): Boolean = items.isNotEmpty() - - fun getNextPageParams(): Optional = 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, - items: List, - ) = HrisBenefitIndividualUnenrollManyPageAsync(individualsService, params, items) - } - - class AutoPager(private val firstPage: HrisBenefitIndividualUnenrollManyPageAsync) { - - fun forEach( - action: Predicate, - executor: Executor, - ): CompletableFuture { - fun CompletableFuture>.forEach( - action: (IndividualUnenrollManyResponse) -> 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/IndividualUnenrollManyResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt index f568b3c3..6641101c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt @@ -5,16 +5,39 @@ 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 IndividualUnenrollManyResponse -private constructor(private val additionalProperties: MutableMap) { +private constructor( + private val jobId: JsonField, + private val additionalProperties: MutableMap, +) { - @JsonCreator private constructor() : this(mutableMapOf()) + @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) { @@ -33,6 +56,11 @@ private constructor(private val additionalProperties: MutableMap? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(individualUnenrollManyResponse: IndividualUnenrollManyResponse) = apply { + jobId = individualUnenrollManyResponse.jobId additionalProperties = individualUnenrollManyResponse.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) @@ -71,9 +111,19 @@ private constructor(private val additionalProperties: MutableMap = + ): 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 f7e4750d..2ea6a3b6 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,7 +18,6 @@ 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 @@ -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() } @@ -127,14 +126,14 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: } } - 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) @@ -151,16 +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, - it, - ) - } } } } 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..e6f88fd1 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.IndividualUnenrollManyResponse interface IndividualService { @@ -44,13 +44,13 @@ interface IndividualService { /** Unenroll individuals from a deduction or contribution */ fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams - ): HrisBenefitIndividualUnenrollManyPage = unenrollMany(params, RequestOptions.none()) + ): IndividualUnenrollManyResponse = unenrollMany(params, RequestOptions.none()) /** @see [unenrollMany] */ fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): HrisBenefitIndividualUnenrollManyPage + ): IndividualUnenrollManyResponse /** 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 a7b88f24..ca75feab 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,7 +18,6 @@ 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 @@ -50,7 +49,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions, - ): HrisBenefitIndividualUnenrollManyPage = + ): IndividualUnenrollManyResponse = // delete /employer/benefits/{benefit_id}/individuals withRawResponse().unenrollMany(params, requestOptions).parse() @@ -120,14 +119,14 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie } } - 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) @@ -142,16 +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, - it, - ) - } } } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifitTest.kt new file mode 100644 index 00000000..633d13fb --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifitTest.kt @@ -0,0 +1,39 @@ +// 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 EnrolledIndividualBenifitTest { + + @Test + fun create() { + val enrolledIndividualBenifit = + EnrolledIndividualBenifit.builder() + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(enrolledIndividualBenifit.jobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val enrolledIndividualBenifit = + EnrolledIndividualBenifit.builder() + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedEnrolledIndividualBenifit = + jsonMapper.readValue( + jsonMapper.writeValueAsString(enrolledIndividualBenifit), + jacksonTypeRef(), + ) + + assertThat(roundtrippedEnrolledIndividualBenifit).isEqualTo(enrolledIndividualBenifit) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt index fca952aa..f5ad98fe 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt @@ -11,13 +11,22 @@ internal class IndividualUnenrollManyResponseTest { @Test fun create() { - val individualUnenrollManyResponse = IndividualUnenrollManyResponse.builder().build() + val individualUnenrollManyResponse = + IndividualUnenrollManyResponse.builder() + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(individualUnenrollManyResponse.jobId()) + .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val individualUnenrollManyResponse = IndividualUnenrollManyResponse.builder().build() + val individualUnenrollManyResponse = + IndividualUnenrollManyResponse.builder() + .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() val roundtrippedIndividualUnenrollManyResponse = jsonMapper.readValue( 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 bb31f78d..bd192a83 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 @@ -60,12 +60,15 @@ internal class IndividualServiceAsyncTest { .build() val individualServiceAsync = client.hris().benefits().individuals() - val pageFuture = + val responseFuture = individualServiceAsync.unenrollMany( - HrisBenefitIndividualUnenrollManyParams.builder().benefitId("benefit_id").build() + HrisBenefitIndividualUnenrollManyParams.builder() + .benefitId("benefit_id") + .addIndividualId("string") + .build() ) - val page = pageFuture.get() - page.items().forEach { it.validate() } + val response = responseFuture.get() + response.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 8a74402c..9e5ffd30 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 @@ -58,11 +58,14 @@ internal class IndividualServiceTest { .build() val individualService = client.hris().benefits().individuals() - val page = + val response = individualService.unenrollMany( - HrisBenefitIndividualUnenrollManyParams.builder().benefitId("benefit_id").build() + HrisBenefitIndividualUnenrollManyParams.builder() + .benefitId("benefit_id") + .addIndividualId("string") + .build() ) - page.items().forEach { it.validate() } + response.validate() } } From c56d73d2d29464841ec771edfa791fda80fb073f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:10:55 +0000 Subject: [PATCH 07/13] chore: fix typo (#540) --- .stats.yml | 2 +- ...enifit.kt => EnrolledIndividualBenefit.kt} | 24 +++++++++---------- ...st.kt => EnrolledIndividualBenefitTest.kt} | 20 ++++++++-------- 3 files changed, 23 insertions(+), 23 deletions(-) rename finch-java-core/src/main/kotlin/com/tryfinch/api/models/{EnrolledIndividualBenifit.kt => EnrolledIndividualBenefit.kt} (89%) rename finch-java-core/src/test/kotlin/com/tryfinch/api/models/{EnrolledIndividualBenifitTest.kt => EnrolledIndividualBenefitTest.kt} (59%) diff --git a/.stats.yml b/.stats.yml index 60191858..ea775314 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-bf858f37d7ab420841ddc6329dad8c46377308b6a5c8e935908011d0f9845e22.yml openapi_spec_hash: 2523952a32436e3c7fd3b55508c2e7ee -config_hash: 4a8def48077df6382ed9fe00588baecf +config_hash: 9faa2458e0e8bb125bf5d41e514a19e7 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefit.kt similarity index 89% rename from finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifit.kt rename to finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefit.kt index 29b0494d..cd4a00b1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefit.kt @@ -15,7 +15,7 @@ import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects -class EnrolledIndividualBenifit +class EnrolledIndividualBenefit private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, @@ -54,7 +54,7 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EnrolledIndividualBenifit]. + * Returns a mutable builder for constructing an instance of [EnrolledIndividualBenefit]. * * The following fields are required: * ```java @@ -64,16 +64,16 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EnrolledIndividualBenifit]. */ + /** A builder for [EnrolledIndividualBenefit]. */ class Builder internal constructor() { private var jobId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(enrolledIndividualBenifit: EnrolledIndividualBenifit) = apply { - jobId = enrolledIndividualBenifit.jobId - additionalProperties = enrolledIndividualBenifit.additionalProperties.toMutableMap() + internal fun from(enrolledIndividualBenefit: EnrolledIndividualBenefit) = apply { + jobId = enrolledIndividualBenefit.jobId + additionalProperties = enrolledIndividualBenefit.additionalProperties.toMutableMap() } fun jobId(jobId: String) = jobId(JsonField.of(jobId)) @@ -106,7 +106,7 @@ private constructor( } /** - * Returns an immutable instance of [EnrolledIndividualBenifit]. + * Returns an immutable instance of [EnrolledIndividualBenefit]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -117,8 +117,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EnrolledIndividualBenifit = - EnrolledIndividualBenifit( + fun build(): EnrolledIndividualBenefit = + EnrolledIndividualBenefit( checkRequired("jobId", jobId), additionalProperties.toMutableMap(), ) @@ -126,7 +126,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EnrolledIndividualBenifit = apply { + fun validate(): EnrolledIndividualBenefit = apply { if (validated) { return@apply } @@ -155,7 +155,7 @@ private constructor( return true } - return /* spotless:off */ other is EnrolledIndividualBenifit && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnrolledIndividualBenefit && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -165,5 +165,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EnrolledIndividualBenifit{jobId=$jobId, additionalProperties=$additionalProperties}" + "EnrolledIndividualBenefit{jobId=$jobId, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitTest.kt similarity index 59% rename from finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifitTest.kt rename to finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitTest.kt index 633d13fb..110db778 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenifitTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitTest.kt @@ -7,33 +7,33 @@ import com.tryfinch.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class EnrolledIndividualBenifitTest { +internal class EnrolledIndividualBenefitTest { @Test fun create() { - val enrolledIndividualBenifit = - EnrolledIndividualBenifit.builder() + val enrolledIndividualBenefit = + EnrolledIndividualBenefit.builder() .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - assertThat(enrolledIndividualBenifit.jobId()) + assertThat(enrolledIndividualBenefit.jobId()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val enrolledIndividualBenifit = - EnrolledIndividualBenifit.builder() + val enrolledIndividualBenefit = + EnrolledIndividualBenefit.builder() .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val roundtrippedEnrolledIndividualBenifit = + val roundtrippedEnrolledIndividualBenefit = jsonMapper.readValue( - jsonMapper.writeValueAsString(enrolledIndividualBenifit), - jacksonTypeRef(), + jsonMapper.writeValueAsString(enrolledIndividualBenefit), + jacksonTypeRef(), ) - assertThat(roundtrippedEnrolledIndividualBenifit).isEqualTo(enrolledIndividualBenifit) + assertThat(roundtrippedEnrolledIndividualBenefit).isEqualTo(enrolledIndividualBenefit) } } From 5463e75521312f9b219be62a6c7b4d090bec0754 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:30:01 +0000 Subject: [PATCH 08/13] refactor(client): migrate pages to builder pattern (#541) --- ...nefitIndividualRetrieveManyBenefitsPage.kt | 112 ++++++++++++---- ...IndividualRetrieveManyBenefitsPageAsync.kt | 116 +++++++++++++---- .../api/models/HrisBenefitListPage.kt | 102 +++++++++++---- .../api/models/HrisBenefitListPageAsync.kt | 108 ++++++++++++---- .../HrisBenefitListSupportedBenefitsPage.kt | 109 ++++++++++++---- ...isBenefitListSupportedBenefitsPageAsync.kt | 113 ++++++++++++---- .../HrisCompanyPayStatementItemListPage.kt | 115 ++++++++++++----- ...risCompanyPayStatementItemListPageAsync.kt | 119 ++++++++++++----- ...HrisCompanyPayStatementItemRuleListPage.kt | 116 ++++++++++++----- ...ompanyPayStatementItemRuleListPageAsync.kt | 121 +++++++++++++----- .../HrisDirectoryListIndividualsPage.kt | 112 ++++++++++++---- .../HrisDirectoryListIndividualsPageAsync.kt | 115 +++++++++++++---- .../api/models/HrisDirectoryListPage.kt | 108 ++++++++++++---- .../api/models/HrisDirectoryListPageAsync.kt | 110 ++++++++++++---- .../models/HrisEmploymentRetrieveManyPage.kt | 109 ++++++++++++---- .../HrisEmploymentRetrieveManyPageAsync.kt | 115 +++++++++++++---- .../models/HrisIndividualRetrieveManyPage.kt | 109 ++++++++++++---- .../HrisIndividualRetrieveManyPageAsync.kt | 115 +++++++++++++---- .../HrisPayStatementRetrieveManyPage.kt | 114 ++++++++++++----- .../HrisPayStatementRetrieveManyPageAsync.kt | 119 ++++++++++++----- .../api/models/HrisPaymentListPage.kt | 102 +++++++++++---- .../api/models/HrisPaymentListPageAsync.kt | 108 ++++++++++++---- .../api/models/PayrollPayGroupListPage.kt | 104 +++++++++++---- .../models/PayrollPayGroupListPageAsync.kt | 108 ++++++++++++---- .../tryfinch/api/models/ProviderListPage.kt | 102 +++++++++++---- .../api/models/ProviderListPageAsync.kt | 108 ++++++++++++---- .../async/ProviderServiceAsyncImpl.kt | 10 +- .../async/hris/BenefitServiceAsyncImpl.kt | 20 +-- .../async/hris/DirectoryServiceAsyncImpl.kt | 20 +-- .../async/hris/EmploymentServiceAsyncImpl.kt | 10 +- .../async/hris/IndividualServiceAsyncImpl.kt | 10 +- .../hris/PayStatementServiceAsyncImpl.kt | 10 +- .../async/hris/PaymentServiceAsyncImpl.kt | 10 +- .../benefits/IndividualServiceAsyncImpl.kt | 10 +- .../PayStatementItemServiceAsyncImpl.kt | 10 +- .../payStatementItem/RuleServiceAsyncImpl.kt | 10 +- .../async/payroll/PayGroupServiceAsyncImpl.kt | 10 +- .../services/blocking/ProviderServiceImpl.kt | 8 +- .../blocking/hris/BenefitServiceImpl.kt | 18 ++- .../blocking/hris/DirectoryServiceImpl.kt | 16 ++- .../blocking/hris/EmploymentServiceImpl.kt | 10 +- .../blocking/hris/IndividualServiceImpl.kt | 10 +- .../blocking/hris/PayStatementServiceImpl.kt | 10 +- .../blocking/hris/PaymentServiceImpl.kt | 8 +- .../hris/benefits/IndividualServiceImpl.kt | 10 +- .../company/PayStatementItemServiceImpl.kt | 10 +- .../payStatementItem/RuleServiceImpl.kt | 10 +- .../blocking/payroll/PayGroupServiceImpl.kt | 6 +- 48 files changed, 2309 insertions(+), 826 deletions(-) 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 0dd2f3f0..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.benefits.IndividualService import java.util.Objects import java.util.Optional @@ -9,49 +10,95 @@ 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = + Optional.empty() - return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPage && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): Optional = + getNextPageParams().map { service.retrieveManyBenefits(it) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "HrisBenefitIndividualRetrieveManyBenefitsPage{individualsService=$individualsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitIndividualRetrieveManyBenefitsParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = - Optional.empty() + fun toBuilder() = Builder().from(this) + + companion object { - fun getNextPage(): Optional { - return getNextPageParams().map { individualsService.retrieveManyBenefits(it) } + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitIndividualRetrieveManyBenefitsPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** 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 + } - companion object { + fun service(service: IndividualService) = apply { this.service = service } - @JvmStatic - fun of( - individualsService: IndividualService, - params: HrisBenefitIndividualRetrieveManyBenefitsParams, - items: List, - ) = HrisBenefitIndividualRetrieveManyBenefitsPage(individualsService, params, items) + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitIndividualRetrieveManyBenefitsParams) = 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 [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) : @@ -73,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 af12a0b0..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync import java.util.Objects import java.util.Optional @@ -9,52 +10,98 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -/** 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HrisBenefitIndividualRetrieveManyBenefitsPageAsync && individualsService == other.individualsService && params == other.params && items == other.items /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(individualsService, params, items) /* spotless:on */ - - override fun toString() = - "HrisBenefitIndividualRetrieveManyBenefitsPageAsync{individualsService=$individualsService, params=$params, items=$items}" - fun hasNextPage(): Boolean = items.isNotEmpty() 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) + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitIndividualRetrieveManyBenefitsParams = params + + /** The response that this page was parsed from. */ + fun items(): List = items + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - individualsService: IndividualServiceAsync, - params: HrisBenefitIndividualRetrieveManyBenefitsParams, - items: List, - ) = HrisBenefitIndividualRetrieveManyBenefitsPageAsync(individualsService, params, items) + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitIndividualRetrieveManyBenefitsPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 + } + + fun service(service: IndividualServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitIndividualRetrieveManyBenefitsParams) = 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 [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) { @@ -86,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/HrisBenefitListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt index f99c7aed..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.BenefitService import java.util.Objects import java.util.Optional @@ -9,48 +10,87 @@ 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisBenefitListPage && benefitsService == other.benefitsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "HrisBenefitListPage{benefitsService=$benefitsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitListParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) + + companion object { - fun getNextPage(): Optional { - return getNextPageParams().map { benefitsService.list(it) } + /** + * Returns a mutable builder for constructing an instance of [HrisBenefitListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisBenefitListPage]. */ + class Builder internal constructor() { - companion object { + private var service: BenefitService? = null + private var params: HrisBenefitListParams? = null + private var items: List? = null + + @JvmSynthetic + internal fun from(hrisBenefitListPage: HrisBenefitListPage) = apply { + service = hrisBenefitListPage.service + params = hrisBenefitListPage.params + items = hrisBenefitListPage.items + } - @JvmStatic - fun of( - benefitsService: BenefitService, - params: HrisBenefitListParams, - items: List, - ) = HrisBenefitListPage(benefitsService, params, items) + 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 { @@ -71,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 5274b3a9..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.BenefitServiceAsync import java.util.Objects import java.util.Optional @@ -9,50 +10,90 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -/** 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisBenefitListPageAsync && benefitsService == other.benefitsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "HrisBenefitListPageAsync{benefitsService=$benefitsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitListParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { benefitsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + companion object { + + /** + * Returns a mutable builder for constructing an instance of [HrisBenefitListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** 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 + + @JvmSynthetic + internal fun from(hrisBenefitListPageAsync: HrisBenefitListPageAsync) = apply { + service = hrisBenefitListPageAsync.service + params = hrisBenefitListPageAsync.params + items = hrisBenefitListPageAsync.items + } - @JvmStatic - fun of( - benefitsService: BenefitServiceAsync, - params: HrisBenefitListParams, - items: List, - ) = HrisBenefitListPageAsync(benefitsService, params, items) + 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) { @@ -83,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 65bc601f..9d619bc6 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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.BenefitService import java.util.Objects import java.util.Optional @@ -9,48 +10,93 @@ 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 items: Optional>, ) { - /** Returns the response that this page was parsed from. */ - fun items(): Optional> = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisBenefitListSupportedBenefitsPage && benefitsService == other.benefitsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): Optional = + getNextPageParams().map { service.listSupportedBenefits(it) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "HrisBenefitListSupportedBenefitsPage{benefitsService=$benefitsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitListSupportedBenefitsParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): Optional> = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) - fun getNextPage(): Optional { - return getNextPageParams().map { benefitsService.listSupportedBenefits(it) } + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitListSupportedBenefitsPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisBenefitListSupportedBenefitsPage]. */ + class Builder internal constructor() { - companion object { + private var service: BenefitService? = null + private var params: HrisBenefitListSupportedBenefitsParams? = null + private var items: Optional>? = null - @JvmStatic - fun of( - benefitsService: BenefitService, - params: HrisBenefitListSupportedBenefitsParams, - items: Optional>, - ) = HrisBenefitListSupportedBenefitsPage(benefitsService, params, items) + @JvmSynthetic + internal fun from( + hrisBenefitListSupportedBenefitsPage: HrisBenefitListSupportedBenefitsPage + ) = apply { + service = hrisBenefitListSupportedBenefitsPage.service + params = hrisBenefitListSupportedBenefitsPage.params + items = hrisBenefitListSupportedBenefitsPage.items + } + + fun service(service: BenefitService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitListSupportedBenefitsParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun items(items: Optional>) = apply { + this.items = items + } + + /** + * 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), + ) } class AutoPager(private val firstPage: HrisBenefitListSupportedBenefitsPage) : @@ -72,4 +118,17 @@ private constructor( 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 08dea534..d9740159 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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.BenefitServiceAsync import java.util.Objects import java.util.Optional @@ -9,50 +10,95 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -/** Get deductions metadata */ +/** @see [BenefitServiceAsync.listSupportedBenefits] */ class HrisBenefitListSupportedBenefitsPageAsync private constructor( - private val benefitsService: BenefitServiceAsync, + private val service: BenefitServiceAsync, private val params: HrisBenefitListSupportedBenefitsParams, private val items: Optional>, ) { - /** Returns the response that this page was parsed from. */ - fun items(): Optional> = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisBenefitListSupportedBenefitsPageAsync && benefitsService == other.benefitsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.listSupportedBenefits(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(benefitsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "HrisBenefitListSupportedBenefitsPageAsync{benefitsService=$benefitsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): HrisBenefitListSupportedBenefitsParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): Optional> = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { benefitsService.listSupportedBenefits(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisBenefitListSupportedBenefitsPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisBenefitListSupportedBenefitsPageAsync]. */ + class Builder internal constructor() { - companion object { + private var service: BenefitServiceAsync? = null + private var params: HrisBenefitListSupportedBenefitsParams? = null + private var items: Optional>? = null + + @JvmSynthetic + internal fun from( + hrisBenefitListSupportedBenefitsPageAsync: HrisBenefitListSupportedBenefitsPageAsync + ) = apply { + service = hrisBenefitListSupportedBenefitsPageAsync.service + params = hrisBenefitListSupportedBenefitsPageAsync.params + items = hrisBenefitListSupportedBenefitsPageAsync.items + } + + fun service(service: BenefitServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisBenefitListSupportedBenefitsParams) = apply { this.params = params } - @JvmStatic - fun of( - benefitsService: BenefitServiceAsync, - params: HrisBenefitListSupportedBenefitsParams, - items: Optional>, - ) = HrisBenefitListSupportedBenefitsPageAsync(benefitsService, params, items) + /** The response that this page was parsed from. */ + fun items(items: Optional>) = apply { + this.items = items + } + + /** + * 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), + ) } class AutoPager(private val firstPage: HrisBenefitListSupportedBenefitsPageAsync) { @@ -85,4 +131,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 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 ce55af68..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.company.PayStatementItemService import java.util.Objects import java.util.Optional @@ -9,21 +10,14 @@ 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: HrisCompanyPayStatementItemListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisCompanyPayStatementItemListPageResponse = response - /** * Delegates to [HrisCompanyPayStatementItemListPageResponse], but gracefully handles missing * data. @@ -33,37 +27,85 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - return /* spotless:off */ other is HrisCompanyPayStatementItemListPage && 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 */ + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } - override fun toString() = - "HrisCompanyPayStatementItemListPage{payStatementItemService=$payStatementItemService, params=$params, response=$response}" + fun autoPager(): AutoPager = AutoPager(this) - fun hasNextPage(): Boolean = responses().isNotEmpty() + /** The parameters that were used to request this page. */ + fun params(): HrisCompanyPayStatementItemListParams = params - fun getNextPageParams(): Optional = Optional.empty() + /** The response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemListPageResponse = response - fun getNextPage(): Optional { - return getNextPageParams().map { payStatementItemService.list(it) } + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisCompanyPayStatementItemListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisCompanyPayStatementItemListPage]. */ + class Builder internal constructor() { - companion object { + private var service: PayStatementItemService? = null + private var params: HrisCompanyPayStatementItemListParams? = null + private var response: HrisCompanyPayStatementItemListPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemListPage: HrisCompanyPayStatementItemListPage + ) = apply { + service = hrisCompanyPayStatementItemListPage.service + params = hrisCompanyPayStatementItemListPage.params + response = hrisCompanyPayStatementItemListPage.response + } + + fun service(service: PayStatementItemService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisCompanyPayStatementItemListParams) = apply { this.params = params } - @JvmStatic - fun of( - payStatementItemService: PayStatementItemService, - params: HrisCompanyPayStatementItemListParams, - response: HrisCompanyPayStatementItemListPageResponse, - ) = HrisCompanyPayStatementItemListPage(payStatementItemService, params, response) + /** The response that this page was parsed from. */ + fun response(response: HrisCompanyPayStatementItemListPageResponse) = apply { + this.response = response + } + + /** + * 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) : @@ -85,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 55743717..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.company.PayStatementItemServiceAsync import java.util.Objects import java.util.Optional @@ -10,21 +11,14 @@ 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: HrisCompanyPayStatementItemListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisCompanyPayStatementItemListPageResponse = response - /** * Delegates to [HrisCompanyPayStatementItemListPageResponse], but gracefully handles missing * data. @@ -34,39 +28,87 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - 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 */ - } - - 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 = responses().isNotEmpty() fun getNextPageParams(): Optional = 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) + /** The parameters that were used to request this page. */ + fun params(): HrisCompanyPayStatementItemListParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - payStatementItemService: PayStatementItemServiceAsync, - params: HrisCompanyPayStatementItemListParams, - response: HrisCompanyPayStatementItemListPageResponse, - ) = HrisCompanyPayStatementItemListPageAsync(payStatementItemService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisCompanyPayStatementItemListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisCompanyPayStatementItemListPageAsync]. */ + class Builder internal constructor() { + + private var service: PayStatementItemServiceAsync? = null + private var params: HrisCompanyPayStatementItemListParams? = null + private var response: HrisCompanyPayStatementItemListPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemListPageAsync: HrisCompanyPayStatementItemListPageAsync + ) = apply { + service = hrisCompanyPayStatementItemListPageAsync.service + params = hrisCompanyPayStatementItemListPageAsync.params + response = hrisCompanyPayStatementItemListPageAsync.response + } + + fun service(service: PayStatementItemServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisCompanyPayStatementItemListParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisCompanyPayStatementItemListPageResponse) = apply { + this.response = response + } + + /** + * 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) { @@ -97,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/HrisCompanyPayStatementItemRuleListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt index 2d27aa04..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.company.payStatementItem.RuleService import java.util.Objects import java.util.Optional @@ -9,20 +10,14 @@ 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: HrisCompanyPayStatementItemRuleListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisCompanyPayStatementItemRuleListPageResponse = response - /** * Delegates to [HrisCompanyPayStatementItemRuleListPageResponse], but gracefully handles * missing data. @@ -32,37 +27,87 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - 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 autoPager(): AutoPager = AutoPager(this) - fun hasNextPage(): Boolean = responses().isNotEmpty() + /** The parameters that were used to request this page. */ + fun params(): HrisCompanyPayStatementItemRuleListParams = params - fun getNextPageParams(): Optional = Optional.empty() + /** The response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemRuleListPageResponse = response - fun getNextPage(): Optional { - return getNextPageParams().map { rulesService.list(it) } + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisCompanyPayStatementItemRuleListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisCompanyPayStatementItemRuleListPage]. */ + class Builder internal constructor() { - companion object { + private var service: RuleService? = null + private var params: HrisCompanyPayStatementItemRuleListParams? = null + private var response: HrisCompanyPayStatementItemRuleListPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisCompanyPayStatementItemRuleListPage: HrisCompanyPayStatementItemRuleListPage + ) = apply { + service = hrisCompanyPayStatementItemRuleListPage.service + params = hrisCompanyPayStatementItemRuleListPage.params + response = hrisCompanyPayStatementItemRuleListPage.response + } - @JvmStatic - fun of( - rulesService: RuleService, - params: HrisCompanyPayStatementItemRuleListParams, - response: HrisCompanyPayStatementItemRuleListPageResponse, - ) = HrisCompanyPayStatementItemRuleListPage(rulesService, params, response) + fun service(service: RuleService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisCompanyPayStatementItemRuleListParams) = apply { + this.params = params + } + + /** The response that this page was parsed from. */ + fun response(response: HrisCompanyPayStatementItemRuleListPageResponse) = apply { + this.response = response + } + + /** + * 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) : @@ -84,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 510961b7..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.company.payStatementItem.RuleServiceAsync import java.util.Objects import java.util.Optional @@ -10,20 +11,14 @@ 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: HrisCompanyPayStatementItemRuleListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisCompanyPayStatementItemRuleListPageResponse = response - /** * Delegates to [HrisCompanyPayStatementItemRuleListPageResponse], but gracefully handles * missing data. @@ -33,39 +28,90 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - 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 */ - } - - 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 = responses().isNotEmpty() fun getNextPageParams(): Optional = 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) + /** The parameters that were used to request this page. */ + fun params(): HrisCompanyPayStatementItemRuleListParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisCompanyPayStatementItemRuleListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - rulesService: RuleServiceAsync, - params: HrisCompanyPayStatementItemRuleListParams, - response: HrisCompanyPayStatementItemRuleListPageResponse, - ) = HrisCompanyPayStatementItemRuleListPageAsync(rulesService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisCompanyPayStatementItemRuleListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** 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 service(service: RuleServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisCompanyPayStatementItemRuleListParams) = apply { + this.params = params + } + + /** The response that this page was parsed from. */ + fun response(response: HrisCompanyPayStatementItemRuleListPageResponse) = apply { + this.response = response + } + + /** + * 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) { @@ -96,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/HrisDirectoryListIndividualsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListIndividualsPage.kt index 976f4206..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.DirectoryService import java.util.Objects import java.util.Optional @@ -10,18 +11,15 @@ 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: HrisDirectoryListIndividualsPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisDirectoryListIndividualsPageResponse = response - /** * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. * @@ -37,19 +35,6 @@ private constructor( */ fun paging(): Optional = response._paging().getOptional("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}" - fun hasNextPage(): Boolean { if (individuals().isEmpty()) { return false @@ -70,20 +55,80 @@ private constructor( 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) + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListIndividualsParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListIndividualsPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - directoryService: DirectoryService, - params: HrisDirectoryListIndividualsParams, - response: HrisDirectoryListIndividualsPageResponse, - ) = HrisDirectoryListIndividualsPage(directoryService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisDirectoryListIndividualsPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisDirectoryListIndividualsPage]. */ + class Builder internal constructor() { + + private var service: DirectoryService? = null + private var params: HrisDirectoryListIndividualsParams? = null + private var response: HrisDirectoryListIndividualsPageResponse? = null + + @JvmSynthetic + internal fun from(hrisDirectoryListIndividualsPage: HrisDirectoryListIndividualsPage) = + apply { + service = hrisDirectoryListIndividualsPage.service + params = hrisDirectoryListIndividualsPage.params + response = hrisDirectoryListIndividualsPage.response + } + + fun service(service: DirectoryService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisDirectoryListIndividualsParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisDirectoryListIndividualsPageResponse) = apply { + this.response = response + } + + /** + * 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) : @@ -105,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 58819226..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.DirectoryServiceAsync import java.util.Objects import java.util.Optional @@ -11,18 +12,15 @@ 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: HrisDirectoryListIndividualsPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisDirectoryListIndividualsPageResponse = response - /** * Delegates to [HrisDirectoryListIndividualsPageResponse], but gracefully handles missing data. * @@ -38,19 +36,6 @@ private constructor( */ fun paging(): Optional = response._paging().getOptional("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}" - fun hasNextPage(): Boolean { if (individuals().isEmpty()) { return false @@ -71,22 +56,83 @@ private constructor( 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) + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListIndividualsParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListIndividualsPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - directoryService: DirectoryServiceAsync, - params: HrisDirectoryListIndividualsParams, - response: HrisDirectoryListIndividualsPageResponse, - ) = HrisDirectoryListIndividualsPageAsync(directoryService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisDirectoryListIndividualsPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisDirectoryListIndividualsPageAsync]. */ + class Builder internal constructor() { + + private var service: DirectoryServiceAsync? = null + private var params: HrisDirectoryListIndividualsParams? = null + private var response: HrisDirectoryListIndividualsPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisDirectoryListIndividualsPageAsync: HrisDirectoryListIndividualsPageAsync + ) = apply { + service = hrisDirectoryListIndividualsPageAsync.service + params = hrisDirectoryListIndividualsPageAsync.params + response = hrisDirectoryListIndividualsPageAsync.response + } + + fun service(service: DirectoryServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisDirectoryListIndividualsParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisDirectoryListIndividualsPageResponse) = apply { + this.response = response + } + + /** + * 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) { @@ -117,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/HrisDirectoryListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisDirectoryListPage.kt index 838dcd26..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.DirectoryService import java.util.Objects import java.util.Optional @@ -10,17 +11,14 @@ 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: HrisDirectoryListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisDirectoryListPageResponse = response - /** * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. * @@ -36,19 +34,6 @@ private constructor( */ fun paging(): Optional = response._paging().getOptional("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}" - fun hasNextPage(): Boolean { if (individuals().isEmpty()) { return false @@ -69,20 +54,76 @@ private constructor( 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) + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - directoryService: DirectoryService, - params: HrisDirectoryListParams, - response: HrisDirectoryListPageResponse, - ) = HrisDirectoryListPage(directoryService, params, response) + /** + * Returns a mutable builder for constructing an instance of [HrisDirectoryListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisDirectoryListPage]. */ + class Builder internal constructor() { + + private var service: DirectoryService? = null + private var params: HrisDirectoryListParams? = null + private var response: HrisDirectoryListPageResponse? = null + + @JvmSynthetic + internal fun from(hrisDirectoryListPage: HrisDirectoryListPage) = apply { + service = hrisDirectoryListPage.service + params = hrisDirectoryListPage.params + response = hrisDirectoryListPage.response + } + + 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) : @@ -104,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 7c1035e1..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.DirectoryServiceAsync import java.util.Objects import java.util.Optional @@ -11,17 +12,14 @@ 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: HrisDirectoryListPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisDirectoryListPageResponse = response - /** * Delegates to [HrisDirectoryListPageResponse], but gracefully handles missing data. * @@ -37,19 +35,6 @@ private constructor( */ fun paging(): Optional = response._paging().getOptional("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}" - fun hasNextPage(): Boolean { if (individuals().isEmpty()) { return false @@ -70,22 +55,78 @@ private constructor( 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) + /** The parameters that were used to request this page. */ + fun params(): HrisDirectoryListParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisDirectoryListPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - directoryService: DirectoryServiceAsync, - params: HrisDirectoryListParams, - response: HrisDirectoryListPageResponse, - ) = HrisDirectoryListPageAsync(directoryService, params, response) + /** + * Returns a mutable builder for constructing an instance of [HrisDirectoryListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisDirectoryListPageAsync]. */ + class Builder internal constructor() { + + private var service: DirectoryServiceAsync? = null + private var params: HrisDirectoryListParams? = null + private var response: HrisDirectoryListPageResponse? = null + + @JvmSynthetic + internal fun from(hrisDirectoryListPageAsync: HrisDirectoryListPageAsync) = apply { + service = hrisDirectoryListPageAsync.service + params = hrisDirectoryListPageAsync.params + response = hrisDirectoryListPageAsync.response + } + + 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) { @@ -116,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/HrisEmploymentRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt index 128f6ce1..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.EmploymentService import java.util.Objects import java.util.Optional @@ -9,17 +10,14 @@ 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: HrisEmploymentRetrieveManyPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisEmploymentRetrieveManyPageResponse = response - /** * Delegates to [HrisEmploymentRetrieveManyPageResponse], but gracefully handles missing data. * @@ -28,37 +26,83 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - return /* spotless:off */ other is HrisEmploymentRetrieveManyPage && 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 */ + fun getNextPage(): Optional = + getNextPageParams().map { service.retrieveMany(it) } - override fun toString() = - "HrisEmploymentRetrieveManyPage{employmentsService=$employmentsService, params=$params, response=$response}" + fun autoPager(): AutoPager = AutoPager(this) - fun hasNextPage(): Boolean = responses().isNotEmpty() + /** The parameters that were used to request this page. */ + fun params(): HrisEmploymentRetrieveManyParams = params - fun getNextPageParams(): Optional = Optional.empty() + /** The response that this page was parsed from. */ + fun response(): HrisEmploymentRetrieveManyPageResponse = response - fun getNextPage(): Optional { - return getNextPageParams().map { employmentsService.retrieveMany(it) } + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisEmploymentRetrieveManyPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisEmploymentRetrieveManyPage]. */ + class Builder internal constructor() { - companion object { + private var service: EmploymentService? = null + private var params: HrisEmploymentRetrieveManyParams? = null + private var response: HrisEmploymentRetrieveManyPageResponse? = null + + @JvmSynthetic + internal fun from(hrisEmploymentRetrieveManyPage: HrisEmploymentRetrieveManyPage) = apply { + service = hrisEmploymentRetrieveManyPage.service + params = hrisEmploymentRetrieveManyPage.params + response = hrisEmploymentRetrieveManyPage.response + } + + fun service(service: EmploymentService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisEmploymentRetrieveManyParams) = apply { this.params = params } - @JvmStatic - fun of( - employmentsService: EmploymentService, - params: HrisEmploymentRetrieveManyParams, - response: HrisEmploymentRetrieveManyPageResponse, - ) = HrisEmploymentRetrieveManyPage(employmentsService, params, response) + /** The response that this page was parsed from. */ + fun response(response: HrisEmploymentRetrieveManyPageResponse) = apply { + this.response = response + } + + /** + * 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) : @@ -80,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 8298a799..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.EmploymentServiceAsync import java.util.Objects import java.util.Optional @@ -10,17 +11,14 @@ 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: HrisEmploymentRetrieveManyPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisEmploymentRetrieveManyPageResponse = response - /** * Delegates to [HrisEmploymentRetrieveManyPageResponse], but gracefully handles missing data. * @@ -29,39 +27,87 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - 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 */ - } - - 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 = responses().isNotEmpty() fun getNextPageParams(): Optional = 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) + /** The parameters that were used to request this page. */ + fun params(): HrisEmploymentRetrieveManyParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisEmploymentRetrieveManyPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - employmentsService: EmploymentServiceAsync, - params: HrisEmploymentRetrieveManyParams, - response: HrisEmploymentRetrieveManyPageResponse, - ) = HrisEmploymentRetrieveManyPageAsync(employmentsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisEmploymentRetrieveManyPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisEmploymentRetrieveManyPageAsync]. */ + class Builder internal constructor() { + + private var service: EmploymentServiceAsync? = null + private var params: HrisEmploymentRetrieveManyParams? = null + private var response: HrisEmploymentRetrieveManyPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisEmploymentRetrieveManyPageAsync: HrisEmploymentRetrieveManyPageAsync + ) = apply { + service = hrisEmploymentRetrieveManyPageAsync.service + params = hrisEmploymentRetrieveManyPageAsync.params + response = hrisEmploymentRetrieveManyPageAsync.response + } + + fun service(service: EmploymentServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisEmploymentRetrieveManyParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisEmploymentRetrieveManyPageResponse) = apply { + this.response = response + } + + /** + * 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) { @@ -92,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/HrisIndividualRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt index 4ce3f385..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.IndividualService import java.util.Objects import java.util.Optional @@ -9,17 +10,14 @@ 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: HrisIndividualRetrieveManyPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisIndividualRetrieveManyPageResponse = response - /** * Delegates to [HrisIndividualRetrieveManyPageResponse], but gracefully handles missing data. * @@ -28,37 +26,83 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - return /* spotless:off */ other is HrisIndividualRetrieveManyPage && 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 */ + fun getNextPage(): Optional = + getNextPageParams().map { service.retrieveMany(it) } - override fun toString() = - "HrisIndividualRetrieveManyPage{individualsService=$individualsService, params=$params, response=$response}" + fun autoPager(): AutoPager = AutoPager(this) - fun hasNextPage(): Boolean = responses().isNotEmpty() + /** The parameters that were used to request this page. */ + fun params(): HrisIndividualRetrieveManyParams = params - fun getNextPageParams(): Optional = Optional.empty() + /** The response that this page was parsed from. */ + fun response(): HrisIndividualRetrieveManyPageResponse = response - fun getNextPage(): Optional { - return getNextPageParams().map { individualsService.retrieveMany(it) } + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisIndividualRetrieveManyPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisIndividualRetrieveManyPage]. */ + class Builder internal constructor() { - companion object { + private var service: IndividualService? = null + private var params: HrisIndividualRetrieveManyParams? = null + private var response: HrisIndividualRetrieveManyPageResponse? = null + + @JvmSynthetic + internal fun from(hrisIndividualRetrieveManyPage: HrisIndividualRetrieveManyPage) = apply { + service = hrisIndividualRetrieveManyPage.service + params = hrisIndividualRetrieveManyPage.params + response = hrisIndividualRetrieveManyPage.response + } + + fun service(service: IndividualService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisIndividualRetrieveManyParams) = apply { this.params = params } - @JvmStatic - fun of( - individualsService: IndividualService, - params: HrisIndividualRetrieveManyParams, - response: HrisIndividualRetrieveManyPageResponse, - ) = HrisIndividualRetrieveManyPage(individualsService, params, response) + /** The response that this page was parsed from. */ + fun response(response: HrisIndividualRetrieveManyPageResponse) = apply { + this.response = response + } + + /** + * 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) : @@ -80,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 c76563e1..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.IndividualServiceAsync import java.util.Objects import java.util.Optional @@ -10,17 +11,14 @@ 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: HrisIndividualRetrieveManyPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisIndividualRetrieveManyPageResponse = response - /** * Delegates to [HrisIndividualRetrieveManyPageResponse], but gracefully handles missing data. * @@ -29,39 +27,87 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - 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 */ - } - - 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 = responses().isNotEmpty() fun getNextPageParams(): Optional = 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) + /** The parameters that were used to request this page. */ + fun params(): HrisIndividualRetrieveManyParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisIndividualRetrieveManyPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - individualsService: IndividualServiceAsync, - params: HrisIndividualRetrieveManyParams, - response: HrisIndividualRetrieveManyPageResponse, - ) = HrisIndividualRetrieveManyPageAsync(individualsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisIndividualRetrieveManyPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisIndividualRetrieveManyPageAsync]. */ + class Builder internal constructor() { + + private var service: IndividualServiceAsync? = null + private var params: HrisIndividualRetrieveManyParams? = null + private var response: HrisIndividualRetrieveManyPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisIndividualRetrieveManyPageAsync: HrisIndividualRetrieveManyPageAsync + ) = apply { + service = hrisIndividualRetrieveManyPageAsync.service + params = hrisIndividualRetrieveManyPageAsync.params + response = hrisIndividualRetrieveManyPageAsync.response + } + + fun service(service: IndividualServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisIndividualRetrieveManyParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisIndividualRetrieveManyPageResponse) = apply { + this.response = response + } + + /** + * 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) { @@ -92,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/HrisPayStatementRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt index 84c61ad2..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.PayStatementService import java.util.Objects import java.util.Optional @@ -9,21 +10,14 @@ 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: HrisPayStatementRetrieveManyPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisPayStatementRetrieveManyPageResponse = response - /** * Delegates to [HrisPayStatementRetrieveManyPageResponse], but gracefully handles missing data. * @@ -32,37 +26,84 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun hasNextPage(): Boolean = responses().isNotEmpty() - return /* spotless:off */ other is HrisPayStatementRetrieveManyPage && 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 */ + fun getNextPage(): Optional = + getNextPageParams().map { service.retrieveMany(it) } - override fun toString() = - "HrisPayStatementRetrieveManyPage{payStatementsService=$payStatementsService, params=$params, response=$response}" + fun autoPager(): AutoPager = AutoPager(this) - fun hasNextPage(): Boolean = responses().isNotEmpty() + /** The parameters that were used to request this page. */ + fun params(): HrisPayStatementRetrieveManyParams = params - fun getNextPageParams(): Optional = Optional.empty() + /** The response that this page was parsed from. */ + fun response(): HrisPayStatementRetrieveManyPageResponse = response - fun getNextPage(): Optional { - return getNextPageParams().map { payStatementsService.retrieveMany(it) } + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [HrisPayStatementRetrieveManyPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisPayStatementRetrieveManyPage]. */ + class Builder internal constructor() { - companion object { + private var service: PayStatementService? = null + private var params: HrisPayStatementRetrieveManyParams? = null + private var response: HrisPayStatementRetrieveManyPageResponse? = null + + @JvmSynthetic + internal fun from(hrisPayStatementRetrieveManyPage: HrisPayStatementRetrieveManyPage) = + apply { + service = hrisPayStatementRetrieveManyPage.service + params = hrisPayStatementRetrieveManyPage.params + response = hrisPayStatementRetrieveManyPage.response + } + + fun service(service: PayStatementService) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisPayStatementRetrieveManyParams) = apply { this.params = params } - @JvmStatic - fun of( - payStatementsService: PayStatementService, - params: HrisPayStatementRetrieveManyParams, - response: HrisPayStatementRetrieveManyPageResponse, - ) = HrisPayStatementRetrieveManyPage(payStatementsService, params, response) + /** The response that this page was parsed from. */ + fun response(response: HrisPayStatementRetrieveManyPageResponse) = apply { + this.response = response + } + + /** + * 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) : @@ -84,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 369a9ee7..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.PayStatementServiceAsync import java.util.Objects import java.util.Optional @@ -10,21 +11,14 @@ 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: HrisPayStatementRetrieveManyPageResponse, ) { - /** Returns the response that this page was parsed from. */ - fun response(): HrisPayStatementRetrieveManyPageResponse = response - /** * Delegates to [HrisPayStatementRetrieveManyPageResponse], but gracefully handles missing data. * @@ -33,39 +27,87 @@ private constructor( fun responses(): List = response._responses().getOptional("responses").getOrNull() ?: emptyList() - 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 */ - } - - 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 = responses().isNotEmpty() fun getNextPageParams(): Optional = 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) + /** The parameters that were used to request this page. */ + fun params(): HrisPayStatementRetrieveManyParams = params + + /** The response that this page was parsed from. */ + fun response(): HrisPayStatementRetrieveManyPageResponse = response + + fun toBuilder() = Builder().from(this) + companion object { - @JvmStatic - fun of( - payStatementsService: PayStatementServiceAsync, - params: HrisPayStatementRetrieveManyParams, - response: HrisPayStatementRetrieveManyPageResponse, - ) = HrisPayStatementRetrieveManyPageAsync(payStatementsService, params, response) + /** + * Returns a mutable builder for constructing an instance of + * [HrisPayStatementRetrieveManyPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .response() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [HrisPayStatementRetrieveManyPageAsync]. */ + class Builder internal constructor() { + + private var service: PayStatementServiceAsync? = null + private var params: HrisPayStatementRetrieveManyParams? = null + private var response: HrisPayStatementRetrieveManyPageResponse? = null + + @JvmSynthetic + internal fun from( + hrisPayStatementRetrieveManyPageAsync: HrisPayStatementRetrieveManyPageAsync + ) = apply { + service = hrisPayStatementRetrieveManyPageAsync.service + params = hrisPayStatementRetrieveManyPageAsync.params + response = hrisPayStatementRetrieveManyPageAsync.response + } + + fun service(service: PayStatementServiceAsync) = apply { this.service = service } + + /** The parameters that were used to request this page. */ + fun params(params: HrisPayStatementRetrieveManyParams) = apply { this.params = params } + + /** The response that this page was parsed from. */ + fun response(response: HrisPayStatementRetrieveManyPageResponse) = apply { + this.response = response + } + + /** + * 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) { @@ -96,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/HrisPaymentListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt index abfb1a64..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.hris.PaymentService import java.util.Objects import java.util.Optional @@ -9,48 +10,87 @@ 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisPaymentListPage && paymentsService == other.paymentsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(paymentsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "HrisPaymentListPage{paymentsService=$paymentsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): HrisPaymentListParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) + + companion object { - fun getNextPage(): Optional { - return getNextPageParams().map { paymentsService.list(it) } + /** + * Returns a mutable builder for constructing an instance of [HrisPaymentListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [HrisPaymentListPage]. */ + class Builder internal constructor() { - companion object { + private var service: PaymentService? = null + private var params: HrisPaymentListParams? = null + private var items: List? = null + + @JvmSynthetic + internal fun from(hrisPaymentListPage: HrisPaymentListPage) = apply { + service = hrisPaymentListPage.service + params = hrisPaymentListPage.params + items = hrisPaymentListPage.items + } - @JvmStatic - fun of( - paymentsService: PaymentService, - params: HrisPaymentListParams, - items: List, - ) = HrisPaymentListPage(paymentsService, params, items) + 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 { @@ -71,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 327da14f..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.hris.PaymentServiceAsync import java.util.Objects import java.util.Optional @@ -9,50 +10,90 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -/** 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is HrisPaymentListPageAsync && paymentsService == other.paymentsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(paymentsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "HrisPaymentListPageAsync{paymentsService=$paymentsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): HrisPaymentListParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { paymentsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + companion object { + + /** + * Returns a mutable builder for constructing an instance of [HrisPaymentListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** 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 + + @JvmSynthetic + internal fun from(hrisPaymentListPageAsync: HrisPaymentListPageAsync) = apply { + service = hrisPaymentListPageAsync.service + params = hrisPaymentListPageAsync.params + items = hrisPaymentListPageAsync.items + } - @JvmStatic - fun of( - paymentsService: PaymentServiceAsync, - params: HrisPaymentListParams, - items: List, - ) = HrisPaymentListPageAsync(paymentsService, params, items) + 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) { @@ -80,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 9de2c369..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.payroll.PayGroupService import java.util.Objects import java.util.Optional @@ -9,48 +10,88 @@ 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is PayrollPayGroupListPage && payGroupsService == other.payGroupsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): Optional = + getNextPageParams().map { service.list(it) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payGroupsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "PayrollPayGroupListPage{payGroupsService=$payGroupsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): PayrollPayGroupListParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) + + companion object { - fun getNextPage(): Optional { - return getNextPageParams().map { payGroupsService.list(it) } + /** + * Returns a mutable builder for constructing an instance of [PayrollPayGroupListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [PayrollPayGroupListPage]. */ + class Builder internal constructor() { - companion object { + private var service: PayGroupService? = null + private var params: PayrollPayGroupListParams? = null + private var items: List? = null + + @JvmSynthetic + internal fun from(payrollPayGroupListPage: PayrollPayGroupListPage) = apply { + service = payrollPayGroupListPage.service + params = payrollPayGroupListPage.params + items = payrollPayGroupListPage.items + } - @JvmStatic - fun of( - payGroupsService: PayGroupService, - params: PayrollPayGroupListParams, - items: List, - ) = PayrollPayGroupListPage(payGroupsService, params, items) + 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) : @@ -72,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 40752dec..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.payroll.PayGroupServiceAsync import java.util.Objects import java.util.Optional @@ -9,50 +10,90 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -/** 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is PayrollPayGroupListPageAsync && payGroupsService == other.payGroupsService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(payGroupsService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "PayrollPayGroupListPageAsync{payGroupsService=$payGroupsService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): PayrollPayGroupListParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { payGroupsService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PayrollPayGroupListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** 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 + + @JvmSynthetic + internal fun from(payrollPayGroupListPageAsync: PayrollPayGroupListPageAsync) = apply { + service = payrollPayGroupListPageAsync.service + params = payrollPayGroupListPageAsync.params + items = payrollPayGroupListPageAsync.items + } - @JvmStatic - fun of( - payGroupsService: PayGroupServiceAsync, - params: PayrollPayGroupListParams, - items: List, - ) = PayrollPayGroupListPageAsync(payGroupsService, params, items) + 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) { @@ -83,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 946b84fe..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.blocking.ProviderService import java.util.Objects import java.util.Optional @@ -9,48 +10,87 @@ 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is ProviderListPage && providersService == other.providersService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): Optional = getNextPageParams().map { service.list(it) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(providersService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "ProviderListPage{providersService=$providersService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): ProviderListParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) + + companion object { - fun getNextPage(): Optional { - return getNextPageParams().map { providersService.list(it) } + /** + * Returns a mutable builder for constructing an instance of [ProviderListPage]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** A builder for [ProviderListPage]. */ + class Builder internal constructor() { - companion object { + private var service: ProviderService? = null + private var params: ProviderListParams? = null + private var items: List? = null + + @JvmSynthetic + internal fun from(providerListPage: ProviderListPage) = apply { + service = providerListPage.service + params = providerListPage.params + items = providerListPage.items + } - @JvmStatic - fun of( - providersService: ProviderService, - params: ProviderListParams, - items: List, - ) = ProviderListPage(providersService, params, items) + 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 { @@ -71,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 1e416f73..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,6 +2,7 @@ package com.tryfinch.api.models +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.services.async.ProviderServiceAsync import java.util.Objects import java.util.Optional @@ -9,50 +10,90 @@ import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate -/** 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 items: List, ) { - /** Returns the response that this page was parsed from. */ - fun items(): List = items + fun hasNextPage(): Boolean = items.isNotEmpty() - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + fun getNextPageParams(): Optional = Optional.empty() - return /* spotless:off */ other is ProviderListPageAsync && providersService == other.providersService && params == other.params && items == other.items /* spotless:on */ - } + fun getNextPage(): CompletableFuture> = + getNextPageParams() + .map { service.list(it).thenApply { Optional.of(it) } } + .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(providersService, params, items) /* spotless:on */ + fun autoPager(): AutoPager = AutoPager(this) - override fun toString() = - "ProviderListPageAsync{providersService=$providersService, params=$params, items=$items}" + /** The parameters that were used to request this page. */ + fun params(): ProviderListParams = params - fun hasNextPage(): Boolean = items.isNotEmpty() + /** The response that this page was parsed from. */ + fun items(): List = items - fun getNextPageParams(): Optional = Optional.empty() + fun toBuilder() = Builder().from(this) - fun getNextPage(): CompletableFuture> { - return getNextPageParams() - .map { providersService.list(it).thenApply { Optional.of(it) } } - .orElseGet { CompletableFuture.completedFuture(Optional.empty()) } + companion object { + + /** + * Returns a mutable builder for constructing an instance of [ProviderListPageAsync]. + * + * The following fields are required: + * ```java + * .service() + * .params() + * .items() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun autoPager(): AutoPager = AutoPager(this) + /** 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 + + @JvmSynthetic + internal fun from(providerListPageAsync: ProviderListPageAsync) = apply { + service = providerListPageAsync.service + params = providerListPageAsync.params + items = providerListPageAsync.items + } - @JvmStatic - fun of( - providersService: ProviderServiceAsync, - params: ProviderListParams, - items: List, - ) = ProviderListPageAsync(providersService, params, items) + 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) { @@ -80,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/services/async/ProviderServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt index 1aed912f..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, - it, - ) + 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 3bca46b9..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 @@ -210,11 +210,11 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl } } .let { - HrisBenefitListPageAsync.of( - BenefitServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisBenefitListPageAsync.builder() + .service(BenefitServiceAsyncImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } @@ -250,11 +250,11 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl } } .let { - HrisBenefitListSupportedBenefitsPageAsync.of( - BenefitServiceAsyncImpl(clientOptions), - params, - it, - ) + 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 00974814..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 @@ -78,11 +78,11 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: } } .let { - HrisDirectoryListPageAsync.of( - DirectoryServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisDirectoryListPageAsync.builder() + .service(DirectoryServiceAsyncImpl(clientOptions)) + .params(params) + .response(it) + .build() } } } @@ -116,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 d7b724b3..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 @@ -69,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 f8bffb62..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 @@ -69,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 b022515e..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 @@ -69,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 1865fb77..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, - it, - ) + 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/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt index 2ea6a3b6..08d6b37a 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 @@ -116,11 +116,11 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: } } .let { - HrisBenefitIndividualRetrieveManyBenefitsPageAsync.of( - IndividualServiceAsyncImpl(clientOptions), - params, - it, - ) + HrisBenefitIndividualRetrieveManyBenefitsPageAsync.builder() + .service(IndividualServiceAsyncImpl(clientOptions)) + .params(params) + .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 5c9634dd..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 @@ -79,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 d3d5726f..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 @@ -155,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 4059ca8b..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,11 +106,11 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C } } .let { - PayrollPayGroupListPageAsync.of( - PayGroupServiceAsyncImpl(clientOptions), - params, - it, - ) + 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 c371b21c..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 @@ -62,7 +62,13 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client it.forEach { it.validate() } } } - .let { ProviderListPage.of(ProviderServiceImpl(clientOptions), params, it) } + .let { + 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 08445899..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 @@ -195,7 +195,13 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO it.forEach { it.validate() } } } - .let { HrisBenefitListPage.of(BenefitServiceImpl(clientOptions), params, it) } + .let { + HrisBenefitListPage.builder() + .service(BenefitServiceImpl(clientOptions)) + .params(params) + .items(it) + .build() + } } } @@ -227,11 +233,11 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO } } .let { - HrisBenefitListSupportedBenefitsPage.of( - BenefitServiceImpl(clientOptions), - params, - it, - ) + 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 ed699622..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 @@ -75,7 +75,11 @@ 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() } } } @@ -106,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 804b5376..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 @@ -66,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 09dbfe4c..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 @@ -66,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 56cd9d5d..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 @@ -66,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 a28d1aed..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 @@ -62,7 +62,13 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO it.forEach { it.validate() } } } - .let { HrisPaymentListPage.of(PaymentServiceImpl(clientOptions), params, it) } + .let { + 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/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt index ca75feab..98f57289 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 @@ -110,11 +110,11 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie } } .let { - HrisBenefitIndividualRetrieveManyBenefitsPage.of( - IndividualServiceImpl(clientOptions), - params, - it, - ) + HrisBenefitIndividualRetrieveManyBenefitsPage.builder() + .service(IndividualServiceImpl(clientOptions)) + .params(params) + .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 3868e4bb..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 @@ -76,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 af2941f2..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 @@ -145,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 3be34de8..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,7 +100,11 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client } } .let { - PayrollPayGroupListPage.of(PayGroupServiceImpl(clientOptions), params, it) + PayrollPayGroupListPage.builder() + .service(PayGroupServiceImpl(clientOptions)) + .params(params) + .items(it) + .build() } } } From 511b7fb4b6969bfded3c4f021753c1823b10baf1 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:36:51 +0000 Subject: [PATCH 09/13] feat(api): add models for hrs benefits individuals async responses --- .stats.yml | 2 +- ...t => EnrolledIndividualBenefitResponse.kt} | 29 ++++++++++--------- ... EnrolledIndividualBenefitResponseTest.kt} | 21 +++++++------- 3 files changed, 28 insertions(+), 24 deletions(-) rename finch-java-core/src/main/kotlin/com/tryfinch/api/models/{EnrolledIndividualBenefit.kt => EnrolledIndividualBenefitResponse.kt} (84%) rename finch-java-core/src/test/kotlin/com/tryfinch/api/models/{EnrolledIndividualBenefitTest.kt => EnrolledIndividualBenefitResponseTest.kt} (55%) diff --git a/.stats.yml b/.stats.yml index ea775314..6b51a4f5 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-bf858f37d7ab420841ddc6329dad8c46377308b6a5c8e935908011d0f9845e22.yml openapi_spec_hash: 2523952a32436e3c7fd3b55508c2e7ee -config_hash: 9faa2458e0e8bb125bf5d41e514a19e7 +config_hash: bedc278fd693e36e7d8dc508d75ab76a diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt similarity index 84% rename from finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefit.kt rename to finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt index cd4a00b1..b3cabc1d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponse.kt @@ -15,7 +15,7 @@ import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects -class EnrolledIndividualBenefit +class EnrolledIndividualBenefitResponse private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, @@ -54,7 +54,8 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [EnrolledIndividualBenefit]. + * Returns a mutable builder for constructing an instance of + * [EnrolledIndividualBenefitResponse]. * * The following fields are required: * ```java @@ -64,17 +65,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [EnrolledIndividualBenefit]. */ + /** A builder for [EnrolledIndividualBenefitResponse]. */ class Builder internal constructor() { private var jobId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(enrolledIndividualBenefit: EnrolledIndividualBenefit) = apply { - jobId = enrolledIndividualBenefit.jobId - additionalProperties = enrolledIndividualBenefit.additionalProperties.toMutableMap() - } + internal fun from(enrolledIndividualBenefitResponse: EnrolledIndividualBenefitResponse) = + apply { + jobId = enrolledIndividualBenefitResponse.jobId + additionalProperties = + enrolledIndividualBenefitResponse.additionalProperties.toMutableMap() + } fun jobId(jobId: String) = jobId(JsonField.of(jobId)) @@ -106,7 +109,7 @@ private constructor( } /** - * Returns an immutable instance of [EnrolledIndividualBenefit]. + * Returns an immutable instance of [EnrolledIndividualBenefitResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -117,8 +120,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): EnrolledIndividualBenefit = - EnrolledIndividualBenefit( + fun build(): EnrolledIndividualBenefitResponse = + EnrolledIndividualBenefitResponse( checkRequired("jobId", jobId), additionalProperties.toMutableMap(), ) @@ -126,7 +129,7 @@ private constructor( private var validated: Boolean = false - fun validate(): EnrolledIndividualBenefit = apply { + fun validate(): EnrolledIndividualBenefitResponse = apply { if (validated) { return@apply } @@ -155,7 +158,7 @@ private constructor( return true } - return /* spotless:off */ other is EnrolledIndividualBenefit && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EnrolledIndividualBenefitResponse && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -165,5 +168,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "EnrolledIndividualBenefit{jobId=$jobId, additionalProperties=$additionalProperties}" + "EnrolledIndividualBenefitResponse{jobId=$jobId, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponseTest.kt similarity index 55% rename from finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitTest.kt rename to finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponseTest.kt index 110db778..b4a0bd16 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EnrolledIndividualBenefitResponseTest.kt @@ -7,33 +7,34 @@ import com.tryfinch.api.core.jsonMapper import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -internal class EnrolledIndividualBenefitTest { +internal class EnrolledIndividualBenefitResponseTest { @Test fun create() { - val enrolledIndividualBenefit = - EnrolledIndividualBenefit.builder() + val enrolledIndividualBenefitResponse = + EnrolledIndividualBenefitResponse.builder() .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - assertThat(enrolledIndividualBenefit.jobId()) + assertThat(enrolledIndividualBenefitResponse.jobId()) .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") } @Test fun roundtrip() { val jsonMapper = jsonMapper() - val enrolledIndividualBenefit = - EnrolledIndividualBenefit.builder() + val enrolledIndividualBenefitResponse = + EnrolledIndividualBenefitResponse.builder() .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() - val roundtrippedEnrolledIndividualBenefit = + val roundtrippedEnrolledIndividualBenefitResponse = jsonMapper.readValue( - jsonMapper.writeValueAsString(enrolledIndividualBenefit), - jacksonTypeRef(), + jsonMapper.writeValueAsString(enrolledIndividualBenefitResponse), + jacksonTypeRef(), ) - assertThat(roundtrippedEnrolledIndividualBenefit).isEqualTo(enrolledIndividualBenefit) + assertThat(roundtrippedEnrolledIndividualBenefitResponse) + .isEqualTo(enrolledIndividualBenefitResponse) } } From 94a98e8ccff95f19fb8faf965525dd063745a3cb Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 19:38:57 +0000 Subject: [PATCH 10/13] chore: fix typo --- .stats.yml | 2 +- ...=> UnenrolledIndividualBenefitResponse.kt} | 26 ++++++------ .../hris/benefits/IndividualServiceAsync.kt | 10 ++--- .../benefits/IndividualServiceAsyncImpl.kt | 10 ++--- .../hris/benefits/IndividualService.kt | 10 ++--- .../hris/benefits/IndividualServiceImpl.kt | 10 ++--- .../IndividualUnenrollManyResponseTest.kt | 40 ------------------- ...UnenrolledIndividualBenefitResponseTest.kt | 40 +++++++++++++++++++ .../benefits/IndividualServiceAsyncTest.kt | 6 +-- .../hris/benefits/IndividualServiceTest.kt | 4 +- 10 files changed, 80 insertions(+), 78 deletions(-) rename finch-java-core/src/main/kotlin/com/tryfinch/api/models/{IndividualUnenrollManyResponse.kt => UnenrolledIndividualBenefitResponse.kt} (83%) delete mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 6b51a4f5..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-bf858f37d7ab420841ddc6329dad8c46377308b6a5c8e935908011d0f9845e22.yml openapi_spec_hash: 2523952a32436e3c7fd3b55508c2e7ee -config_hash: bedc278fd693e36e7d8dc508d75ab76a +config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt similarity index 83% rename from finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt rename to finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt index 6641101c..308a775e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividualBenefitResponse.kt @@ -15,7 +15,7 @@ import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects -class IndividualUnenrollManyResponse +class UnenrolledIndividualBenefitResponse private constructor( private val jobId: JsonField, private val additionalProperties: MutableMap, @@ -55,7 +55,7 @@ private constructor( /** * Returns a mutable builder for constructing an instance of - * [IndividualUnenrollManyResponse]. + * [UnenrolledIndividualBenefitResponse]. * * The following fields are required: * ```java @@ -65,17 +65,19 @@ private constructor( @JvmStatic fun builder() = Builder() } - /** A builder for [IndividualUnenrollManyResponse]. */ + /** A builder for [UnenrolledIndividualBenefitResponse]. */ class Builder internal constructor() { private var jobId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(individualUnenrollManyResponse: IndividualUnenrollManyResponse) = apply { - jobId = individualUnenrollManyResponse.jobId + internal fun from( + unenrolledIndividualBenefitResponse: UnenrolledIndividualBenefitResponse + ) = apply { + jobId = unenrolledIndividualBenefitResponse.jobId additionalProperties = - individualUnenrollManyResponse.additionalProperties.toMutableMap() + unenrolledIndividualBenefitResponse.additionalProperties.toMutableMap() } fun jobId(jobId: String) = jobId(JsonField.of(jobId)) @@ -108,7 +110,7 @@ private constructor( } /** - * Returns an immutable instance of [IndividualUnenrollManyResponse]. + * Returns an immutable instance of [UnenrolledIndividualBenefitResponse]. * * Further updates to this [Builder] will not mutate the returned instance. * @@ -119,8 +121,8 @@ private constructor( * * @throws IllegalStateException if any required field is unset. */ - fun build(): IndividualUnenrollManyResponse = - IndividualUnenrollManyResponse( + fun build(): UnenrolledIndividualBenefitResponse = + UnenrolledIndividualBenefitResponse( checkRequired("jobId", jobId), additionalProperties.toMutableMap(), ) @@ -128,7 +130,7 @@ private constructor( private var validated: Boolean = false - fun validate(): IndividualUnenrollManyResponse = apply { + fun validate(): UnenrolledIndividualBenefitResponse = apply { if (validated) { return@apply } @@ -157,7 +159,7 @@ private constructor( return true } - return /* spotless:off */ other is IndividualUnenrollManyResponse && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnenrolledIndividualBenefitResponse && jobId == other.jobId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -167,5 +169,5 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "IndividualUnenrollManyResponse{jobId=$jobId, additionalProperties=$additionalProperties}" + "UnenrolledIndividualBenefitResponse{jobId=$jobId, additionalProperties=$additionalProperties}" } 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 efbddead..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 @@ -10,7 +10,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPageAsyn import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualEnrolledIdsResponse -import com.tryfinch.api.models.IndividualUnenrollManyResponse +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 08d6b37a..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 @@ -21,7 +21,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualBenefit import com.tryfinch.api.models.IndividualEnrolledIdsResponse -import com.tryfinch.api.models.IndividualUnenrollManyResponse +import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse import java.util.concurrent.CompletableFuture class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -50,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() } @@ -126,14 +126,14 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: } } - 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) 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 e6f88fd1..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 @@ -10,7 +10,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsPage import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualEnrolledIdsResponse -import com.tryfinch.api.models.IndividualUnenrollManyResponse +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 - ): IndividualUnenrollManyResponse = unenrollMany(params, RequestOptions.none()) + ): UnenrolledIndividualBenefitResponse = unenrollMany(params, RequestOptions.none()) /** @see [unenrollMany] */ fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions = RequestOptions.none(), - ): IndividualUnenrollManyResponse + ): 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 98f57289..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 @@ -21,7 +21,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualBenefit import com.tryfinch.api.models.IndividualEnrolledIdsResponse -import com.tryfinch.api.models.IndividualUnenrollManyResponse +import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : IndividualService { @@ -49,7 +49,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions, - ): IndividualUnenrollManyResponse = + ): UnenrolledIndividualBenefitResponse = // delete /employer/benefits/{benefit_id}/individuals withRawResponse().unenrollMany(params, requestOptions).parse() @@ -119,14 +119,14 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie } } - 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) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt deleted file mode 100644 index f5ad98fe..00000000 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IndividualUnenrollManyResponseTest.kt +++ /dev/null @@ -1,40 +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 IndividualUnenrollManyResponseTest { - - @Test - fun create() { - val individualUnenrollManyResponse = - IndividualUnenrollManyResponse.builder() - .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - assertThat(individualUnenrollManyResponse.jobId()) - .isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val individualUnenrollManyResponse = - IndividualUnenrollManyResponse.builder() - .jobId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - .build() - - val roundtrippedIndividualUnenrollManyResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(individualUnenrollManyResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedIndividualUnenrollManyResponse) - .isEqualTo(individualUnenrollManyResponse) - } -} 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/services/async/hris/benefits/IndividualServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncTest.kt index bd192a83..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 @@ -60,7 +60,7 @@ internal class IndividualServiceAsyncTest { .build() val individualServiceAsync = client.hris().benefits().individuals() - val responseFuture = + val unenrolledIndividualBenefitResponseFuture = individualServiceAsync.unenrollMany( HrisBenefitIndividualUnenrollManyParams.builder() .benefitId("benefit_id") @@ -68,7 +68,7 @@ internal class IndividualServiceAsyncTest { .build() ) - val response = responseFuture.get() - response.validate() + val unenrolledIndividualBenefitResponse = unenrolledIndividualBenefitResponseFuture.get() + unenrolledIndividualBenefitResponse.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 9e5ffd30..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 @@ -58,7 +58,7 @@ internal class IndividualServiceTest { .build() val individualService = client.hris().benefits().individuals() - val response = + val unenrolledIndividualBenefitResponse = individualService.unenrollMany( HrisBenefitIndividualUnenrollManyParams.builder() .benefitId("benefit_id") @@ -66,6 +66,6 @@ internal class IndividualServiceTest { .build() ) - response.validate() + unenrolledIndividualBenefitResponse.validate() } } From 72adfa647da7ce56023200595f04f46379245ff8 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 9 Apr 2025 21:08:12 +0000 Subject: [PATCH 11/13] chore(internal): reduce CI branch coverage --- .github/workflows/ci.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a6ae118..ebbaa260 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,19 +1,17 @@ name: CI on: push: - branches-ignore: - - 'generated' - - 'codegen/**' - - 'integrated/**' - - 'preview-head/**' - - 'preview-base/**' - - 'preview/**' + branches: + - main + pull_request: + branches: + - main + - next jobs: lint: name: lint runs-on: ubuntu-latest - steps: - uses: actions/checkout@v4 From 4da1190d2b90298fb4d24ac48f2b9009fb39534f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 14:35:46 +0000 Subject: [PATCH 12/13] fix(client): page compilation error --- .../api/models/HrisBenefitListSupportedBenefitsPage.kt | 8 ++++---- .../models/HrisBenefitListSupportedBenefitsPageAsync.kt | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) 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 9d619bc6..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 @@ -15,7 +15,7 @@ class HrisBenefitListSupportedBenefitsPage private constructor( private val service: BenefitService, private val params: HrisBenefitListSupportedBenefitsParams, - private val items: Optional>, + private val items: List, ) { fun hasNextPage(): Boolean = items.isNotEmpty() @@ -31,7 +31,7 @@ private constructor( fun params(): HrisBenefitListSupportedBenefitsParams = params /** The response that this page was parsed from. */ - fun items(): Optional> = items + fun items(): List = items fun toBuilder() = Builder().from(this) @@ -64,7 +64,7 @@ private constructor( ) = apply { service = hrisBenefitListSupportedBenefitsPage.service params = hrisBenefitListSupportedBenefitsPage.params - items = hrisBenefitListSupportedBenefitsPage.items + items = Optional.of(hrisBenefitListSupportedBenefitsPage.items) } fun service(service: BenefitService) = apply { this.service = service } @@ -95,7 +95,7 @@ private constructor( HrisBenefitListSupportedBenefitsPage( checkRequired("service", service), checkRequired("params", params), - checkRequired("items", items), + checkRequired("items", items).getOrNull() ?: emptyList(), ) } 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 d9740159..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 @@ -9,13 +9,14 @@ import java.util.Optional import java.util.concurrent.CompletableFuture import java.util.concurrent.Executor import java.util.function.Predicate +import kotlin.jvm.optionals.getOrNull /** @see [BenefitServiceAsync.listSupportedBenefits] */ class HrisBenefitListSupportedBenefitsPageAsync private constructor( private val service: BenefitServiceAsync, private val params: HrisBenefitListSupportedBenefitsParams, - private val items: Optional>, + private val items: List, ) { fun hasNextPage(): Boolean = items.isNotEmpty() @@ -33,7 +34,7 @@ private constructor( fun params(): HrisBenefitListSupportedBenefitsParams = params /** The response that this page was parsed from. */ - fun items(): Optional> = items + fun items(): List = items fun toBuilder() = Builder().from(this) @@ -66,7 +67,7 @@ private constructor( ) = apply { service = hrisBenefitListSupportedBenefitsPageAsync.service params = hrisBenefitListSupportedBenefitsPageAsync.params - items = hrisBenefitListSupportedBenefitsPageAsync.items + items = Optional.of(hrisBenefitListSupportedBenefitsPageAsync.items) } fun service(service: BenefitServiceAsync) = apply { this.service = service } @@ -97,7 +98,7 @@ private constructor( HrisBenefitListSupportedBenefitsPageAsync( checkRequired("service", service), checkRequired("params", params), - checkRequired("items", items), + checkRequired("items", items).getOrNull() ?: emptyList(), ) } From 7f20b31920efc885467782310013c07ae8d9c46c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 11 Apr 2025 14:36:15 +0000 Subject: [PATCH 13/13] release: 5.1.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 37 +++++++++++++++++++++++++++++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 44 insertions(+), 7 deletions(-) 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/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 40b26b41..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 ``` 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 {