From 4a698524363d93740d94cbec6fe9e58c163261fe 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:27 +0000 Subject: [PATCH] refactor(client): deduplicate page response classes 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() } } }