From ec2fe8b45c5898aee580617acbce9364802647be Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 21 May 2025 15:14:50 +0000 Subject: [PATCH 01/26] chore(docs): grammar improvements --- SECURITY.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SECURITY.md b/SECURITY.md index b6499508..1e432e1e 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -16,11 +16,11 @@ before making any information public. ## Reporting Non-SDK Related Security Issues If you encounter security issues that are not directly related to SDKs but pertain to the services -or products provided by Finch please follow the respective company's security reporting guidelines. +or products provided by Finch, please follow the respective company's security reporting guidelines. ### Finch Terms and Policies -Please contact founders@tryfinch.com for any questions or concerns regarding security of our services. +Please contact founders@tryfinch.com for any questions or concerns regarding the security of our services. --- From ad3d78f6515a72e9bc485e5eb9a5dfd98e8cd3d9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 14:06:42 +0000 Subject: [PATCH 02/26] feat(api): api update --- .stats.yml | 4 ++-- .../com/tryfinch/api/models/ConnectSessionNewParams.kt | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.stats.yml b/.stats.yml index 2493b56b..db3bf653 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-944a0f9d35f3b8ec2ba62fa12e551cf89f0b845f8ed1e3c7f67a9fb80b32d96f.yml -openapi_spec_hash: 37c849e7b5dd941c011385b49467e077 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-4fcae6958da081ca0e96ef6b3ce8f0b6e50994faaed8ecd6e94aa40ce1a93521.yml +openapi_spec_hash: a825b1120bb26f04505e3bc9ab1e48f3 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionNewParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionNewParams.kt index 7e1b5ca6..a2c22053 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionNewParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionNewParams.kt @@ -68,7 +68,7 @@ private constructor( fun manual(): Optional = body.manual() /** - * The number of minutes until the session expires (defaults to 43,200, which is 30 days) + * The number of minutes until the session expires (defaults to 129,600, which is 90 days) * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -297,7 +297,7 @@ private constructor( fun manual(manual: JsonField) = apply { body.manual(manual) } /** - * The number of minutes until the session expires (defaults to 43,200, which is 30 days) + * The number of minutes until the session expires (defaults to 129,600, which is 90 days) */ fun minutesToExpire(minutesToExpire: Double?) = apply { body.minutesToExpire(minutesToExpire) @@ -586,7 +586,7 @@ private constructor( fun manual(): Optional = manual.getOptional("manual") /** - * The number of minutes until the session expires (defaults to 43,200, which is 30 days) + * The number of minutes until the session expires (defaults to 129,600, which is 90 days) * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). @@ -847,7 +847,7 @@ private constructor( fun manual(manual: JsonField) = apply { this.manual = manual } /** - * The number of minutes until the session expires (defaults to 43,200, which is 30 + * The number of minutes until the session expires (defaults to 129,600, which is 90 * days) */ fun minutesToExpire(minutesToExpire: Double?) = From d06d641383d5b756ed558ce9dc23382995855b97 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 22 May 2025 19:39:05 +0000 Subject: [PATCH 03/26] feat(api): api update --- .stats.yml | 4 +- .../com/tryfinch/api/models/BenefitType.kt | 108 +- .../com/tryfinch/api/models/EmploymentData.kt | 2114 +++--- .../kotlin/com/tryfinch/api/models/Money.kt | 36 +- .../api/models/PayGroupListResponse.kt | 107 +- .../api/models/PayGroupRetrieveResponse.kt | 54 +- .../com/tryfinch/api/models/PayStatement.kt | 4255 ----------- .../models/PayStatementItemListResponse.kt | 159 +- .../api/models/PayStatementResponse.kt | 71 +- .../api/models/PayStatementResponseBody.kt | 6390 ++++++++++++++++- .../kotlin/com/tryfinch/api/models/Payment.kt | 169 +- .../api/models/SandboxPaymentCreateParams.kt | 2021 +++--- .../tryfinch/api/models/CompanyBenefitTest.kt | 6 +- .../api/models/EmploymentDataResponseTest.kt | 42 +- .../tryfinch/api/models/EmploymentDataTest.kt | 28 +- .../api/models/HrisBenefitCreateParamsTest.kt | 6 +- ...anyPayStatementItemListPageResponseTest.kt | 6 +- ...sEmploymentRetrieveManyPageResponseTest.kt | 42 +- ...ayStatementRetrieveManyPageResponseTest.kt | 424 +- .../com/tryfinch/api/models/MoneyTest.kt | 2 +- .../api/models/PayGroupListResponseTest.kt | 7 +- .../PayStatementItemListResponseTest.kt | 12 +- .../models/PayStatementResponseBodyTest.kt | 589 +- .../api/models/PayStatementResponseTest.kt | 603 +- .../tryfinch/api/models/PayStatementTest.kt | 375 - .../com/tryfinch/api/models/PaymentTest.kt | 2 +- .../models/SandboxPaymentCreateParamsTest.kt | 108 +- .../async/hris/BenefitServiceAsyncTest.kt | 2 +- .../async/sandbox/PaymentServiceAsyncTest.kt | 40 +- .../blocking/hris/BenefitServiceTest.kt | 2 +- .../blocking/sandbox/PaymentServiceTest.kt | 40 +- 31 files changed, 10132 insertions(+), 7692 deletions(-) delete mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt delete mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt diff --git a/.stats.yml b/.stats.yml index db3bf653..739ef65d 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-4fcae6958da081ca0e96ef6b3ce8f0b6e50994faaed8ecd6e94aa40ce1a93521.yml -openapi_spec_hash: a825b1120bb26f04505e3bc9ab1e48f3 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-5b7ee4cddd08558fb0cc5010d36899c0bbe5d6a8d39c8171f65b70b68927df3c.yml +openapi_spec_hash: c01482dc89e9bf7ae4c9dad0fb547e62 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitType.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitType.kt index 27b2ed15..b8526345 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitType.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitType.kt @@ -21,6 +21,8 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< companion object { + @JvmField val _457 = of("457") + @JvmField val _401K = of("401k") @JvmField val _401K_ROTH = of("401k_roth") @@ -31,58 +33,56 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< @JvmField val _403B_ROTH = of("403b_roth") - @JvmField val _457 = of("457") - @JvmField val _457_ROTH = of("457_roth") - @JvmField val S125_MEDICAL = of("s125_medical") - - @JvmField val S125_DENTAL = of("s125_dental") + @JvmField val COMMUTER = of("commuter") - @JvmField val S125_VISION = of("s125_vision") + @JvmField val CUSTOM_POST_TAX = of("custom_post_tax") - @JvmField val HSA_PRE = of("hsa_pre") + @JvmField val CUSTOM_PRE_TAX = of("custom_pre_tax") - @JvmField val HSA_POST = of("hsa_post") + @JvmField val FSA_DEPENDENT_CARE = of("fsa_dependent_care") @JvmField val FSA_MEDICAL = of("fsa_medical") - @JvmField val FSA_DEPENDENT_CARE = of("fsa_dependent_care") + @JvmField val HSA_POST = of("hsa_post") - @JvmField val SIMPLE_IRA = of("simple_ira") + @JvmField val HSA_PRE = of("hsa_pre") - @JvmField val SIMPLE = of("simple") + @JvmField val S125_DENTAL = of("s125_dental") - @JvmField val COMMUTER = of("commuter") + @JvmField val S125_MEDICAL = of("s125_medical") - @JvmField val CUSTOM_POST_TAX = of("custom_post_tax") + @JvmField val S125_VISION = of("s125_vision") - @JvmField val CUSTOM_PRE_TAX = of("custom_pre_tax") + @JvmField val SIMPLE = of("simple") + + @JvmField val SIMPLE_IRA = of("simple_ira") @JvmStatic fun of(value: String) = BenefitType(JsonField.of(value)) } /** An enum containing [BenefitType]'s known values. */ enum class Known { + _457, _401K, _401K_ROTH, _401K_LOAN, _403B, _403B_ROTH, - _457, _457_ROTH, - S125_MEDICAL, - S125_DENTAL, - S125_VISION, - HSA_PRE, - HSA_POST, - FSA_MEDICAL, - FSA_DEPENDENT_CARE, - SIMPLE_IRA, - SIMPLE, COMMUTER, CUSTOM_POST_TAX, CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, } /** @@ -95,25 +95,25 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { + _457, _401K, _401K_ROTH, _401K_LOAN, _403B, _403B_ROTH, - _457, _457_ROTH, - S125_MEDICAL, - S125_DENTAL, - S125_VISION, - HSA_PRE, - HSA_POST, - FSA_MEDICAL, - FSA_DEPENDENT_CARE, - SIMPLE_IRA, - SIMPLE, COMMUTER, CUSTOM_POST_TAX, CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, /** An enum member indicating that [BenefitType] was instantiated with an unknown value. */ _UNKNOWN, } @@ -127,25 +127,25 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< */ fun value(): Value = when (this) { + _457 -> Value._457 _401K -> Value._401K _401K_ROTH -> Value._401K_ROTH _401K_LOAN -> Value._401K_LOAN _403B -> Value._403B _403B_ROTH -> Value._403B_ROTH - _457 -> Value._457 _457_ROTH -> Value._457_ROTH - S125_MEDICAL -> Value.S125_MEDICAL - S125_DENTAL -> Value.S125_DENTAL - S125_VISION -> Value.S125_VISION - HSA_PRE -> Value.HSA_PRE - HSA_POST -> Value.HSA_POST - FSA_MEDICAL -> Value.FSA_MEDICAL - FSA_DEPENDENT_CARE -> Value.FSA_DEPENDENT_CARE - SIMPLE_IRA -> Value.SIMPLE_IRA - SIMPLE -> Value.SIMPLE COMMUTER -> Value.COMMUTER CUSTOM_POST_TAX -> Value.CUSTOM_POST_TAX CUSTOM_PRE_TAX -> Value.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Value.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Value.FSA_MEDICAL + HSA_POST -> Value.HSA_POST + HSA_PRE -> Value.HSA_PRE + S125_DENTAL -> Value.S125_DENTAL + S125_MEDICAL -> Value.S125_MEDICAL + S125_VISION -> Value.S125_VISION + SIMPLE -> Value.SIMPLE + SIMPLE_IRA -> Value.SIMPLE_IRA else -> Value._UNKNOWN } @@ -159,25 +159,25 @@ class BenefitType @JsonCreator private constructor(private val value: JsonField< */ fun known(): Known = when (this) { + _457 -> Known._457 _401K -> Known._401K _401K_ROTH -> Known._401K_ROTH _401K_LOAN -> Known._401K_LOAN _403B -> Known._403B _403B_ROTH -> Known._403B_ROTH - _457 -> Known._457 _457_ROTH -> Known._457_ROTH - S125_MEDICAL -> Known.S125_MEDICAL - S125_DENTAL -> Known.S125_DENTAL - S125_VISION -> Known.S125_VISION - HSA_PRE -> Known.HSA_PRE - HSA_POST -> Known.HSA_POST - FSA_MEDICAL -> Known.FSA_MEDICAL - FSA_DEPENDENT_CARE -> Known.FSA_DEPENDENT_CARE - SIMPLE_IRA -> Known.SIMPLE_IRA - SIMPLE -> Known.SIMPLE COMMUTER -> Known.COMMUTER CUSTOM_POST_TAX -> Known.CUSTOM_POST_TAX CUSTOM_PRE_TAX -> Known.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Known.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Known.FSA_MEDICAL + HSA_POST -> Known.HSA_POST + HSA_PRE -> Known.HSA_PRE + S125_DENTAL -> Known.S125_DENTAL + S125_MEDICAL -> Known.S125_MEDICAL + S125_VISION -> Known.S125_VISION + SIMPLE -> Known.SIMPLE + SIMPLE_IRA -> Known.SIMPLE_IRA else -> throw FinchInvalidDataException("Unknown BenefitType: $value") } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentData.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentData.kt index bd97abad..e95ca383 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentData.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentData.kt @@ -207,7 +207,6 @@ private constructor( private constructor( private val id: JsonField, private val classCode: JsonField, - private val customFields: JsonField>, private val department: JsonField, private val employment: JsonField, private val employmentStatus: JsonField, @@ -221,10 +220,11 @@ private constructor( private val middleName: JsonField, private val startDate: JsonField, private val title: JsonField, - private val workId: JsonField, + private val customFields: JsonField>, private val income: JsonField, private val incomeHistory: JsonField>, private val sourceId: JsonField, + private val workId: JsonField, private val additionalProperties: MutableMap, ) { @@ -234,9 +234,6 @@ private constructor( @JsonProperty("class_code") @ExcludeMissing classCode: JsonField = JsonMissing.of(), - @JsonProperty("custom_fields") - @ExcludeMissing - customFields: JsonField> = JsonMissing.of(), @JsonProperty("department") @ExcludeMissing department: JsonField = JsonMissing.of(), @@ -270,7 +267,9 @@ private constructor( @ExcludeMissing startDate: JsonField = JsonMissing.of(), @JsonProperty("title") @ExcludeMissing title: JsonField = JsonMissing.of(), - @JsonProperty("work_id") @ExcludeMissing workId: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + customFields: JsonField> = JsonMissing.of(), @JsonProperty("income") @ExcludeMissing income: JsonField = JsonMissing.of(), @JsonProperty("income_history") @ExcludeMissing @@ -278,10 +277,10 @@ private constructor( @JsonProperty("source_id") @ExcludeMissing sourceId: JsonField = JsonMissing.of(), + @JsonProperty("work_id") @ExcludeMissing workId: JsonField = JsonMissing.of(), ) : this( id, classCode, - customFields, department, employment, employmentStatus, @@ -295,10 +294,11 @@ private constructor( middleName, startDate, title, - workId, + customFields, income, incomeHistory, sourceId, + workId, mutableMapOf(), ) @@ -318,15 +318,6 @@ private constructor( */ fun classCode(): Optional = classCode.getOptional("class_code") - /** - * Custom fields for the individual. These are fields which are defined by the employer in - * the system. Custom fields are not currently supported for assisted connections. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun customFields(): Optional> = customFields.getOptional("custom_fields") - /** * The department object. * @@ -427,12 +418,13 @@ private constructor( fun title(): Optional = title.getOptional("title") /** - * This field is deprecated in favour of `source_id` + * Custom fields for the individual. These are fields which are defined by the employer in + * the system. Custom fields are not currently supported for assisted connections. * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - @Deprecated("deprecated") fun workId(): Optional = workId.getOptional("work_id") + fun customFields(): Optional> = customFields.getOptional("custom_fields") /** * The employee's income as reported by the provider. This may not always be annualized @@ -460,6 +452,14 @@ private constructor( */ fun sourceId(): Optional = sourceId.getOptional("source_id") + /** + * This field is deprecated in favour of `source_id` + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + @Deprecated("deprecated") fun workId(): Optional = workId.getOptional("work_id") + /** * Returns the raw JSON value of [id]. * @@ -474,16 +474,6 @@ private constructor( */ @JsonProperty("class_code") @ExcludeMissing fun _classCode(): JsonField = classCode - /** - * Returns the raw JSON value of [customFields]. - * - * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("custom_fields") - @ExcludeMissing - fun _customFields(): JsonField> = customFields - /** * Returns the raw JSON value of [department]. * @@ -588,14 +578,14 @@ private constructor( @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title /** - * Returns the raw JSON value of [workId]. + * Returns the raw JSON value of [customFields]. * - * Unlike [workId], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [customFields], this method doesn't throw if the JSON field has an unexpected + * type. */ - @Deprecated("deprecated") - @JsonProperty("work_id") + @JsonProperty("custom_fields") @ExcludeMissing - fun _workId(): JsonField = workId + fun _customFields(): JsonField> = customFields /** * Returns the raw JSON value of [income]. @@ -621,6 +611,16 @@ private constructor( */ @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId + /** + * Returns the raw JSON value of [workId]. + * + * Unlike [workId], this method doesn't throw if the JSON field has an unexpected type. + */ + @Deprecated("deprecated") + @JsonProperty("work_id") + @ExcludeMissing + fun _workId(): JsonField = workId + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -642,7 +642,6 @@ private constructor( * ```java * .id() * .classCode() - * .customFields() * .department() * .employment() * .employmentStatus() @@ -656,7 +655,6 @@ private constructor( * .middleName() * .startDate() * .title() - * .workId() * ``` */ @JvmStatic fun builder() = Builder() @@ -667,7 +665,6 @@ private constructor( private var id: JsonField? = null private var classCode: JsonField? = null - private var customFields: JsonField>? = null private var department: JsonField? = null private var employment: JsonField? = null private var employmentStatus: JsonField? = null @@ -681,17 +678,17 @@ private constructor( private var middleName: JsonField? = null private var startDate: JsonField? = null private var title: JsonField? = null - private var workId: JsonField? = null + private var customFields: JsonField>? = null private var income: JsonField = JsonMissing.of() private var incomeHistory: JsonField>? = null private var sourceId: JsonField = JsonMissing.of() + private var workId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(unionMember0: UnionMember0) = apply { id = unionMember0.id classCode = unionMember0.classCode - customFields = unionMember0.customFields.map { it.toMutableList() } department = unionMember0.department employment = unionMember0.employment employmentStatus = unionMember0.employmentStatus @@ -705,10 +702,11 @@ private constructor( middleName = unionMember0.middleName startDate = unionMember0.startDate title = unionMember0.title - workId = unionMember0.workId + customFields = unionMember0.customFields.map { it.toMutableList() } income = unionMember0.income incomeHistory = unionMember0.incomeHistory.map { it.toMutableList() } sourceId = unionMember0.sourceId + workId = unionMember0.workId additionalProperties = unionMember0.additionalProperties.toMutableMap() } @@ -739,40 +737,6 @@ private constructor( */ fun classCode(classCode: JsonField) = apply { this.classCode = classCode } - /** - * Custom fields for the individual. These are fields which are defined by the employer - * in the system. Custom fields are not currently supported for assisted connections. - */ - fun customFields(customFields: List?) = - customFields(JsonField.ofNullable(customFields)) - - /** Alias for calling [Builder.customFields] with `customFields.orElse(null)`. */ - fun customFields(customFields: Optional>) = - customFields(customFields.getOrNull()) - - /** - * Sets [Builder.customFields] to an arbitrary JSON value. - * - * You should usually call [Builder.customFields] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun customFields(customFields: JsonField>) = apply { - this.customFields = customFields.map { it.toMutableList() } - } - - /** - * Adds a single [CustomField] to [customFields]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCustomField(customField: CustomField) = apply { - customFields = - (customFields ?: JsonField.of(mutableListOf())).also { - checkKnown("customFields", it).add(customField) - } - } - /** The department object. */ fun department(department: Department?) = department(JsonField.ofNullable(department)) @@ -990,23 +954,39 @@ private constructor( */ fun title(title: JsonField) = apply { this.title = title } - /** This field is deprecated in favour of `source_id` */ - @Deprecated("deprecated") - fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) + /** + * Custom fields for the individual. These are fields which are defined by the employer + * in the system. Custom fields are not currently supported for assisted connections. + */ + fun customFields(customFields: List?) = + customFields(JsonField.ofNullable(customFields)) - /** Alias for calling [Builder.workId] with `workId.orElse(null)`. */ - @Deprecated("deprecated") - fun workId(workId: Optional) = workId(workId.getOrNull()) + /** Alias for calling [Builder.customFields] with `customFields.orElse(null)`. */ + fun customFields(customFields: Optional>) = + customFields(customFields.getOrNull()) /** - * Sets [Builder.workId] to an arbitrary JSON value. + * Sets [Builder.customFields] to an arbitrary JSON value. * - * You should usually call [Builder.workId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.customFields] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. */ - @Deprecated("deprecated") - fun workId(workId: JsonField) = apply { this.workId = workId } + fun customFields(customFields: JsonField>) = apply { + this.customFields = customFields.map { it.toMutableList() } + } + + /** + * Adds a single [CustomField] to [customFields]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addCustomField(customField: CustomField) = apply { + customFields = + (customFields ?: JsonField.of(mutableListOf())).also { + checkKnown("customFields", it).add(customField) + } + } /** * The employee's income as reported by the provider. This may not always be annualized @@ -1073,6 +1053,24 @@ private constructor( */ fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } + /** This field is deprecated in favour of `source_id` */ + @Deprecated("deprecated") + fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) + + /** Alias for calling [Builder.workId] with `workId.orElse(null)`. */ + @Deprecated("deprecated") + fun workId(workId: Optional) = workId(workId.getOrNull()) + + /** + * Sets [Builder.workId] to an arbitrary JSON value. + * + * You should usually call [Builder.workId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + @Deprecated("deprecated") + fun workId(workId: JsonField) = apply { this.workId = workId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1101,7 +1099,6 @@ private constructor( * ```java * .id() * .classCode() - * .customFields() * .department() * .employment() * .employmentStatus() @@ -1115,7 +1112,6 @@ private constructor( * .middleName() * .startDate() * .title() - * .workId() * ``` * * @throws IllegalStateException if any required field is unset. @@ -1124,7 +1120,6 @@ private constructor( UnionMember0( checkRequired("id", id), checkRequired("classCode", classCode), - checkRequired("customFields", customFields).map { it.toImmutable() }, checkRequired("department", department), checkRequired("employment", employment), checkRequired("employmentStatus", employmentStatus), @@ -1138,10 +1133,11 @@ private constructor( checkRequired("middleName", middleName), checkRequired("startDate", startDate), checkRequired("title", title), - checkRequired("workId", workId), + (customFields ?: JsonMissing.of()).map { it.toImmutable() }, income, (incomeHistory ?: JsonMissing.of()).map { it.toImmutable() }, sourceId, + workId, additionalProperties.toMutableMap(), ) } @@ -1155,7 +1151,6 @@ private constructor( id() classCode() - customFields().ifPresent { it.forEach { it.validate() } } department().ifPresent { it.validate() } employment().ifPresent { it.validate() } employmentStatus().ifPresent { it.validate() } @@ -1169,10 +1164,11 @@ private constructor( middleName() startDate() title() - workId() + customFields().ifPresent { it.forEach { it.validate() } } income().ifPresent { it.validate() } incomeHistory().ifPresent { it.forEach { it?.validate() } } sourceId() + workId() validated = true } @@ -1194,7 +1190,6 @@ private constructor( internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + (if (classCode.asKnown().isPresent) 1 else 0) + - (customFields.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (department.asKnown().getOrNull()?.validity() ?: 0) + (employment.asKnown().getOrNull()?.validity() ?: 0) + (employmentStatus.asKnown().getOrNull()?.validity() ?: 0) + @@ -1208,37 +1203,33 @@ private constructor( (if (middleName.asKnown().isPresent) 1 else 0) + (if (startDate.asKnown().isPresent) 1 else 0) + (if (title.asKnown().isPresent) 1 else 0) + - (if (workId.asKnown().isPresent) 1 else 0) + + (customFields.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + (income.asKnown().getOrNull()?.validity() ?: 0) + (incomeHistory.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (if (sourceId.asKnown().isPresent) 1 else 0) + (if (sourceId.asKnown().isPresent) 1 else 0) + + (if (workId.asKnown().isPresent) 1 else 0) - class CustomField + /** The department object. */ + class Department private constructor( private val name: JsonField, - private val value: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), - ) : this(name, value, mutableMapOf()) + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() + ) : this(name, mutableMapOf()) /** + * The name of the department associated with the individual. + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if * the server responded with an unexpected value). */ fun name(): Optional = name.getOptional("name") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun value(): Optional = value.getOptional("value") - /** * Returns the raw JSON value of [name]. * @@ -1246,13 +1237,6 @@ private constructor( */ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - /** - * Returns the raw JSON value of [value]. - * - * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value - @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1267,24 +1251,30 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [CustomField]. */ + /** + * Returns a mutable builder for constructing an instance of [Department]. + * + * The following fields are required: + * ```java + * .name() + * ``` + */ @JvmStatic fun builder() = Builder() } - /** A builder for [CustomField]. */ + /** A builder for [Department]. */ class Builder internal constructor() { - private var name: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(customField: CustomField) = apply { - name = customField.name - value = customField.value - additionalProperties = customField.additionalProperties.toMutableMap() + internal fun from(department: Department) = apply { + name = department.name + additionalProperties = department.additionalProperties.toMutableMap() } + /** The name of the department associated with the individual. */ fun name(name: String?) = name(JsonField.ofNullable(name)) /** Alias for calling [Builder.name] with `name.orElse(null)`. */ @@ -1299,36 +1289,6 @@ private constructor( */ fun name(name: JsonField) = apply { this.name = name } - fun value(value: Value?) = value(JsonField.ofNullable(value)) - - /** Alias for calling [Builder.value] with `value.orElse(null)`. */ - fun value(value: Optional) = value(value.getOrNull()) - - /** - * Sets [Builder.value] to an arbitrary JSON value. - * - * You should usually call [Builder.value] with a well-typed [Value] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun value(value: JsonField) = apply { this.value = value } - - /** Alias for calling [value] with `Value.ofString(string)`. */ - fun value(string: String) = value(Value.ofString(string)) - - /** Alias for calling [value] with `Value.ofJsonValues(jsonValues)`. */ - fun valueOfJsonValues(jsonValues: List) = - value(Value.ofJsonValues(jsonValues)) - - /** Alias for calling [value] with `Value.ofJson(json)`. */ - fun value(json: JsonValue) = value(Value.ofJson(json)) - - /** Alias for calling [value] with `Value.ofNumber(number)`. */ - fun value(number: Double) = value(Value.ofNumber(number)) - - /** Alias for calling [value] with `Value.ofBool(bool)`. */ - fun value(bool: Boolean) = value(Value.ofBool(bool)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1352,23 +1312,29 @@ private constructor( } /** - * Returns an immutable instance of [CustomField]. + * Returns an immutable instance of [Department]. * * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): CustomField = - CustomField(name, value, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false + * + * The following fields are required: + * ```java + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Department = + Department(checkRequired("name", name), additionalProperties.toMutableMap()) + } - fun validate(): CustomField = apply { + private var validated: Boolean = false + + fun validate(): Department = apply { if (validated) { return@apply } name() - value().ifPresent { it.validate() } validated = true } @@ -1386,566 +1352,166 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic - internal fun validity(): Int = - (if (name.asKnown().isPresent) 1 else 0) + - (value.asKnown().getOrNull()?.validity() ?: 0) - - @JsonDeserialize(using = Value.Deserializer::class) - @JsonSerialize(using = Value.Serializer::class) - class Value - private constructor( - private val string: String? = null, - private val jsonValues: List? = null, - private val json: JsonValue? = null, - private val number: Double? = null, - private val bool: Boolean? = null, - private val _json: JsonValue? = null, - ) { - - fun string(): Optional = Optional.ofNullable(string) - - fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) - - fun json(): Optional = Optional.ofNullable(json) - - fun number(): Optional = Optional.ofNullable(number) - - fun bool(): Optional = Optional.ofNullable(bool) + @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) - fun isString(): Boolean = string != null + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun isJsonValues(): Boolean = jsonValues != null + return /* spotless:off */ other is Department && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } - fun isJson(): Boolean = json != null + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } + /* spotless:on */ - fun isNumber(): Boolean = number != null + override fun hashCode(): Int = hashCode - fun isBool(): Boolean = bool != null + override fun toString() = + "Department{name=$name, additionalProperties=$additionalProperties}" + } - fun asString(): String = string.getOrThrow("string") + /** The employment object. */ + class Employment + private constructor( + private val subtype: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { - fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + @JsonCreator + private constructor( + @JsonProperty("subtype") + @ExcludeMissing + subtype: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(subtype, type, mutableMapOf()) - fun asJson(): JsonValue = json.getOrThrow("json") + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun subtype(): Optional = subtype.getOptional("subtype") - fun asNumber(): Double = number.getOrThrow("number") + /** + * The main employment type of the individual. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") - fun asBool(): Boolean = bool.getOrThrow("bool") + /** + * Returns the raw JSON value of [subtype]. + * + * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - fun accept(visitor: Visitor): T = - when { - string != null -> visitor.visitString(string) - jsonValues != null -> visitor.visitJsonValues(jsonValues) - json != null -> visitor.visitJson(json) - number != null -> visitor.visitNumber(number) - bool != null -> visitor.visitBool(bool) - else -> visitor.unknown(_json) - } + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - private var validated: Boolean = false + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun validate(): Value = apply { - if (validated) { - return@apply - } + fun toBuilder() = Builder().from(this) - accept( - object : Visitor { - override fun visitString(string: String) {} + companion object { - override fun visitJsonValues(jsonValues: List) {} + /** + * Returns a mutable builder for constructing an instance of [Employment]. + * + * The following fields are required: + * ```java + * .subtype() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - override fun visitJson(json: JsonValue) {} + /** A builder for [Employment]. */ + class Builder internal constructor() { - override fun visitNumber(number: Double) {} + private var subtype: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - override fun visitBool(bool: Boolean) {} - } - ) - validated = true + @JvmSynthetic + internal fun from(employment: Employment) = apply { + subtype = employment.subtype + type = employment.type + additionalProperties = employment.additionalProperties.toMutableMap() } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. + * The secondary employment type of the individual. Options: `full_time`, + * `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`. */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitString(string: String) = 1 - - override fun visitJsonValues(jsonValues: List) = - jsonValues.size + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) - override fun visitJson(json: JsonValue) = 1 + /** Alias for calling [Builder.subtype] with `subtype.orElse(null)`. */ + fun subtype(subtype: Optional) = subtype(subtype.getOrNull()) - override fun visitNumber(number: Double) = 1 + /** + * Sets [Builder.subtype] to an arbitrary JSON value. + * + * You should usually call [Builder.subtype] with a well-typed [Subtype] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } - override fun visitBool(bool: Boolean) = 1 + /** The main employment type of the individual. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) - override fun unknown(json: JsonValue?) = 0 - } - ) + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } - return /* spotless:off */ other is Value && string == other.string && jsonValues == other.jsonValues && json == other.json && number == other.number && bool == other.bool /* spotless:on */ + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, jsonValues, json, number, bool) /* spotless:on */ + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - override fun toString(): String = - when { - string != null -> "Value{string=$string}" - jsonValues != null -> "Value{jsonValues=$jsonValues}" - json != null -> "Value{json=$json}" - number != null -> "Value{number=$number}" - bool != null -> "Value{bool=$bool}" - _json != null -> "Value{_unknown=$_json}" - else -> throw IllegalStateException("Invalid Value") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - companion object { - - @JvmStatic fun ofString(string: String) = Value(string = string) - - @JvmStatic - fun ofJsonValues(jsonValues: List) = Value(jsonValues = jsonValues) - - @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) - - @JvmStatic fun ofNumber(number: Double) = Value(number = number) + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } - @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) - } - - /** - * An interface that defines how to map each variant of [Value] to a value of type - * [T]. - */ - interface Visitor { - - fun visitString(string: String): T - - fun visitJsonValues(jsonValues: List): T - - fun visitJson(json: JsonValue): T - - fun visitNumber(number: Double): T - - fun visitBool(bool: Boolean): T - - /** - * Maps an unknown variant of [Value] to a value of type [T]. - * - * An instance of [Value] can contain an unknown variant if it was deserialized - * from data that doesn't match any known variant. For example, if the SDK is on - * an older version than the API, then the API may respond with new variants - * that the SDK is unaware of. - * - * @throws FinchInvalidDataException in the default implementation. - */ - fun unknown(json: JsonValue?): T { - throw FinchInvalidDataException("Unknown Value: $json") - } - } - - internal class Deserializer : BaseDeserializer(Value::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): Value { - val json = JsonValue.fromJsonNode(node) - - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - Value(string = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef>())?.let { - Value(jsonValues = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(number = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(bool = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - Value(json = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely - // incompatible with all the possible variants. - 0 -> Value(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use - // the first completely valid match, or simply the first match if none - // are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } - } - } - - internal class Serializer : BaseSerializer(Value::class) { - - override fun serialize( - value: Value, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.string != null -> generator.writeObject(value.string) - value.jsonValues != null -> generator.writeObject(value.jsonValues) - value.json != null -> generator.writeObject(value.json) - value.number != null -> generator.writeObject(value.number) - value.bool != null -> generator.writeObject(value.bool) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid Value") - } - } - } - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CustomField && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, value, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "CustomField{name=$name, value=$value, additionalProperties=$additionalProperties}" - } - - /** The department object. */ - class Department - private constructor( - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of() - ) : this(name, mutableMapOf()) - - /** - * The name of the department associated with the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Department]. - * - * The following fields are required: - * ```java - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Department]. */ - class Builder internal constructor() { - - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(department: Department) = apply { - name = department.name - additionalProperties = department.additionalProperties.toMutableMap() - } - - /** The name of the department associated with the individual. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Department]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Department = - Department(checkRequired("name", name), additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Department = apply { - if (validated) { - return@apply - } - - name() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (name.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Department && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Department{name=$name, additionalProperties=$additionalProperties}" - } - - /** The employment object. */ - class Employment - private constructor( - private val subtype: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("subtype") - @ExcludeMissing - subtype: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(subtype, type, mutableMapOf()) - - /** - * The secondary employment type of the individual. Options: `full_time`, `part_time`, - * `intern`, `temp`, `seasonal` and `individual_contractor`. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun subtype(): Optional = subtype.getOptional("subtype") - - /** - * The main employment type of the individual. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [subtype]. - * - * Unlike [subtype], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Employment]. - * - * The following fields are required: - * ```java - * .subtype() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Employment]. */ - class Builder internal constructor() { - - private var subtype: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employment: Employment) = apply { - subtype = employment.subtype - type = employment.type - additionalProperties = employment.additionalProperties.toMutableMap() - } - - /** - * The secondary employment type of the individual. Options: `full_time`, - * `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`. - */ - fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) - - /** Alias for calling [Builder.subtype] with `subtype.orElse(null)`. */ - fun subtype(subtype: Optional) = subtype(subtype.getOrNull()) - - /** - * Sets [Builder.subtype] to an arbitrary JSON value. - * - * You should usually call [Builder.subtype] with a well-typed [Subtype] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun subtype(subtype: JsonField) = apply { this.subtype = subtype } - - /** The main employment type of the individual. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } /** @@ -2027,42 +1593,181 @@ private constructor( @JvmField val TEMP = of("temp") - @JvmField val SEASONAL = of("seasonal") + @JvmField val SEASONAL = of("seasonal") + + @JvmField val INDIVIDUAL_CONTRACTOR = of("individual_contractor") + + @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) + } + + /** An enum containing [Subtype]'s known values. */ + enum class Known { + FULL_TIME, + INTERN, + PART_TIME, + TEMP, + SEASONAL, + INDIVIDUAL_CONTRACTOR, + } + + /** + * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Subtype] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FULL_TIME, + INTERN, + PART_TIME, + TEMP, + SEASONAL, + INDIVIDUAL_CONTRACTOR, + /** + * An enum member indicating that [Subtype] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FULL_TIME -> Value.FULL_TIME + INTERN -> Value.INTERN + PART_TIME -> Value.PART_TIME + TEMP -> Value.TEMP + SEASONAL -> Value.SEASONAL + INDIVIDUAL_CONTRACTOR -> Value.INDIVIDUAL_CONTRACTOR + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FULL_TIME -> Known.FULL_TIME + INTERN -> Known.INTERN + PART_TIME -> Known.PART_TIME + TEMP -> Known.TEMP + SEASONAL -> Known.SEASONAL + INDIVIDUAL_CONTRACTOR -> Known.INDIVIDUAL_CONTRACTOR + else -> throw FinchInvalidDataException("Unknown Subtype: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Subtype = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Subtype && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The main employment type of the individual. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val EMPLOYEE = of("employee") - @JvmField val INDIVIDUAL_CONTRACTOR = of("individual_contractor") + @JvmField val CONTRACTOR = of("contractor") - @JvmStatic fun of(value: String) = Subtype(JsonField.of(value)) + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - /** An enum containing [Subtype]'s known values. */ + /** An enum containing [Type]'s known values. */ enum class Known { - FULL_TIME, - INTERN, - PART_TIME, - TEMP, - SEASONAL, - INDIVIDUAL_CONTRACTOR, + EMPLOYEE, + CONTRACTOR, } /** - * An enum containing [Subtype]'s known values, as well as an [_UNKNOWN] member. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * - * An instance of [Subtype] can contain an unknown value in a couple of cases: + * An instance of [Type] can contain an unknown value in a couple of cases: * - It was deserialized from data that doesn't match any known member. For example, * if the SDK is on an older version than the API, then the API may respond with * new members that the SDK is unaware of. * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - FULL_TIME, - INTERN, - PART_TIME, - TEMP, - SEASONAL, - INDIVIDUAL_CONTRACTOR, + EMPLOYEE, + CONTRACTOR, /** - * An enum member indicating that [Subtype] was instantiated with an unknown - * value. + * An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -2076,12 +1781,8 @@ private constructor( */ fun value(): Value = when (this) { - FULL_TIME -> Value.FULL_TIME - INTERN -> Value.INTERN - PART_TIME -> Value.PART_TIME - TEMP -> Value.TEMP - SEASONAL -> Value.SEASONAL - INDIVIDUAL_CONTRACTOR -> Value.INDIVIDUAL_CONTRACTOR + EMPLOYEE -> Value.EMPLOYEE + CONTRACTOR -> Value.CONTRACTOR else -> Value._UNKNOWN } @@ -2096,13 +1797,9 @@ private constructor( */ fun known(): Known = when (this) { - FULL_TIME -> Known.FULL_TIME - INTERN -> Known.INTERN - PART_TIME -> Known.PART_TIME - TEMP -> Known.TEMP - SEASONAL -> Known.SEASONAL - INDIVIDUAL_CONTRACTOR -> Known.INDIVIDUAL_CONTRACTOR - else -> throw FinchInvalidDataException("Unknown Subtype: $value") + EMPLOYEE -> Known.EMPLOYEE + CONTRACTOR -> Known.CONTRACTOR + else -> throw FinchInvalidDataException("Unknown Type: $value") } /** @@ -2121,7 +1818,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Subtype = apply { + fun validate(): Type = apply { if (validated) { return@apply } @@ -2146,303 +1843,518 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Employment && subtype == other.subtype && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(subtype, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" + } + + /** + * The detailed employment status of the individual. Available options: `active`, + * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + */ + class EmploymentStatus + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACTIVE = of("active") + + @JvmField val DECEASED = of("deceased") + + @JvmField val LEAVE = of("leave") + + @JvmField val ONBOARDING = of("onboarding") + + @JvmField val PREHIRE = of("prehire") + + @JvmField val RETIRED = of("retired") + + @JvmField val TERMINATED = of("terminated") + + @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) + } + + /** An enum containing [EmploymentStatus]'s known values. */ + enum class Known { + ACTIVE, + DECEASED, + LEAVE, + ONBOARDING, + PREHIRE, + RETIRED, + TERMINATED, + } + + /** + * An enum containing [EmploymentStatus]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [EmploymentStatus] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACTIVE, + DECEASED, + LEAVE, + ONBOARDING, + PREHIRE, + RETIRED, + TERMINATED, + /** + * An enum member indicating that [EmploymentStatus] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACTIVE -> Value.ACTIVE + DECEASED -> Value.DECEASED + LEAVE -> Value.LEAVE + ONBOARDING -> Value.ONBOARDING + PREHIRE -> Value.PREHIRE + RETIRED -> Value.RETIRED + TERMINATED -> Value.TERMINATED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACTIVE -> Known.ACTIVE + DECEASED -> Known.DECEASED + LEAVE -> Known.LEAVE + ONBOARDING -> Known.ONBOARDING + PREHIRE -> Known.PREHIRE + RETIRED -> Known.RETIRED + TERMINATED -> Known.TERMINATED + else -> throw FinchInvalidDataException("Unknown EmploymentStatus: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): EmploymentStatus = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EmploymentStatus && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The manager object representing the manager of the individual within the org. */ + class Manager + private constructor( + private val id: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() + ) : this(id, mutableMapOf()) - return /* spotless:off */ other is Subtype && value == other.value /* spotless:on */ - } + /** + * A stable Finch `id` (UUID v4) for an individual in the company. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun id(): String = id.getRequired("id") - override fun hashCode() = value.hashCode() + /** + * Returns the raw JSON value of [id]. + * + * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - override fun toString() = value.toString() + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - /** The main employment type of the individual. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { /** - * Returns this class instance's raw value. + * Returns a mutable builder for constructing an instance of [Manager]. * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. + * The following fields are required: + * ```java + * .id() + * ``` */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val EMPLOYEE = of("employee") - - @JvmField val CONTRACTOR = of("contractor") + @JvmStatic fun builder() = Builder() + } - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } + /** A builder for [Manager]. */ + class Builder internal constructor() { - /** An enum containing [Type]'s known values. */ - enum class Known { - EMPLOYEE, - CONTRACTOR, - } + private var id: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - EMPLOYEE, - CONTRACTOR, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, + @JvmSynthetic + internal fun from(manager: Manager) = apply { + id = manager.id + additionalProperties = manager.additionalProperties.toMutableMap() } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - EMPLOYEE -> Value.EMPLOYEE - CONTRACTOR -> Value.CONTRACTOR - else -> Value._UNKNOWN - } + /** A stable Finch `id` (UUID v4) for an individual in the company. */ + fun id(id: String) = id(JsonField.of(id)) /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. + * Sets [Builder.id] to an arbitrary JSON value. * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. + * You should usually call [Builder.id] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun known(): Known = - when (this) { - EMPLOYEE -> Known.EMPLOYEE - CONTRACTOR -> Known.CONTRACTOR - else -> throw FinchInvalidDataException("Unknown Type: $value") - } + fun id(id: JsonField) = apply { this.id = id } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } - private var validated: Boolean = false + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun validate(): Type = apply { - if (validated) { - return@apply + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) } - known() - validated = true + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * Returns an immutable instance of [Manager]. * - * Used for best match union deserialization. + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + fun build(): Manager = + Manager(checkRequired("id", id), additionalProperties.toMutableMap()) + } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + private var validated: Boolean = false - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + fun validate(): Manager = apply { + if (validated) { + return@apply } - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() + id() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Employment && subtype == other.subtype && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Manager && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(subtype, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = - "Employment{subtype=$subtype, type=$type, additionalProperties=$additionalProperties}" + override fun toString() = "Manager{id=$id, additionalProperties=$additionalProperties}" } - /** - * The detailed employment status of the individual. Available options: `active`, - * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. - */ - class EmploymentStatus - @JsonCreator - private constructor(private val value: JsonField) : Enum { + class CustomField + private constructor( + private val name: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(name, value, mutableMapOf()) /** - * Returns this class instance's raw value. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun value(): Optional = value.getOptional("value") + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [value]. * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. + * Unlike [value], this method doesn't throw if the JSON field has an unexpected type. */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) companion object { - @JvmField val ACTIVE = of("active") + /** Returns a mutable builder for constructing an instance of [CustomField]. */ + @JvmStatic fun builder() = Builder() + } - @JvmField val DECEASED = of("deceased") + /** A builder for [CustomField]. */ + class Builder internal constructor() { - @JvmField val LEAVE = of("leave") + private var name: JsonField = JsonMissing.of() + private var value: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JvmField val ONBOARDING = of("onboarding") + @JvmSynthetic + internal fun from(customField: CustomField) = apply { + name = customField.name + value = customField.value + additionalProperties = customField.additionalProperties.toMutableMap() + } - @JvmField val PREHIRE = of("prehire") + fun name(name: String?) = name(JsonField.ofNullable(name)) - @JvmField val RETIRED = of("retired") + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) - @JvmField val TERMINATED = of("terminated") + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } - @JvmStatic fun of(value: String) = EmploymentStatus(JsonField.of(value)) - } + fun value(value: Value?) = value(JsonField.ofNullable(value)) - /** An enum containing [EmploymentStatus]'s known values. */ - enum class Known { - ACTIVE, - DECEASED, - LEAVE, - ONBOARDING, - PREHIRE, - RETIRED, - TERMINATED, - } + /** Alias for calling [Builder.value] with `value.orElse(null)`. */ + fun value(value: Optional) = value(value.getOrNull()) - /** - * An enum containing [EmploymentStatus]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [EmploymentStatus] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACTIVE, - DECEASED, - LEAVE, - ONBOARDING, - PREHIRE, - RETIRED, - TERMINATED, /** - * An enum member indicating that [EmploymentStatus] was instantiated with an - * unknown value. + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [Value] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - _UNKNOWN, - } + fun value(value: JsonField) = apply { this.value = value } - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACTIVE -> Value.ACTIVE - DECEASED -> Value.DECEASED - LEAVE -> Value.LEAVE - ONBOARDING -> Value.ONBOARDING - PREHIRE -> Value.PREHIRE - RETIRED -> Value.RETIRED - TERMINATED -> Value.TERMINATED - else -> Value._UNKNOWN + /** Alias for calling [value] with `Value.ofString(string)`. */ + fun value(string: String) = value(Value.ofString(string)) + + /** Alias for calling [value] with `Value.ofJsonValues(jsonValues)`. */ + fun valueOfJsonValues(jsonValues: List) = + value(Value.ofJsonValues(jsonValues)) + + /** Alias for calling [value] with `Value.ofJson(json)`. */ + fun value(json: JsonValue) = value(Value.ofJson(json)) + + /** Alias for calling [value] with `Value.ofNumber(number)`. */ + fun value(number: Double) = value(Value.ofNumber(number)) + + /** Alias for calling [value] with `Value.ofBool(bool)`. */ + fun value(bool: Boolean) = value(Value.ofBool(bool)) + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ACTIVE -> Known.ACTIVE - DECEASED -> Known.DECEASED - LEAVE -> Known.LEAVE - ONBOARDING -> Known.ONBOARDING - PREHIRE -> Known.PREHIRE - RETIRED -> Known.RETIRED - TERMINATED -> Known.TERMINATED - else -> throw FinchInvalidDataException("Unknown EmploymentStatus: $value") + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) } - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) } + /** + * Returns an immutable instance of [CustomField]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CustomField = + CustomField(name, value, additionalProperties.toMutableMap()) + } + private var validated: Boolean = false - fun validate(): EmploymentStatus = apply { + fun validate(): CustomField = apply { if (validated) { return@apply } - known() + name() + value().ifPresent { it.validate() } validated = true } @@ -2460,178 +2372,262 @@ private constructor( * * Used for best match union deserialization. */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + @JvmSynthetic + internal fun validity(): Int = + (if (name.asKnown().isPresent) 1 else 0) + + (value.asKnown().getOrNull()?.validity() ?: 0) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + @JsonDeserialize(using = Value.Deserializer::class) + @JsonSerialize(using = Value.Serializer::class) + class Value + private constructor( + private val string: String? = null, + private val jsonValues: List? = null, + private val json: JsonValue? = null, + private val number: Double? = null, + private val bool: Boolean? = null, + private val _json: JsonValue? = null, + ) { - return /* spotless:off */ other is EmploymentStatus && value == other.value /* spotless:on */ - } + fun string(): Optional = Optional.ofNullable(string) - override fun hashCode() = value.hashCode() + fun jsonValues(): Optional> = Optional.ofNullable(jsonValues) - override fun toString() = value.toString() - } + fun json(): Optional = Optional.ofNullable(json) - /** The manager object representing the manager of the individual within the org. */ - class Manager - private constructor( - private val id: JsonField, - private val additionalProperties: MutableMap, - ) { + fun number(): Optional = Optional.ofNullable(number) + + fun bool(): Optional = Optional.ofNullable(bool) + + fun isString(): Boolean = string != null + + fun isJsonValues(): Boolean = jsonValues != null + + fun isJson(): Boolean = json != null + + fun isNumber(): Boolean = number != null + + fun isBool(): Boolean = bool != null + + fun asString(): String = string.getOrThrow("string") + + fun asJsonValues(): List = jsonValues.getOrThrow("jsonValues") + + fun asJson(): JsonValue = json.getOrThrow("json") + + fun asNumber(): Double = number.getOrThrow("number") + + fun asBool(): Boolean = bool.getOrThrow("bool") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + string != null -> visitor.visitString(string) + jsonValues != null -> visitor.visitJsonValues(jsonValues) + json != null -> visitor.visitJson(json) + number != null -> visitor.visitNumber(number) + bool != null -> visitor.visitBool(bool) + else -> visitor.unknown(_json) + } - @JsonCreator - private constructor( - @JsonProperty("id") @ExcludeMissing id: JsonField = JsonMissing.of() - ) : this(id, mutableMapOf()) + private var validated: Boolean = false - /** - * A stable Finch `id` (UUID v4) for an individual in the company. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun id(): String = id.getRequired("id") + fun validate(): Value = apply { + if (validated) { + return@apply + } - /** - * Returns the raw JSON value of [id]. - * - * Unlike [id], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id + accept( + object : Visitor { + override fun visitString(string: String) {} - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + override fun visitJsonValues(jsonValues: List) {} - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + override fun visitJson(json: JsonValue) {} - fun toBuilder() = Builder().from(this) + override fun visitNumber(number: Double) {} - companion object { + override fun visitBool(bool: Boolean) {} + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Returns a mutable builder for constructing an instance of [Manager]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * The following fields are required: - * ```java - * .id() - * ``` + * Used for best match union deserialization. */ - @JvmStatic fun builder() = Builder() - } + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitString(string: String) = 1 - /** A builder for [Manager]. */ - class Builder internal constructor() { + override fun visitJsonValues(jsonValues: List) = + jsonValues.size - private var id: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() + override fun visitJson(json: JsonValue) = 1 - @JvmSynthetic - internal fun from(manager: Manager) = apply { - id = manager.id - additionalProperties = manager.additionalProperties.toMutableMap() - } + override fun visitNumber(number: Double) = 1 - /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: String) = id(JsonField.of(id)) + override fun visitBool(bool: Boolean) = 1 - /** - * Sets [Builder.id] to an arbitrary JSON value. - * - * You should usually call [Builder.id] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun id(id: JsonField) = apply { this.id = id } + override fun unknown(json: JsonValue?) = 0 + } + ) - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) + return /* spotless:off */ other is Value && string == other.string && jsonValues == other.jsonValues && json == other.json && number == other.number && bool == other.bool /* spotless:on */ } - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + override fun hashCode(): Int = /* spotless:off */ Objects.hash(string, jsonValues, json, number, bool) /* spotless:on */ + + override fun toString(): String = + when { + string != null -> "Value{string=$string}" + jsonValues != null -> "Value{jsonValues=$jsonValues}" + json != null -> "Value{json=$json}" + number != null -> "Value{number=$number}" + bool != null -> "Value{bool=$bool}" + _json != null -> "Value{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Value") } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + companion object { - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + @JvmStatic fun ofString(string: String) = Value(string = string) + + @JvmStatic + fun ofJsonValues(jsonValues: List) = Value(jsonValues = jsonValues) + + @JvmStatic fun ofJson(json: JsonValue) = Value(json = json) + + @JvmStatic fun ofNumber(number: Double) = Value(number = number) + + @JvmStatic fun ofBool(bool: Boolean) = Value(bool = bool) } /** - * Returns an immutable instance of [Manager]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .id() - * ``` - * - * @throws IllegalStateException if any required field is unset. + * An interface that defines how to map each variant of [Value] to a value of type + * [T]. */ - fun build(): Manager = - Manager(checkRequired("id", id), additionalProperties.toMutableMap()) - } + interface Visitor { - private var validated: Boolean = false + fun visitString(string: String): T - fun validate(): Manager = apply { - if (validated) { - return@apply + fun visitJsonValues(jsonValues: List): T + + fun visitJson(json: JsonValue): T + + fun visitNumber(number: Double): T + + fun visitBool(bool: Boolean): T + + /** + * Maps an unknown variant of [Value] to a value of type [T]. + * + * An instance of [Value] can contain an unknown variant if it was deserialized + * from data that doesn't match any known variant. For example, if the SDK is on + * an older version than the API, then the API may respond with new variants + * that the SDK is unaware of. + * + * @throws FinchInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw FinchInvalidDataException("Unknown Value: $json") + } } - id() - validated = true - } + internal class Deserializer : BaseDeserializer(Value::class) { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + override fun ObjectCodec.deserialize(node: JsonNode): Value { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Value(string = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef>())?.let { + Value(jsonValues = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(number = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(bool = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Value(json = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely + // incompatible with all the possible variants. + 0 -> Value(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use + // the first completely valid match, or simply the first match if none + // are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } } - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = (if (id.asKnown().isPresent) 1 else 0) + internal class Serializer : BaseSerializer(Value::class) { + + override fun serialize( + value: Value, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.string != null -> generator.writeObject(value.string) + value.jsonValues != null -> generator.writeObject(value.jsonValues) + value.json != null -> generator.writeObject(value.json) + value.number != null -> generator.writeObject(value.number) + value.bool != null -> generator.writeObject(value.bool) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Value") + } + } + } + } override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Manager && id == other.id && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CustomField && name == other.name && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(name, value, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode - override fun toString() = "Manager{id=$id, additionalProperties=$additionalProperties}" + override fun toString() = + "CustomField{name=$name, value=$value, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { @@ -2639,17 +2635,17 @@ private constructor( return true } - return /* spotless:off */ other is UnionMember0 && id == other.id && classCode == other.classCode && customFields == other.customFields && department == other.department && employment == other.employment && employmentStatus == other.employmentStatus && endDate == other.endDate && firstName == other.firstName && isActive == other.isActive && lastName == other.lastName && latestRehireDate == other.latestRehireDate && location == other.location && manager == other.manager && middleName == other.middleName && startDate == other.startDate && title == other.title && workId == other.workId && income == other.income && incomeHistory == other.incomeHistory && sourceId == other.sourceId && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is UnionMember0 && id == other.id && classCode == other.classCode && department == other.department && employment == other.employment && employmentStatus == other.employmentStatus && endDate == other.endDate && firstName == other.firstName && isActive == other.isActive && lastName == other.lastName && latestRehireDate == other.latestRehireDate && location == other.location && manager == other.manager && middleName == other.middleName && startDate == other.startDate && title == other.title && customFields == other.customFields && income == other.income && incomeHistory == other.incomeHistory && sourceId == other.sourceId && workId == other.workId && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(id, classCode, customFields, department, employment, employmentStatus, endDate, firstName, isActive, lastName, latestRehireDate, location, manager, middleName, startDate, title, workId, income, incomeHistory, sourceId, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(id, classCode, department, employment, employmentStatus, endDate, firstName, isActive, lastName, latestRehireDate, location, manager, middleName, startDate, title, customFields, income, incomeHistory, sourceId, workId, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "UnionMember0{id=$id, classCode=$classCode, customFields=$customFields, department=$department, employment=$employment, employmentStatus=$employmentStatus, endDate=$endDate, firstName=$firstName, isActive=$isActive, lastName=$lastName, latestRehireDate=$latestRehireDate, location=$location, manager=$manager, middleName=$middleName, startDate=$startDate, title=$title, workId=$workId, income=$income, incomeHistory=$incomeHistory, sourceId=$sourceId, additionalProperties=$additionalProperties}" + "UnionMember0{id=$id, classCode=$classCode, department=$department, employment=$employment, employmentStatus=$employmentStatus, endDate=$endDate, firstName=$firstName, isActive=$isActive, lastName=$lastName, latestRehireDate=$latestRehireDate, location=$location, manager=$manager, middleName=$middleName, startDate=$startDate, title=$title, customFields=$customFields, income=$income, incomeHistory=$incomeHistory, sourceId=$sourceId, workId=$workId, additionalProperties=$additionalProperties}" } class BatchError diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Money.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Money.kt index c9badec1..137e061e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Money.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Money.kt @@ -10,6 +10,7 @@ import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -38,10 +39,10 @@ private constructor( fun amount(): Optional = amount.getOptional("amount") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun currency(): Optional = currency.getOptional("currency") + fun currency(): String = currency.getRequired("currency") /** * Returns the raw JSON value of [amount]. @@ -71,15 +72,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Money]. */ + /** + * Returns a mutable builder for constructing an instance of [Money]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Money]. */ class Builder internal constructor() { - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -143,8 +152,21 @@ private constructor( * Returns an immutable instance of [Money]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ - fun build(): Money = Money(amount, currency, additionalProperties.toMutableMap()) + fun build(): Money = + Money( + checkRequired("amount", amount), + checkRequired("currency", currency), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupListResponse.kt index 608a9101..a5826485 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupListResponse.kt @@ -12,11 +12,11 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects -import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayGroupListResponse @@ -39,27 +39,26 @@ private constructor( /** * Finch id (uuidv4) for the pay group * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun id(): Optional = id.getOptional("id") + fun id(): String = id.getRequired("id") /** * Name of the pay group * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun name(): Optional = name.getOptional("name") + fun name(): String = name.getRequired("name") /** * List of pay frequencies associated with this pay group * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun payFrequencies(): Optional> = - payFrequencies.getOptional("pay_frequencies") + fun payFrequencies(): List = payFrequencies.getRequired("pay_frequencies") /** * Returns the raw JSON value of [id]. @@ -98,15 +97,24 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayGroupListResponse]. */ + /** + * Returns a mutable builder for constructing an instance of [PayGroupListResponse]. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .payFrequencies() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [PayGroupListResponse]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var payFrequencies: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -190,12 +198,21 @@ private constructor( * Returns an immutable instance of [PayGroupListResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .name() + * .payFrequencies() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayGroupListResponse = PayGroupListResponse( - id, - name, - (payFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, + checkRequired("id", id), + checkRequired("name", name), + checkRequired("payFrequencies", payFrequencies).map { it.toImmutable() }, additionalProperties.toMutableMap(), ) } @@ -209,7 +226,7 @@ private constructor( id() name() - payFrequencies().ifPresent { it.forEach { it.validate() } } + payFrequencies().forEach { it.validate() } validated = true } @@ -249,21 +266,21 @@ private constructor( @JvmField val ANNUALLY = of("annually") - @JvmField val SEMI_ANNUALLY = of("semi_annually") + @JvmField val BI_WEEKLY = of("bi_weekly") - @JvmField val QUARTERLY = of("quarterly") + @JvmField val DAILY = of("daily") @JvmField val MONTHLY = of("monthly") - @JvmField val SEMI_MONTHLY = of("semi_monthly") + @JvmField val OTHER = of("other") - @JvmField val BI_WEEKLY = of("bi_weekly") + @JvmField val QUARTERLY = of("quarterly") - @JvmField val WEEKLY = of("weekly") + @JvmField val SEMI_ANNUALLY = of("semi_annually") - @JvmField val DAILY = of("daily") + @JvmField val SEMI_MONTHLY = of("semi_monthly") - @JvmField val OTHER = of("other") + @JvmField val WEEKLY = of("weekly") @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } @@ -271,14 +288,14 @@ private constructor( /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, } /** @@ -292,14 +309,14 @@ private constructor( */ enum class Value { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, /** * An enum member indicating that [PayFrequency] was instantiated with an unknown value. */ @@ -316,14 +333,14 @@ private constructor( fun value(): Value = when (this) { ANNUALLY -> Value.ANNUALLY - SEMI_ANNUALLY -> Value.SEMI_ANNUALLY - QUARTERLY -> Value.QUARTERLY - MONTHLY -> Value.MONTHLY - SEMI_MONTHLY -> Value.SEMI_MONTHLY BI_WEEKLY -> Value.BI_WEEKLY - WEEKLY -> Value.WEEKLY DAILY -> Value.DAILY + MONTHLY -> Value.MONTHLY OTHER -> Value.OTHER + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUALLY -> Value.SEMI_ANNUALLY + SEMI_MONTHLY -> Value.SEMI_MONTHLY + WEEKLY -> Value.WEEKLY else -> Value._UNKNOWN } @@ -338,14 +355,14 @@ private constructor( fun known(): Known = when (this) { ANNUALLY -> Known.ANNUALLY - SEMI_ANNUALLY -> Known.SEMI_ANNUALLY - QUARTERLY -> Known.QUARTERLY - MONTHLY -> Known.MONTHLY - SEMI_MONTHLY -> Known.SEMI_MONTHLY BI_WEEKLY -> Known.BI_WEEKLY - WEEKLY -> Known.WEEKLY DAILY -> Known.DAILY + MONTHLY -> Known.MONTHLY OTHER -> Known.OTHER + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUALLY -> Known.SEMI_ANNUALLY + SEMI_MONTHLY -> Known.SEMI_MONTHLY + WEEKLY -> Known.WEEKLY else -> throw FinchInvalidDataException("Unknown PayFrequency: $value") } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponse.kt index e6e2c27b..8e93a1cc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayGroupRetrieveResponse.kt @@ -317,21 +317,21 @@ private constructor( @JvmField val ANNUALLY = of("annually") - @JvmField val SEMI_ANNUALLY = of("semi_annually") + @JvmField val BI_WEEKLY = of("bi_weekly") - @JvmField val QUARTERLY = of("quarterly") + @JvmField val DAILY = of("daily") @JvmField val MONTHLY = of("monthly") - @JvmField val SEMI_MONTHLY = of("semi_monthly") + @JvmField val OTHER = of("other") - @JvmField val BI_WEEKLY = of("bi_weekly") + @JvmField val QUARTERLY = of("quarterly") - @JvmField val WEEKLY = of("weekly") + @JvmField val SEMI_ANNUALLY = of("semi_annually") - @JvmField val DAILY = of("daily") + @JvmField val SEMI_MONTHLY = of("semi_monthly") - @JvmField val OTHER = of("other") + @JvmField val WEEKLY = of("weekly") @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } @@ -339,14 +339,14 @@ private constructor( /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, } /** @@ -360,14 +360,14 @@ private constructor( */ enum class Value { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, /** * An enum member indicating that [PayFrequency] was instantiated with an unknown value. */ @@ -384,14 +384,14 @@ private constructor( fun value(): Value = when (this) { ANNUALLY -> Value.ANNUALLY - SEMI_ANNUALLY -> Value.SEMI_ANNUALLY - QUARTERLY -> Value.QUARTERLY - MONTHLY -> Value.MONTHLY - SEMI_MONTHLY -> Value.SEMI_MONTHLY BI_WEEKLY -> Value.BI_WEEKLY - WEEKLY -> Value.WEEKLY DAILY -> Value.DAILY + MONTHLY -> Value.MONTHLY OTHER -> Value.OTHER + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUALLY -> Value.SEMI_ANNUALLY + SEMI_MONTHLY -> Value.SEMI_MONTHLY + WEEKLY -> Value.WEEKLY else -> Value._UNKNOWN } @@ -406,14 +406,14 @@ private constructor( fun known(): Known = when (this) { ANNUALLY -> Known.ANNUALLY - SEMI_ANNUALLY -> Known.SEMI_ANNUALLY - QUARTERLY -> Known.QUARTERLY - MONTHLY -> Known.MONTHLY - SEMI_MONTHLY -> Known.SEMI_MONTHLY BI_WEEKLY -> Known.BI_WEEKLY - WEEKLY -> Known.WEEKLY DAILY -> Known.DAILY + MONTHLY -> Known.MONTHLY OTHER -> Known.OTHER + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUALLY -> Known.SEMI_ANNUALLY + SEMI_MONTHLY -> Known.SEMI_MONTHLY + WEEKLY -> Known.WEEKLY else -> throw FinchInvalidDataException("Unknown PayFrequency: $value") } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt deleted file mode 100644 index 805ed50b..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt +++ /dev/null @@ -1,4255 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.tryfinch.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.tryfinch.api.core.Enum -import com.tryfinch.api.core.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.core.checkKnown -import com.tryfinch.api.core.toImmutable -import com.tryfinch.api.errors.FinchInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class PayStatement -private constructor( - private val earnings: JsonField>, - private val employeeDeductions: JsonField>, - private val employerContributions: JsonField>, - private val grossPay: JsonField, - private val individualId: JsonField, - private val netPay: JsonField, - private val paymentMethod: JsonField, - private val taxes: JsonField>, - private val totalHours: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("earnings") - @ExcludeMissing - earnings: JsonField> = JsonMissing.of(), - @JsonProperty("employee_deductions") - @ExcludeMissing - employeeDeductions: JsonField> = JsonMissing.of(), - @JsonProperty("employer_contributions") - @ExcludeMissing - employerContributions: JsonField> = JsonMissing.of(), - @JsonProperty("gross_pay") @ExcludeMissing grossPay: JsonField = JsonMissing.of(), - @JsonProperty("individual_id") - @ExcludeMissing - individualId: JsonField = JsonMissing.of(), - @JsonProperty("net_pay") @ExcludeMissing netPay: JsonField = JsonMissing.of(), - @JsonProperty("payment_method") - @ExcludeMissing - paymentMethod: JsonField = JsonMissing.of(), - @JsonProperty("taxes") @ExcludeMissing taxes: JsonField> = JsonMissing.of(), - @JsonProperty("total_hours") - @ExcludeMissing - totalHours: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this( - earnings, - employeeDeductions, - employerContributions, - grossPay, - individualId, - netPay, - paymentMethod, - taxes, - totalHours, - type, - mutableMapOf(), - ) - - /** - * The array of earnings objects associated with this pay statement - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun earnings(): Optional> = earnings.getOptional("earnings") - - /** - * The array of deductions objects associated with this pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employeeDeductions(): Optional> = - employeeDeductions.getOptional("employee_deductions") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employerContributions(): Optional> = - employerContributions.getOptional("employer_contributions") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun grossPay(): Optional = grossPay.getOptional("gross_pay") - - /** - * A stable Finch `id` (UUID v4) for an individual in the company - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun individualId(): Optional = individualId.getOptional("individual_id") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun netPay(): Optional = netPay.getOptional("net_pay") - - /** - * The payment method. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun paymentMethod(): Optional = paymentMethod.getOptional("payment_method") - - /** - * The array of taxes objects associated with this pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun taxes(): Optional> = taxes.getOptional("taxes") - - /** - * The number of hours worked for this pay period - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun totalHours(): Optional = totalHours.getOptional("total_hours") - - /** - * The type of the payment associated with the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [earnings]. - * - * Unlike [earnings], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("earnings") @ExcludeMissing fun _earnings(): JsonField> = earnings - - /** - * Returns the raw JSON value of [employeeDeductions]. - * - * Unlike [employeeDeductions], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employee_deductions") - @ExcludeMissing - fun _employeeDeductions(): JsonField> = employeeDeductions - - /** - * Returns the raw JSON value of [employerContributions]. - * - * Unlike [employerContributions], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employer_contributions") - @ExcludeMissing - fun _employerContributions(): JsonField> = employerContributions - - /** - * Returns the raw JSON value of [grossPay]. - * - * Unlike [grossPay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay - - /** - * Returns the raw JSON value of [individualId]. - * - * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("individual_id") - @ExcludeMissing - fun _individualId(): JsonField = individualId - - /** - * Returns the raw JSON value of [netPay]. - * - * Unlike [netPay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay - - /** - * Returns the raw JSON value of [paymentMethod]. - * - * Unlike [paymentMethod], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("payment_method") - @ExcludeMissing - fun _paymentMethod(): JsonField = paymentMethod - - /** - * Returns the raw JSON value of [taxes]. - * - * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes - - /** - * Returns the raw JSON value of [totalHours]. - * - * Unlike [totalHours], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_hours") @ExcludeMissing fun _totalHours(): JsonField = totalHours - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [PayStatement]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PayStatement]. */ - class Builder internal constructor() { - - private var earnings: JsonField>? = null - private var employeeDeductions: JsonField>? = null - private var employerContributions: JsonField>? = null - private var grossPay: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var netPay: JsonField = JsonMissing.of() - private var paymentMethod: JsonField = JsonMissing.of() - private var taxes: JsonField>? = null - private var totalHours: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(payStatement: PayStatement) = apply { - earnings = payStatement.earnings.map { it.toMutableList() } - employeeDeductions = payStatement.employeeDeductions.map { it.toMutableList() } - employerContributions = payStatement.employerContributions.map { it.toMutableList() } - grossPay = payStatement.grossPay - individualId = payStatement.individualId - netPay = payStatement.netPay - paymentMethod = payStatement.paymentMethod - taxes = payStatement.taxes.map { it.toMutableList() } - totalHours = payStatement.totalHours - type = payStatement.type - additionalProperties = payStatement.additionalProperties.toMutableMap() - } - - /** The array of earnings objects associated with this pay statement */ - fun earnings(earnings: List?) = earnings(JsonField.ofNullable(earnings)) - - /** Alias for calling [Builder.earnings] with `earnings.orElse(null)`. */ - fun earnings(earnings: Optional>) = earnings(earnings.getOrNull()) - - /** - * Sets [Builder.earnings] to an arbitrary JSON value. - * - * You should usually call [Builder.earnings] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun earnings(earnings: JsonField>) = apply { - this.earnings = earnings.map { it.toMutableList() } - } - - /** - * Adds a single [Earning] to [earnings]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEarning(earning: Earning) = apply { - earnings = - (earnings ?: JsonField.of(mutableListOf())).also { - checkKnown("earnings", it).add(earning) - } - } - - /** The array of deductions objects associated with this pay statement. */ - fun employeeDeductions(employeeDeductions: List?) = - employeeDeductions(JsonField.ofNullable(employeeDeductions)) - - /** - * Alias for calling [Builder.employeeDeductions] with `employeeDeductions.orElse(null)`. - */ - fun employeeDeductions(employeeDeductions: Optional>) = - employeeDeductions(employeeDeductions.getOrNull()) - - /** - * Sets [Builder.employeeDeductions] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeDeductions] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun employeeDeductions(employeeDeductions: JsonField>) = apply { - this.employeeDeductions = employeeDeductions.map { it.toMutableList() } - } - - /** - * Adds a single [EmployeeDeduction] to [employeeDeductions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { - employeeDeductions = - (employeeDeductions ?: JsonField.of(mutableListOf())).also { - checkKnown("employeeDeductions", it).add(employeeDeduction) - } - } - - fun employerContributions(employerContributions: List?) = - employerContributions(JsonField.ofNullable(employerContributions)) - - /** - * Alias for calling [Builder.employerContributions] with - * `employerContributions.orElse(null)`. - */ - fun employerContributions(employerContributions: Optional>) = - employerContributions(employerContributions.getOrNull()) - - /** - * Sets [Builder.employerContributions] to an arbitrary JSON value. - * - * You should usually call [Builder.employerContributions] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun employerContributions(employerContributions: JsonField>) = - apply { - this.employerContributions = employerContributions.map { it.toMutableList() } - } - - /** - * Adds a single [EmployerContribution] to [employerContributions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployerContribution(employerContribution: EmployerContribution) = apply { - employerContributions = - (employerContributions ?: JsonField.of(mutableListOf())).also { - checkKnown("employerContributions", it).add(employerContribution) - } - } - - fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) - - /** Alias for calling [Builder.grossPay] with `grossPay.orElse(null)`. */ - fun grossPay(grossPay: Optional) = grossPay(grossPay.getOrNull()) - - /** - * Sets [Builder.grossPay] to an arbitrary JSON value. - * - * You should usually call [Builder.grossPay] with a well-typed [Money] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } - - /** A stable Finch `id` (UUID v4) for an individual in the company */ - fun individualId(individualId: String) = individualId(JsonField.of(individualId)) - - /** - * Sets [Builder.individualId] to an arbitrary JSON value. - * - * You should usually call [Builder.individualId] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun individualId(individualId: JsonField) = apply { - this.individualId = individualId - } - - fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) - - /** Alias for calling [Builder.netPay] with `netPay.orElse(null)`. */ - fun netPay(netPay: Optional) = netPay(netPay.getOrNull()) - - /** - * Sets [Builder.netPay] to an arbitrary JSON value. - * - * You should usually call [Builder.netPay] with a well-typed [Money] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun netPay(netPay: JsonField) = apply { this.netPay = netPay } - - /** The payment method. */ - fun paymentMethod(paymentMethod: PaymentMethod?) = - paymentMethod(JsonField.ofNullable(paymentMethod)) - - /** Alias for calling [Builder.paymentMethod] with `paymentMethod.orElse(null)`. */ - fun paymentMethod(paymentMethod: Optional) = - paymentMethod(paymentMethod.getOrNull()) - - /** - * Sets [Builder.paymentMethod] to an arbitrary JSON value. - * - * You should usually call [Builder.paymentMethod] with a well-typed [PaymentMethod] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun paymentMethod(paymentMethod: JsonField) = apply { - this.paymentMethod = paymentMethod - } - - /** The array of taxes objects associated with this pay statement. */ - fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) - - /** Alias for calling [Builder.taxes] with `taxes.orElse(null)`. */ - fun taxes(taxes: Optional>) = taxes(taxes.getOrNull()) - - /** - * Sets [Builder.taxes] to an arbitrary JSON value. - * - * You should usually call [Builder.taxes] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun taxes(taxes: JsonField>) = apply { - this.taxes = taxes.map { it.toMutableList() } - } - - /** - * Adds a single [Tax] to [taxes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTax(tax: Tax) = apply { - taxes = - (taxes ?: JsonField.of(mutableListOf())).also { checkKnown("taxes", it).add(tax) } - } - - /** The number of hours worked for this pay period */ - fun totalHours(totalHours: Double?) = totalHours(JsonField.ofNullable(totalHours)) - - /** - * Alias for [Builder.totalHours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun totalHours(totalHours: Double) = totalHours(totalHours as Double?) - - /** Alias for calling [Builder.totalHours] with `totalHours.orElse(null)`. */ - fun totalHours(totalHours: Optional) = totalHours(totalHours.getOrNull()) - - /** - * Sets [Builder.totalHours] to an arbitrary JSON value. - * - * You should usually call [Builder.totalHours] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun totalHours(totalHours: JsonField) = apply { this.totalHours = totalHours } - - /** The type of the payment associated with the pay statement. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PayStatement]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): PayStatement = - PayStatement( - (earnings ?: JsonMissing.of()).map { it.toImmutable() }, - (employeeDeductions ?: JsonMissing.of()).map { it.toImmutable() }, - (employerContributions ?: JsonMissing.of()).map { it.toImmutable() }, - grossPay, - individualId, - netPay, - paymentMethod, - (taxes ?: JsonMissing.of()).map { it.toImmutable() }, - totalHours, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PayStatement = apply { - if (validated) { - return@apply - } - - earnings().ifPresent { it.forEach { it?.validate() } } - employeeDeductions().ifPresent { it.forEach { it?.validate() } } - employerContributions().ifPresent { it.forEach { it?.validate() } } - grossPay().ifPresent { it.validate() } - individualId() - netPay().ifPresent { it.validate() } - paymentMethod().ifPresent { it.validate() } - taxes().ifPresent { it.forEach { it?.validate() } } - totalHours() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (earnings.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (employeeDeductions.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (employerContributions.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (grossPay.asKnown().getOrNull()?.validity() ?: 0) + - (if (individualId.asKnown().isPresent) 1 else 0) + - (netPay.asKnown().getOrNull()?.validity() ?: 0) + - (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + - (taxes.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (if (totalHours.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Earning - private constructor( - private val amount: JsonField, - private val attributes: JsonField, - private val currency: JsonField, - private val hours: JsonField, - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("hours") @ExcludeMissing hours: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, hours, name, type, mutableMapOf()) - - /** - * The earnings amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * The earnings currency code. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The number of hours associated with this earning. (For salaried employees, this could be - * hours per pay period, `0` or `null`, depending on the provider). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hours(): Optional = hours.getOptional("hours") - - /** - * The exact name of the deduction from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The type of earning. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [hours]. - * - * Unlike [hours], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField = hours - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Earning]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Earning]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var hours: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(earning: Earning) = apply { - amount = earning.amount - attributes = earning.attributes - currency = earning.currency - hours = earning.hours - name = earning.name - type = earning.type - additionalProperties = earning.additionalProperties.toMutableMap() - } - - /** The earnings amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - /** The earnings currency code. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * The number of hours associated with this earning. (For salaried employees, this could - * be hours per pay period, `0` or `null`, depending on the provider). - */ - fun hours(hours: Double?) = hours(JsonField.ofNullable(hours)) - - /** - * Alias for [Builder.hours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hours(hours: Double) = hours(hours as Double?) - - /** Alias for calling [Builder.hours] with `hours.orElse(null)`. */ - fun hours(hours: Optional) = hours(hours.getOrNull()) - - /** - * Sets [Builder.hours] to an arbitrary JSON value. - * - * You should usually call [Builder.hours] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun hours(hours: JsonField) = apply { this.hours = hours } - - /** The exact name of the deduction from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The type of earning. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Earning]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Earning = - Earning( - amount, - attributes, - currency, - hours, - name, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Earning = apply { - if (validated) { - return@apply - } - - amount() - attributes().ifPresent { it.validate() } - currency() - hours() - name() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (hours.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Attributes = Attributes(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - /** The type of earning. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val SALARY = of("salary") - - @JvmField val WAGE = of("wage") - - @JvmField val REIMBURSEMENT = of("reimbursement") - - @JvmField val OVERTIME = of("overtime") - - @JvmField val SEVERANCE = of("severance") - - @JvmField val DOUBLE_OVERTIME = of("double_overtime") - - @JvmField val PTO = of("pto") - - @JvmField val SICK = of("sick") - - @JvmField val BONUS = of("bonus") - - @JvmField val COMMISSION = of("commission") - - @JvmField val TIPS = of("tips") - - @JvmField val _1099 = of("1099") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - OTHER, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - OTHER, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SALARY -> Value.SALARY - WAGE -> Value.WAGE - REIMBURSEMENT -> Value.REIMBURSEMENT - OVERTIME -> Value.OVERTIME - SEVERANCE -> Value.SEVERANCE - DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME - PTO -> Value.PTO - SICK -> Value.SICK - BONUS -> Value.BONUS - COMMISSION -> Value.COMMISSION - TIPS -> Value.TIPS - _1099 -> Value._1099 - OTHER -> Value.OTHER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SALARY -> Known.SALARY - WAGE -> Known.WAGE - REIMBURSEMENT -> Known.REIMBURSEMENT - OVERTIME -> Known.OVERTIME - SEVERANCE -> Known.SEVERANCE - DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME - PTO -> Known.PTO - SICK -> Known.SICK - BONUS -> Known.BONUS - COMMISSION -> Known.COMMISSION - TIPS -> Known.TIPS - _1099 -> Known._1099 - OTHER -> Known.OTHER - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Earning && amount == other.amount && attributes == other.attributes && currency == other.currency && hours == other.hours && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, hours, name, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Earning{amount=$amount, attributes=$attributes, currency=$currency, hours=$hours, name=$name, type=$type, additionalProperties=$additionalProperties}" - } - - class EmployeeDeduction - private constructor( - private val amount: JsonField, - private val attributes: JsonField, - private val currency: JsonField, - private val name: JsonField, - private val preTax: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("pre_tax") @ExcludeMissing preTax: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, name, preTax, type, mutableMapOf()) - - /** - * The deduction amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * The deduction currency. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The deduction name from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Boolean indicating if the deduction is pre-tax. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun preTax(): Optional = preTax.getOptional("pre_tax") - - /** - * Type of benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [preTax]. - * - * Unlike [preTax], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pre_tax") @ExcludeMissing fun _preTax(): JsonField = preTax - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [EmployeeDeduction]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmployeeDeduction]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var preTax: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employeeDeduction: EmployeeDeduction) = apply { - amount = employeeDeduction.amount - attributes = employeeDeduction.attributes - currency = employeeDeduction.currency - name = employeeDeduction.name - preTax = employeeDeduction.preTax - type = employeeDeduction.type - additionalProperties = employeeDeduction.additionalProperties.toMutableMap() - } - - /** The deduction amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - /** The deduction currency. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The deduction name from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Boolean indicating if the deduction is pre-tax. */ - fun preTax(preTax: Boolean?) = preTax(JsonField.ofNullable(preTax)) - - /** - * Alias for [Builder.preTax]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preTax(preTax: Boolean) = preTax(preTax as Boolean?) - - /** Alias for calling [Builder.preTax] with `preTax.orElse(null)`. */ - fun preTax(preTax: Optional) = preTax(preTax.getOrNull()) - - /** - * Sets [Builder.preTax] to an arbitrary JSON value. - * - * You should usually call [Builder.preTax] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun preTax(preTax: JsonField) = apply { this.preTax = preTax } - - /** Type of benefit. */ - fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [BenefitType] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - 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 [EmployeeDeduction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EmployeeDeduction = - EmployeeDeduction( - amount, - attributes, - currency, - name, - preTax, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmployeeDeduction = apply { - if (validated) { - return@apply - } - - amount() - attributes().ifPresent { it.validate() } - currency() - name() - preTax() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (preTax.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Attributes = Attributes(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && attributes == other.attributes && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, name, preTax, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmployeeDeduction{amount=$amount, attributes=$attributes, currency=$currency, name=$name, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" - } - - class EmployerContribution - private constructor( - private val amount: JsonField, - private val attributes: JsonField, - private val currency: JsonField, - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, name, type, mutableMapOf()) - - /** - * The contribution amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * The contribution currency. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The contribution name from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Type of benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [EmployerContribution]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmployerContribution]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employerContribution: EmployerContribution) = apply { - amount = employerContribution.amount - attributes = employerContribution.attributes - currency = employerContribution.currency - name = employerContribution.name - type = employerContribution.type - additionalProperties = employerContribution.additionalProperties.toMutableMap() - } - - /** The contribution amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - /** The contribution currency. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The contribution name from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Type of benefit. */ - fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [BenefitType] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - 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 [EmployerContribution]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): EmployerContribution = - EmployerContribution( - amount, - attributes, - currency, - name, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmployerContribution = apply { - if (validated) { - return@apply - } - - amount() - attributes().ifPresent { it.validate() } - currency() - name() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Attributes = Attributes(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployerContribution && amount == other.amount && attributes == other.attributes && currency == other.currency && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, name, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmployerContribution{amount=$amount, attributes=$attributes, currency=$currency, name=$name, type=$type, additionalProperties=$additionalProperties}" - } - - /** The payment method. */ - class PaymentMethod @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CHECK = of("check") - - @JvmField val DIRECT_DEPOSIT = of("direct_deposit") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = PaymentMethod(JsonField.of(value)) - } - - /** An enum containing [PaymentMethod]'s known values. */ - enum class Known { - CHECK, - DIRECT_DEPOSIT, - OTHER, - } - - /** - * An enum containing [PaymentMethod]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PaymentMethod] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CHECK, - DIRECT_DEPOSIT, - OTHER, - /** - * An enum member indicating that [PaymentMethod] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CHECK -> Value.CHECK - DIRECT_DEPOSIT -> Value.DIRECT_DEPOSIT - OTHER -> Value.OTHER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - CHECK -> Known.CHECK - DIRECT_DEPOSIT -> Known.DIRECT_DEPOSIT - OTHER -> Known.OTHER - else -> throw FinchInvalidDataException("Unknown PaymentMethod: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): PaymentMethod = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentMethod && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Tax - private constructor( - private val amount: JsonField, - private val attributes: JsonField, - private val currency: JsonField, - private val employer: JsonField, - private val name: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("employer") - @ExcludeMissing - employer: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, employer, name, type, mutableMapOf()) - - /** - * The tax amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * The currency code. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * `true` if the amount is paid by the employers. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employer(): Optional = employer.getOptional("employer") - - /** - * The exact name of tax from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The type of taxes. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [employer]. - * - * Unlike [employer], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Tax]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tax]. */ - class Builder internal constructor() { - - private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var employer: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tax: Tax) = apply { - amount = tax.amount - attributes = tax.attributes - currency = tax.currency - employer = tax.employer - name = tax.name - type = tax.type - additionalProperties = tax.additionalProperties.toMutableMap() - } - - /** The tax amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - /** The currency code. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** `true` if the amount is paid by the employers. */ - fun employer(employer: Boolean?) = employer(JsonField.ofNullable(employer)) - - /** - * Alias for [Builder.employer]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun employer(employer: Boolean) = employer(employer as Boolean?) - - /** Alias for calling [Builder.employer] with `employer.orElse(null)`. */ - fun employer(employer: Optional) = employer(employer.getOrNull()) - - /** - * Sets [Builder.employer] to an arbitrary JSON value. - * - * You should usually call [Builder.employer] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun employer(employer: JsonField) = apply { this.employer = employer } - - /** The exact name of tax from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The type of taxes. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tax]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Tax = - Tax( - amount, - attributes, - currency, - employer, - name, - type, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tax = apply { - if (validated) { - return@apply - } - - amount() - attributes().ifPresent { it.validate() } - currency() - employer() - name() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (employer.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Attributes = Attributes(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [Metadata]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Metadata = Metadata(metadata, additionalProperties.toMutableMap()) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a key-value - * pairs where the values can be of any type (string, number, boolean, object, - * array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - /** The type of taxes. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val STATE = of("state") - - @JvmField val FEDERAL = of("federal") - - @JvmField val LOCAL = of("local") - - @JvmField val FICA = of("fica") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - STATE, - FEDERAL, - LOCAL, - FICA, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - STATE, - FEDERAL, - LOCAL, - FICA, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - STATE -> Value.STATE - FEDERAL -> Value.FEDERAL - LOCAL -> Value.LOCAL - FICA -> Value.FICA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - STATE -> Known.STATE - FEDERAL -> Known.FEDERAL - LOCAL -> Known.LOCAL - FICA -> Known.FICA - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tax && amount == other.amount && attributes == other.attributes && currency == other.currency && employer == other.employer && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, employer, name, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tax{amount=$amount, attributes=$attributes, currency=$currency, employer=$employer, name=$name, type=$type, additionalProperties=$additionalProperties}" - } - - /** The type of the payment associated with the pay statement. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val REGULAR_PAYROLL = of("regular_payroll") - - @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") - - @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - REGULAR_PAYROLL, - OFF_CYCLE_PAYROLL, - ONE_TIME_PAYMENT, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - REGULAR_PAYROLL, - OFF_CYCLE_PAYROLL, - ONE_TIME_PAYMENT, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - REGULAR_PAYROLL -> Value.REGULAR_PAYROLL - OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL - ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - REGULAR_PAYROLL -> Known.REGULAR_PAYROLL - OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL - ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PayStatement && earnings == other.earnings && employeeDeductions == other.employeeDeductions && employerContributions == other.employerContributions && grossPay == other.grossPay && individualId == other.individualId && netPay == other.netPay && paymentMethod == other.paymentMethod && taxes == other.taxes && totalHours == other.totalHours && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(earnings, employeeDeductions, employerContributions, grossPay, individualId, netPay, paymentMethod, taxes, totalHours, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PayStatement{earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, individualId=$individualId, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" -} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt index 846be3c3..172c2ddf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementItemListResponse.kt @@ -11,6 +11,7 @@ import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -38,26 +39,26 @@ private constructor( /** * The attributes of the pay statement item. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun attributes(): Optional = attributes.getOptional("attributes") + fun attributes(): Attributes = attributes.getRequired("attributes") /** * The category of the pay statement item. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun category(): Optional = category.getOptional("category") + fun category(): Category = category.getRequired("category") /** * The name of the pay statement item. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun name(): Optional = name.getOptional("name") + fun name(): String = name.getRequired("name") /** * Returns the raw JSON value of [attributes]. @@ -98,6 +99,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [PayStatementItemListResponse]. + * + * The following fields are required: + * ```java + * .attributes() + * .category() + * .name() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -105,9 +113,9 @@ private constructor( /** A builder for [PayStatementItemListResponse]. */ class Builder internal constructor() { - private var attributes: JsonField = JsonMissing.of() - private var category: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var attributes: JsonField? = null + private var category: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -176,12 +184,21 @@ private constructor( * Returns an immutable instance of [PayStatementItemListResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attributes() + * .category() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayStatementItemListResponse = PayStatementItemListResponse( - attributes, - category, - name, + checkRequired("attributes", attributes), + checkRequired("category", category), + checkRequired("name", name), additionalProperties.toMutableMap(), ) } @@ -193,8 +210,8 @@ private constructor( return@apply } - attributes().ifPresent { it.validate() } - category().ifPresent { it.validate() } + attributes().validate() + category().validate() name() validated = true } @@ -221,8 +238,8 @@ private constructor( /** The attributes of the pay statement item. */ class Attributes private constructor( - private val employer: JsonField, private val metadata: JsonField, + private val employer: JsonField, private val preTax: JsonField, private val type: JsonField, private val additionalProperties: MutableMap, @@ -230,32 +247,32 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("employer") - @ExcludeMissing - employer: JsonField = JsonMissing.of(), @JsonProperty("metadata") @ExcludeMissing metadata: JsonField = JsonMissing.of(), + @JsonProperty("employer") + @ExcludeMissing + employer: JsonField = JsonMissing.of(), @JsonProperty("pre_tax") @ExcludeMissing preTax: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(employer, metadata, preTax, type, mutableMapOf()) + ) : this(metadata, employer, preTax, type, mutableMapOf()) /** - * `true` if the amount is paid by the employers. This field is only available for taxes. + * The metadata of the pay statement item derived by the rules engine if available. Each + * attribute will be a key-value pair defined by a rule. * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun employer(): Optional = employer.getOptional("employer") + fun metadata(): Optional = metadata.getOptional("metadata") /** - * The metadata of the pay statement item derived by the rules engine if available. Each - * attribute will be a key-value pair defined by a rule. + * `true` if the amount is paid by the employers. This field is only available for taxes. * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun employer(): Optional = employer.getOptional("employer") /** * `true` if the pay statement item is pre-tax. This field is only available for employee @@ -275,18 +292,18 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [employer]. + * Returns the raw JSON value of [metadata]. * - * Unlike [employer], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** - * Returns the raw JSON value of [metadata]. + * Returns the raw JSON value of [employer]. * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [employer], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer /** * Returns the raw JSON value of [preTax]. @@ -316,28 +333,53 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Attributes]. */ class Builder internal constructor() { + private var metadata: JsonField? = null private var employer: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() private var preTax: JsonField = JsonMissing.of() private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(attributes: Attributes) = apply { - employer = attributes.employer metadata = attributes.metadata + employer = attributes.employer preTax = attributes.preTax type = attributes.type additionalProperties = attributes.additionalProperties.toMutableMap() } + /** + * The metadata of the pay statement item derived by the rules engine if available. Each + * attribute will be a key-value pair defined by a rule. + */ + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) + + /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ + fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * `true` if the amount is paid by the employers. This field is only available for * taxes. @@ -363,24 +405,6 @@ private constructor( */ fun employer(employer: JsonField) = apply { this.employer = employer } - /** - * The metadata of the pay statement item derived by the rules engine if available. Each - * attribute will be a key-value pair defined by a rule. - */ - fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) - - /** Alias for calling [Builder.metadata] with `metadata.orElse(null)`. */ - fun metadata(metadata: Optional) = metadata(metadata.getOrNull()) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - /** * `true` if the pay statement item is pre-tax. This field is only available for * employee deductions. @@ -444,9 +468,22 @@ private constructor( * Returns an immutable instance of [Attributes]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Attributes = - Attributes(employer, metadata, preTax, type, additionalProperties.toMutableMap()) + Attributes( + checkRequired("metadata", metadata), + employer, + preTax, + type, + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -456,8 +493,8 @@ private constructor( return@apply } - employer() metadata().ifPresent { it.validate() } + employer() preTax() type() validated = true @@ -479,8 +516,8 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (employer.asKnown().isPresent) 1 else 0) + - (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + (if (employer.asKnown().isPresent) 1 else 0) + (if (preTax.asKnown().isPresent) 1 else 0) + (if (type.asKnown().isPresent) 1 else 0) @@ -597,17 +634,17 @@ private constructor( return true } - return /* spotless:off */ other is Attributes && employer == other.employer && metadata == other.metadata && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Attributes && metadata == other.metadata && employer == other.employer && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(employer, metadata, preTax, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(metadata, employer, preTax, type, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Attributes{employer=$employer, metadata=$metadata, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" + "Attributes{metadata=$metadata, employer=$employer, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" } /** The category of the pay statement item. */ diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt index 3f5cf6c6..58b6413f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt @@ -10,10 +10,10 @@ import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects -import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayStatementResponse @@ -34,22 +34,22 @@ private constructor( ) : this(body, code, paymentId, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun body(): Optional = body.getOptional("body") + fun body(): PayStatementResponseBody = body.getRequired("body") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun code(): Optional = code.getOptional("code") + fun code(): Long = code.getRequired("code") /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun paymentId(): Optional = paymentId.getOptional("payment_id") + fun paymentId(): String = paymentId.getRequired("payment_id") /** * Returns the raw JSON value of [body]. @@ -86,16 +86,25 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayStatementResponse]. */ + /** + * Returns a mutable builder for constructing an instance of [PayStatementResponse]. + * + * The following fields are required: + * ```java + * .body() + * .code() + * .paymentId() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [PayStatementResponse]. */ class Builder internal constructor() { - private var body: JsonField = JsonMissing.of() - private var code: JsonField = JsonMissing.of() - private var paymentId: JsonField = JsonMissing.of() + private var body: JsonField? = null + private var code: JsonField? = null + private var paymentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -117,6 +126,22 @@ private constructor( */ fun body(body: JsonField) = apply { this.body = body } + /** + * Alias for calling [body] with `PayStatementResponseBody.ofUnionMember0(unionMember0)`. + */ + fun body(unionMember0: PayStatementResponseBody.UnionMember0) = + body(PayStatementResponseBody.ofUnionMember0(unionMember0)) + + /** Alias for calling [body] with `PayStatementResponseBody.ofBatchError(batchError)`. */ + fun body(batchError: PayStatementResponseBody.BatchError) = + body(PayStatementResponseBody.ofBatchError(batchError)) + + /** + * Alias for calling [body] with `PayStatementResponseBody.ofUnionMember2(unionMember2)`. + */ + fun body(unionMember2: PayStatementResponseBody.UnionMember2) = + body(PayStatementResponseBody.ofUnionMember2(unionMember2)) + fun code(code: Long) = code(JsonField.of(code)) /** @@ -161,9 +186,23 @@ private constructor( * Returns an immutable instance of [PayStatementResponse]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .body() + * .code() + * .paymentId() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayStatementResponse = - PayStatementResponse(body, code, paymentId, additionalProperties.toMutableMap()) + PayStatementResponse( + checkRequired("body", body), + checkRequired("code", code), + checkRequired("paymentId", paymentId), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -173,7 +212,7 @@ private constructor( return@apply } - body().ifPresent { it.validate() } + body().validate() code() paymentId() validated = true diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt index 66722b9f..8d6d15f8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt @@ -6,11 +6,24 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.BaseDeserializer +import com.tryfinch.api.core.BaseSerializer +import com.tryfinch.api.core.Enum import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.allMaxBy import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.getOrThrow import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -18,196 +31,6309 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +@JsonDeserialize(using = PayStatementResponseBody.Deserializer::class) +@JsonSerialize(using = PayStatementResponseBody.Serializer::class) class PayStatementResponseBody private constructor( - private val paging: JsonField, - private val payStatements: JsonField>, - private val additionalProperties: MutableMap, + private val unionMember0: UnionMember0? = null, + private val batchError: BatchError? = null, + private val unionMember2: UnionMember2? = null, + private val _json: JsonValue? = null, ) { - @JsonCreator + fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + + fun batchError(): Optional = Optional.ofNullable(batchError) + + fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + + fun isUnionMember0(): Boolean = unionMember0 != null + + fun isBatchError(): Boolean = batchError != null + + fun isUnionMember2(): Boolean = unionMember2 != null + + fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + + fun asBatchError(): BatchError = batchError.getOrThrow("batchError") + + fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + unionMember0 != null -> visitor.visitUnionMember0(unionMember0) + batchError != null -> visitor.visitBatchError(batchError) + unionMember2 != null -> visitor.visitUnionMember2(unionMember2) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): PayStatementResponseBody = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) { + unionMember0.validate() + } + + override fun visitBatchError(batchError: BatchError) { + batchError.validate() + } + + override fun visitUnionMember2(unionMember2: UnionMember2) { + unionMember2.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() + + override fun visitBatchError(batchError: BatchError) = batchError.validity() + + override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PayStatementResponseBody && unionMember0 == other.unionMember0 && batchError == other.batchError && unionMember2 == other.unionMember2 /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, batchError, unionMember2) /* spotless:on */ + + override fun toString(): String = + when { + unionMember0 != null -> "PayStatementResponseBody{unionMember0=$unionMember0}" + batchError != null -> "PayStatementResponseBody{batchError=$batchError}" + unionMember2 != null -> "PayStatementResponseBody{unionMember2=$unionMember2}" + _json != null -> "PayStatementResponseBody{_unknown=$_json}" + else -> throw IllegalStateException("Invalid PayStatementResponseBody") + } + + companion object { + + @JvmStatic + fun ofUnionMember0(unionMember0: UnionMember0) = + PayStatementResponseBody(unionMember0 = unionMember0) + + @JvmStatic + fun ofBatchError(batchError: BatchError) = PayStatementResponseBody(batchError = batchError) + + @JvmStatic + fun ofUnionMember2(unionMember2: UnionMember2) = + PayStatementResponseBody(unionMember2 = unionMember2) + } + + /** + * An interface that defines how to map each variant of [PayStatementResponseBody] to a value of + * type [T]. + */ + interface Visitor { + + fun visitUnionMember0(unionMember0: UnionMember0): T + + fun visitBatchError(batchError: BatchError): T + + fun visitUnionMember2(unionMember2: UnionMember2): T + + /** + * Maps an unknown variant of [PayStatementResponseBody] to a value of type [T]. + * + * An instance of [PayStatementResponseBody] can contain an unknown variant if it was + * deserialized from data that doesn't match any known variant. For example, if the SDK is + * on an older version than the API, then the API may respond with new variants that the SDK + * is unaware of. + * + * @throws FinchInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw FinchInvalidDataException("Unknown PayStatementResponseBody: $json") + } + } + + internal class Deserializer : + BaseDeserializer(PayStatementResponseBody::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): PayStatementResponseBody { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + PayStatementResponseBody(unionMember0 = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + PayStatementResponseBody(batchError = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + PayStatementResponseBody(unionMember2 = it, _json = json) + }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with all + // the possible variants (e.g. deserializing from boolean). + 0 -> PayStatementResponseBody(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : + BaseSerializer(PayStatementResponseBody::class) { + + override fun serialize( + value: PayStatementResponseBody, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.unionMember0 != null -> generator.writeObject(value.unionMember0) + value.batchError != null -> generator.writeObject(value.batchError) + value.unionMember2 != null -> generator.writeObject(value.unionMember2) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid PayStatementResponseBody") + } + } + } + + class UnionMember0 + private constructor( + private val paging: JsonField, + private val payStatements: JsonField>, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + @JsonProperty("pay_statements") + @ExcludeMissing + payStatements: JsonField> = JsonMissing.of(), + ) : this(paging, payStatements, 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 paging(): Paging = paging.getRequired("paging") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun payStatements(): List = payStatements.getRequired("pay_statements") + + /** + * 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 + + /** + * Returns the raw JSON value of [payStatements]. + * + * Unlike [payStatements], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pay_statements") + @ExcludeMissing + fun _payStatements(): JsonField> = payStatements + + @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 [UnionMember0]. + * + * The following fields are required: + * ```java + * .paging() + * .payStatements() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [UnionMember0]. */ + class Builder internal constructor() { + + private var paging: JsonField? = null + private var payStatements: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember0: UnionMember0) = apply { + paging = unionMember0.paging + payStatements = unionMember0.payStatements.map { it.toMutableList() } + additionalProperties = unionMember0.additionalProperties.toMutableMap() + } + + 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 payStatements(payStatements: List) = + payStatements(JsonField.of(payStatements)) + + /** + * Sets [Builder.payStatements] to an arbitrary JSON value. + * + * You should usually call [Builder.payStatements] with a well-typed + * `List` value instead. This method is primarily for setting the field to + * an undocumented or not yet supported value. + */ + fun payStatements(payStatements: JsonField>) = apply { + this.payStatements = payStatements.map { it.toMutableList() } + } + + /** + * Adds a single [PayStatement] to [payStatements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPayStatement(payStatement: PayStatement) = apply { + payStatements = + (payStatements ?: JsonField.of(mutableListOf())).also { + checkKnown("payStatements", it).add(payStatement) + } + } + + 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 [UnionMember0]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .paging() + * .payStatements() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember0 = + UnionMember0( + checkRequired("paging", paging), + checkRequired("payStatements", payStatements).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): UnionMember0 = apply { + if (validated) { + return@apply + } + + paging().validate() + payStatements().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 = + (paging.asKnown().getOrNull()?.validity() ?: 0) + + (payStatements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Paging + private constructor( + private val offset: JsonField, + private val count: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + ) : this(offset, count, mutableMapOf()) + + /** + * The current start index of the returned list of elements + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun offset(): Long = offset.getRequired("offset") + + /** + * The total number of elements for the entire query (not just the given page) + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun count(): Optional = count.getOptional("count") + + /** + * Returns the raw JSON value of [offset]. + * + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset + + /** + * Returns the raw JSON value of [count]. + * + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Paging]. + * + * The following fields are required: + * ```java + * .offset() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Paging]. */ + class Builder internal constructor() { + + private var offset: JsonField? = null + private var count: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(paging: Paging) = apply { + offset = paging.offset + count = paging.count + additionalProperties = paging.additionalProperties.toMutableMap() + } + + /** The current start index of the returned list of elements */ + fun offset(offset: Long) = offset(JsonField.of(offset)) + + /** + * Sets [Builder.offset] to an arbitrary JSON value. + * + * You should usually call [Builder.offset] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun offset(offset: JsonField) = apply { this.offset = offset } + + /** The total number of elements for the entire query (not just the given page) */ + fun count(count: Long) = count(JsonField.of(count)) + + /** + * Sets [Builder.count] to an arbitrary JSON value. + * + * You should usually call [Builder.count] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun count(count: JsonField) = apply { this.count = count } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Paging]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .offset() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Paging = + Paging( + checkRequired("offset", offset), + count, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Paging = apply { + if (validated) { + return@apply + } + + offset() + count() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (offset.asKnown().isPresent) 1 else 0) + + (if (count.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Paging && offset == other.offset && count == other.count && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(offset, count, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Paging{offset=$offset, count=$count, additionalProperties=$additionalProperties}" + } + + class PayStatement + private constructor( + private val earnings: JsonField>, + private val employeeDeductions: JsonField>, + private val employerContributions: JsonField>, + private val grossPay: JsonField, + private val individualId: JsonField, + private val netPay: JsonField, + private val paymentMethod: JsonField, + private val taxes: JsonField>, + private val totalHours: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("earnings") + @ExcludeMissing + earnings: JsonField> = JsonMissing.of(), + @JsonProperty("employee_deductions") + @ExcludeMissing + employeeDeductions: JsonField> = JsonMissing.of(), + @JsonProperty("employer_contributions") + @ExcludeMissing + employerContributions: JsonField> = JsonMissing.of(), + @JsonProperty("gross_pay") + @ExcludeMissing + grossPay: JsonField = JsonMissing.of(), + @JsonProperty("individual_id") + @ExcludeMissing + individualId: JsonField = JsonMissing.of(), + @JsonProperty("net_pay") + @ExcludeMissing + netPay: JsonField = JsonMissing.of(), + @JsonProperty("payment_method") + @ExcludeMissing + paymentMethod: JsonField = JsonMissing.of(), + @JsonProperty("taxes") + @ExcludeMissing + taxes: JsonField> = JsonMissing.of(), + @JsonProperty("total_hours") + @ExcludeMissing + totalHours: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + earnings, + employeeDeductions, + employerContributions, + grossPay, + individualId, + netPay, + paymentMethod, + taxes, + totalHours, + type, + mutableMapOf(), + ) + + /** + * The array of earnings objects associated with this pay statement + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun earnings(): Optional> = earnings.getOptional("earnings") + + /** + * The array of deductions objects associated with this pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun employeeDeductions(): Optional> = + employeeDeductions.getOptional("employee_deductions") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun employerContributions(): Optional> = + employerContributions.getOptional("employer_contributions") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun grossPay(): Optional = grossPay.getOptional("gross_pay") + + /** + * A stable Finch `id` (UUID v4) for an individual in the company + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun individualId(): String = individualId.getRequired("individual_id") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun netPay(): Optional = netPay.getOptional("net_pay") + + /** + * The payment method. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun paymentMethod(): Optional = + paymentMethod.getOptional("payment_method") + + /** + * The array of taxes objects associated with this pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun taxes(): Optional> = taxes.getOptional("taxes") + + /** + * The number of hours worked for this pay period + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun totalHours(): Optional = totalHours.getOptional("total_hours") + + /** + * The type of the payment associated with the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [earnings]. + * + * Unlike [earnings], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("earnings") + @ExcludeMissing + fun _earnings(): JsonField> = earnings + + /** + * Returns the raw JSON value of [employeeDeductions]. + * + * Unlike [employeeDeductions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("employee_deductions") + @ExcludeMissing + fun _employeeDeductions(): JsonField> = employeeDeductions + + /** + * Returns the raw JSON value of [employerContributions]. + * + * Unlike [employerContributions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("employer_contributions") + @ExcludeMissing + fun _employerContributions(): JsonField> = + employerContributions + + /** + * Returns the raw JSON value of [grossPay]. + * + * Unlike [grossPay], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay + + /** + * Returns the raw JSON value of [individualId]. + * + * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId + + /** + * Returns the raw JSON value of [netPay]. + * + * Unlike [netPay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay + + /** + * Returns the raw JSON value of [paymentMethod]. + * + * Unlike [paymentMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_method") + @ExcludeMissing + fun _paymentMethod(): JsonField = paymentMethod + + /** + * Returns the raw JSON value of [taxes]. + * + * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes + + /** + * Returns the raw JSON value of [totalHours]. + * + * Unlike [totalHours], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("total_hours") + @ExcludeMissing + fun _totalHours(): JsonField = totalHours + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PayStatement]. + * + * The following fields are required: + * ```java + * .earnings() + * .employeeDeductions() + * .employerContributions() + * .grossPay() + * .individualId() + * .netPay() + * .paymentMethod() + * .taxes() + * .totalHours() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PayStatement]. */ + class Builder internal constructor() { + + private var earnings: JsonField>? = null + private var employeeDeductions: JsonField>? = null + private var employerContributions: JsonField>? = + null + private var grossPay: JsonField? = null + private var individualId: JsonField? = null + private var netPay: JsonField? = null + private var paymentMethod: JsonField? = null + private var taxes: JsonField>? = null + private var totalHours: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(payStatement: PayStatement) = apply { + earnings = payStatement.earnings.map { it.toMutableList() } + employeeDeductions = payStatement.employeeDeductions.map { it.toMutableList() } + employerContributions = + payStatement.employerContributions.map { it.toMutableList() } + grossPay = payStatement.grossPay + individualId = payStatement.individualId + netPay = payStatement.netPay + paymentMethod = payStatement.paymentMethod + taxes = payStatement.taxes.map { it.toMutableList() } + totalHours = payStatement.totalHours + type = payStatement.type + additionalProperties = payStatement.additionalProperties.toMutableMap() + } + + /** The array of earnings objects associated with this pay statement */ + fun earnings(earnings: List?) = earnings(JsonField.ofNullable(earnings)) + + /** Alias for calling [Builder.earnings] with `earnings.orElse(null)`. */ + fun earnings(earnings: Optional>) = earnings(earnings.getOrNull()) + + /** + * Sets [Builder.earnings] to an arbitrary JSON value. + * + * You should usually call [Builder.earnings] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun earnings(earnings: JsonField>) = apply { + this.earnings = earnings.map { it.toMutableList() } + } + + /** + * Adds a single [Earning] to [earnings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEarning(earning: Earning) = apply { + earnings = + (earnings ?: JsonField.of(mutableListOf())).also { + checkKnown("earnings", it).add(earning) + } + } + + /** The array of deductions objects associated with this pay statement. */ + fun employeeDeductions(employeeDeductions: List?) = + employeeDeductions(JsonField.ofNullable(employeeDeductions)) + + /** + * Alias for calling [Builder.employeeDeductions] with + * `employeeDeductions.orElse(null)`. + */ + fun employeeDeductions(employeeDeductions: Optional>) = + employeeDeductions(employeeDeductions.getOrNull()) + + /** + * Sets [Builder.employeeDeductions] to an arbitrary JSON value. + * + * You should usually call [Builder.employeeDeductions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun employeeDeductions(employeeDeductions: JsonField>) = + apply { + this.employeeDeductions = employeeDeductions.map { it.toMutableList() } + } + + /** + * Adds a single [EmployeeDeduction] to [employeeDeductions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { + employeeDeductions = + (employeeDeductions ?: JsonField.of(mutableListOf())).also { + checkKnown("employeeDeductions", it).add(employeeDeduction) + } + } + + fun employerContributions(employerContributions: List?) = + employerContributions(JsonField.ofNullable(employerContributions)) + + /** + * Alias for calling [Builder.employerContributions] with + * `employerContributions.orElse(null)`. + */ + fun employerContributions( + employerContributions: Optional> + ) = employerContributions(employerContributions.getOrNull()) + + /** + * Sets [Builder.employerContributions] to an arbitrary JSON value. + * + * You should usually call [Builder.employerContributions] with a well-typed + * `List` value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun employerContributions( + employerContributions: JsonField> + ) = apply { + this.employerContributions = employerContributions.map { it.toMutableList() } + } + + /** + * Adds a single [EmployerContribution] to [employerContributions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmployerContribution(employerContribution: EmployerContribution) = apply { + employerContributions = + (employerContributions ?: JsonField.of(mutableListOf())).also { + checkKnown("employerContributions", it).add(employerContribution) + } + } + + fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) + + /** Alias for calling [Builder.grossPay] with `grossPay.orElse(null)`. */ + fun grossPay(grossPay: Optional) = grossPay(grossPay.getOrNull()) + + /** + * Sets [Builder.grossPay] to an arbitrary JSON value. + * + * You should usually call [Builder.grossPay] with a well-typed [Money] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } + + /** A stable Finch `id` (UUID v4) for an individual in the company */ + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** + * Sets [Builder.individualId] to an arbitrary JSON value. + * + * You should usually call [Builder.individualId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } + + fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) + + /** Alias for calling [Builder.netPay] with `netPay.orElse(null)`. */ + fun netPay(netPay: Optional) = netPay(netPay.getOrNull()) + + /** + * Sets [Builder.netPay] to an arbitrary JSON value. + * + * You should usually call [Builder.netPay] with a well-typed [Money] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun netPay(netPay: JsonField) = apply { this.netPay = netPay } + + /** The payment method. */ + fun paymentMethod(paymentMethod: PaymentMethod?) = + paymentMethod(JsonField.ofNullable(paymentMethod)) + + /** Alias for calling [Builder.paymentMethod] with `paymentMethod.orElse(null)`. */ + fun paymentMethod(paymentMethod: Optional) = + paymentMethod(paymentMethod.getOrNull()) + + /** + * Sets [Builder.paymentMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentMethod] with a well-typed [PaymentMethod] + * value instead. This method is primarily for setting the field to an undocumented + * or not yet supported value. + */ + fun paymentMethod(paymentMethod: JsonField) = apply { + this.paymentMethod = paymentMethod + } + + /** The array of taxes objects associated with this pay statement. */ + fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) + + /** Alias for calling [Builder.taxes] with `taxes.orElse(null)`. */ + fun taxes(taxes: Optional>) = taxes(taxes.getOrNull()) + + /** + * Sets [Builder.taxes] to an arbitrary JSON value. + * + * You should usually call [Builder.taxes] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun taxes(taxes: JsonField>) = apply { + this.taxes = taxes.map { it.toMutableList() } + } + + /** + * Adds a single [Tax] to [taxes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTax(tax: Tax) = apply { + taxes = + (taxes ?: JsonField.of(mutableListOf())).also { + checkKnown("taxes", it).add(tax) + } + } + + /** The number of hours worked for this pay period */ + fun totalHours(totalHours: Double?) = totalHours(JsonField.ofNullable(totalHours)) + + /** + * Alias for [Builder.totalHours]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalHours(totalHours: Double) = totalHours(totalHours as Double?) + + /** Alias for calling [Builder.totalHours] with `totalHours.orElse(null)`. */ + fun totalHours(totalHours: Optional) = totalHours(totalHours.getOrNull()) + + /** + * Sets [Builder.totalHours] to an arbitrary JSON value. + * + * You should usually call [Builder.totalHours] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun totalHours(totalHours: JsonField) = apply { + this.totalHours = totalHours + } + + /** The type of the payment associated with the pay statement. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PayStatement]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .earnings() + * .employeeDeductions() + * .employerContributions() + * .grossPay() + * .individualId() + * .netPay() + * .paymentMethod() + * .taxes() + * .totalHours() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PayStatement = + PayStatement( + checkRequired("earnings", earnings).map { it.toImmutable() }, + checkRequired("employeeDeductions", employeeDeductions).map { + it.toImmutable() + }, + checkRequired("employerContributions", employerContributions).map { + it.toImmutable() + }, + checkRequired("grossPay", grossPay), + checkRequired("individualId", individualId), + checkRequired("netPay", netPay), + checkRequired("paymentMethod", paymentMethod), + checkRequired("taxes", taxes).map { it.toImmutable() }, + checkRequired("totalHours", totalHours), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PayStatement = apply { + if (validated) { + return@apply + } + + earnings().ifPresent { it.forEach { it?.validate() } } + employeeDeductions().ifPresent { it.forEach { it?.validate() } } + employerContributions().ifPresent { it.forEach { it?.validate() } } + grossPay().ifPresent { it.validate() } + individualId() + netPay().ifPresent { it.validate() } + paymentMethod().ifPresent { it.validate() } + taxes().ifPresent { it.forEach { it?.validate() } } + totalHours() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (earnings.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + + (employeeDeductions.asKnown().getOrNull()?.sumOf { + (it?.validity() ?: 0).toInt() + } ?: 0) + + (employerContributions.asKnown().getOrNull()?.sumOf { + (it?.validity() ?: 0).toInt() + } ?: 0) + + (grossPay.asKnown().getOrNull()?.validity() ?: 0) + + (if (individualId.asKnown().isPresent) 1 else 0) + + (netPay.asKnown().getOrNull()?.validity() ?: 0) + + (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + + (taxes.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + + (if (totalHours.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Earning + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val hours: JsonField, + private val name: JsonField, + private val type: JsonField, + private val attributes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("hours") + @ExcludeMissing + hours: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(amount, currency, hours, name, type, attributes, mutableMapOf()) + + /** + * The earnings amount in cents. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The earnings currency code. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * The number of hours associated with this earning. (For salaried employees, this + * could be hours per pay period, `0` or `null`, depending on the provider). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun hours(): Optional = hours.getOptional("hours") + + /** + * The exact name of the deduction from the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The type of earning. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [hours]. + * + * Unlike [hours], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField = hours + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Earning]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .hours() + * .name() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Earning]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var hours: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + private var attributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(earning: Earning) = apply { + amount = earning.amount + currency = earning.currency + hours = earning.hours + name = earning.name + type = earning.type + attributes = earning.attributes + additionalProperties = earning.additionalProperties.toMutableMap() + } + + /** The earnings amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The earnings currency code. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * The number of hours associated with this earning. (For salaried employees, + * this could be hours per pay period, `0` or `null`, depending on the + * provider). + */ + fun hours(hours: Double?) = hours(JsonField.ofNullable(hours)) + + /** + * Alias for [Builder.hours]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hours(hours: Double) = hours(hours as Double?) + + /** Alias for calling [Builder.hours] with `hours.orElse(null)`. */ + fun hours(hours: Optional) = hours(hours.getOrNull()) + + /** + * Sets [Builder.hours] to an arbitrary JSON value. + * + * You should usually call [Builder.hours] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun hours(hours: JsonField) = apply { this.hours = hours } + + /** The exact name of the deduction from the pay statement. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The type of earning. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun attributes(attributes: Attributes?) = + attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = + attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Earning]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .hours() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Earning = + Earning( + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("hours", hours), + checkRequired("name", name), + checkRequired("type", type), + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Earning = apply { + if (validated) { + return@apply + } + + amount() + currency() + hours() + name() + type().ifPresent { it.validate() } + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (hours.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + /** The type of earning. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val SALARY = of("salary") + + @JvmField val WAGE = of("wage") + + @JvmField val REIMBURSEMENT = of("reimbursement") + + @JvmField val OVERTIME = of("overtime") + + @JvmField val SEVERANCE = of("severance") + + @JvmField val DOUBLE_OVERTIME = of("double_overtime") + + @JvmField val PTO = of("pto") + + @JvmField val SICK = of("sick") + + @JvmField val BONUS = of("bonus") + + @JvmField val COMMISSION = of("commission") + + @JvmField val TIPS = of("tips") + + @JvmField val _1099 = of("1099") + + @JvmField val OTHER = of("other") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SALARY, + WAGE, + REIMBURSEMENT, + OVERTIME, + SEVERANCE, + DOUBLE_OVERTIME, + PTO, + SICK, + BONUS, + COMMISSION, + TIPS, + _1099, + OTHER, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SALARY, + WAGE, + REIMBURSEMENT, + OVERTIME, + SEVERANCE, + DOUBLE_OVERTIME, + PTO, + SICK, + BONUS, + COMMISSION, + TIPS, + _1099, + OTHER, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SALARY -> Value.SALARY + WAGE -> Value.WAGE + REIMBURSEMENT -> Value.REIMBURSEMENT + OVERTIME -> Value.OVERTIME + SEVERANCE -> Value.SEVERANCE + DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME + PTO -> Value.PTO + SICK -> Value.SICK + BONUS -> Value.BONUS + COMMISSION -> Value.COMMISSION + TIPS -> Value.TIPS + _1099 -> Value._1099 + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + SALARY -> Known.SALARY + WAGE -> Known.WAGE + REIMBURSEMENT -> Known.REIMBURSEMENT + OVERTIME -> Known.OVERTIME + SEVERANCE -> Known.SEVERANCE + DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME + PTO -> Known.PTO + SICK -> Known.SICK + BONUS -> Known.BONUS + COMMISSION -> Known.COMMISSION + TIPS -> Known.TIPS + _1099 -> Known._1099 + OTHER -> Known.OTHER + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun metadata(): InnerMetadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + this.metadata = metadata.metadata + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + */ + fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed + * [InnerMetadata] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + */ + class InnerMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerMetadata: InnerMetadata) = apply { + additionalProperties = + innerMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): InnerMetadata = + InnerMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InnerMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerMetadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Earning && amount == other.amount && currency == other.currency && hours == other.hours && name == other.name && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, currency, hours, name, type, attributes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Earning{amount=$amount, currency=$currency, hours=$hours, name=$name, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" + } + + class EmployeeDeduction + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val name: JsonField, + private val preTax: JsonField, + private val type: JsonField, + private val attributes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("pre_tax") + @ExcludeMissing + preTax: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(amount, currency, name, preTax, type, attributes, mutableMapOf()) + + /** + * The deduction amount in cents. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The deduction currency. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * The deduction name from the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Boolean indicating if the deduction is pre-tax. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun preTax(): Optional = preTax.getOptional("pre_tax") + + /** + * Type of benefit. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [preTax]. + * + * Unlike [preTax], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("pre_tax") @ExcludeMissing fun _preTax(): JsonField = preTax + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EmployeeDeduction]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .name() + * .preTax() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmployeeDeduction]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var name: JsonField? = null + private var preTax: JsonField? = null + private var type: JsonField? = null + private var attributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(employeeDeduction: EmployeeDeduction) = apply { + amount = employeeDeduction.amount + currency = employeeDeduction.currency + name = employeeDeduction.name + preTax = employeeDeduction.preTax + type = employeeDeduction.type + attributes = employeeDeduction.attributes + additionalProperties = employeeDeduction.additionalProperties.toMutableMap() + } + + /** The deduction amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The deduction currency. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The deduction name from the pay statement. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Boolean indicating if the deduction is pre-tax. */ + fun preTax(preTax: Boolean?) = preTax(JsonField.ofNullable(preTax)) + + /** + * Alias for [Builder.preTax]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun preTax(preTax: Boolean) = preTax(preTax as Boolean?) + + /** Alias for calling [Builder.preTax] with `preTax.orElse(null)`. */ + fun preTax(preTax: Optional) = preTax(preTax.getOrNull()) + + /** + * Sets [Builder.preTax] to an arbitrary JSON value. + * + * You should usually call [Builder.preTax] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun preTax(preTax: JsonField) = apply { this.preTax = preTax } + + /** Type of benefit. */ + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BenefitType] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun attributes(attributes: Attributes?) = + attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = + attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmployeeDeduction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .name() + * .preTax() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EmployeeDeduction = + EmployeeDeduction( + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("name", name), + checkRequired("preTax", preTax), + checkRequired("type", type), + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EmployeeDeduction = apply { + if (validated) { + return@apply + } + + amount() + currency() + name() + preTax() + type().ifPresent { it.validate() } + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (preTax.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun metadata(): InnerMetadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + this.metadata = metadata.metadata + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + */ + fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed + * [InnerMetadata] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + */ + class InnerMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerMetadata: InnerMetadata) = apply { + additionalProperties = + innerMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): InnerMetadata = + InnerMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InnerMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerMetadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, currency, name, preTax, type, attributes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmployeeDeduction{amount=$amount, currency=$currency, name=$name, preTax=$preTax, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" + } + + class EmployerContribution + private constructor( + private val currency: JsonField, + private val name: JsonField, + private val type: JsonField, + private val amount: JsonField, + private val attributes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + type: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(currency, name, type, amount, attributes, mutableMapOf()) + + /** + * The contribution currency. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * The contribution name from the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Type of benefit. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * The contribution amount in cents. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [EmployerContribution]. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmployerContribution]. */ + class Builder internal constructor() { + + private var currency: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var attributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(employerContribution: EmployerContribution) = apply { + currency = employerContribution.currency + name = employerContribution.name + type = employerContribution.type + amount = employerContribution.amount + attributes = employerContribution.attributes + additionalProperties = + employerContribution.additionalProperties.toMutableMap() + } + + /** The contribution currency. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The contribution name from the pay statement. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Type of benefit. */ + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BenefitType] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The contribution amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun attributes(attributes: Attributes?) = + attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = + attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + 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 [EmployerContribution]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EmployerContribution = + EmployerContribution( + checkRequired("currency", currency), + checkRequired("name", name), + checkRequired("type", type), + amount, + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EmployerContribution = apply { + if (validated) { + return@apply + } + + currency() + name() + type().ifPresent { it.validate() } + amount() + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun metadata(): InnerMetadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + this.metadata = metadata.metadata + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + */ + fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed + * [InnerMetadata] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + */ + class InnerMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerMetadata: InnerMetadata) = apply { + additionalProperties = + innerMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): InnerMetadata = + InnerMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InnerMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerMetadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EmployerContribution && currency == other.currency && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(currency, name, type, amount, attributes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmployerContribution{currency=$currency, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" + } + + /** The payment method. */ + class PaymentMethod + @JsonCreator + private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CHECK = of("check") + + @JvmField val DIRECT_DEPOSIT = of("direct_deposit") + + @JvmField val OTHER = of("other") + + @JvmStatic fun of(value: String) = PaymentMethod(JsonField.of(value)) + } + + /** An enum containing [PaymentMethod]'s known values. */ + enum class Known { + CHECK, + DIRECT_DEPOSIT, + OTHER, + } + + /** + * An enum containing [PaymentMethod]'s known values, as well as an [_UNKNOWN] + * member. + * + * An instance of [PaymentMethod] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHECK, + DIRECT_DEPOSIT, + OTHER, + /** + * An enum member indicating that [PaymentMethod] was instantiated with an + * unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHECK -> Value.CHECK + DIRECT_DEPOSIT -> Value.DIRECT_DEPOSIT + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHECK -> Known.CHECK + DIRECT_DEPOSIT -> Known.DIRECT_DEPOSIT + OTHER -> Known.OTHER + else -> throw FinchInvalidDataException("Unknown PaymentMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): PaymentMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentMethod && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Tax + private constructor( + private val currency: JsonField, + private val employer: JsonField, + private val name: JsonField, + private val type: JsonField, + private val amount: JsonField, + private val attributes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("employer") + @ExcludeMissing + employer: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + amount: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(currency, employer, name, type, amount, attributes, mutableMapOf()) + + /** + * The currency code. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * `true` if the amount is paid by the employers. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun employer(): Optional = employer.getOptional("employer") + + /** + * The exact name of tax from the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The type of taxes. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * The tax amount in cents. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [employer]. + * + * Unlike [employer], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("employer") + @ExcludeMissing + fun _employer(): JsonField = employer + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tax]. + * + * The following fields are required: + * ```java + * .currency() + * .employer() + * .name() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tax]. */ + class Builder internal constructor() { + + private var currency: JsonField? = null + private var employer: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var attributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tax: Tax) = apply { + currency = tax.currency + employer = tax.employer + name = tax.name + type = tax.type + amount = tax.amount + attributes = tax.attributes + additionalProperties = tax.additionalProperties.toMutableMap() + } + + /** The currency code. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** `true` if the amount is paid by the employers. */ + fun employer(employer: Boolean?) = employer(JsonField.ofNullable(employer)) + + /** + * Alias for [Builder.employer]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun employer(employer: Boolean) = employer(employer as Boolean?) + + /** Alias for calling [Builder.employer] with `employer.orElse(null)`. */ + fun employer(employer: Optional) = employer(employer.getOrNull()) + + /** + * Sets [Builder.employer] to an arbitrary JSON value. + * + * You should usually call [Builder.employer] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun employer(employer: JsonField) = apply { this.employer = employer } + + /** The exact name of tax from the pay statement. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The type of taxes. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The tax amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun attributes(attributes: Attributes?) = + attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = + attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tax]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .currency() + * .employer() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tax = + Tax( + checkRequired("currency", currency), + checkRequired("employer", employer), + checkRequired("name", name), + checkRequired("type", type), + amount, + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tax = apply { + if (validated) { + return@apply + } + + currency() + employer() + name() + type().ifPresent { it.validate() } + amount() + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (if (employer.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + /** The type of taxes. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue + fun _value(): JsonField = value + + companion object { + + @JvmField val STATE = of("state") + + @JvmField val FEDERAL = of("federal") + + @JvmField val LOCAL = of("local") + + @JvmField val FICA = of("fica") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + STATE, + FEDERAL, + LOCAL, + FICA, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For + * example, if the SDK is on an older version than the API, then the API may + * respond with new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STATE, + FEDERAL, + LOCAL, + FICA, + /** + * An enum member indicating that [Type] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or + * if you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STATE -> Value.STATE + FEDERAL -> Value.FEDERAL + LOCAL -> Value.LOCAL + FICA -> Value.FICA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known + * and don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a + * known member. + */ + fun known(): Known = + when (this) { + STATE -> Known.STATE + FEDERAL -> Known.FEDERAL + LOCAL -> Known.LOCAL + FICA -> Known.FICA + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not + * have the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected + * type or is unexpectedly missing or null (e.g. if the server responded + * with an unexpected value). + */ + fun metadata(): InnerMetadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + this.metadata = metadata.metadata + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + */ + fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed + * [InnerMetadata] value instead. This method is primarily for setting + * the field to an undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this + * object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, + * boolean, object, array, etc.). + */ + class InnerMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerMetadata: InnerMetadata) = apply { + additionalProperties = + innerMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties( + additionalProperties: Map + ) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerMetadata]. + * + * Further updates to this [Builder] will not mutate the returned + * instance. + */ + fun build(): InnerMetadata = + InnerMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InnerMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in + * this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerMetadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tax && currency == other.currency && employer == other.employer && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(currency, employer, name, type, amount, attributes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tax{currency=$currency, employer=$employer, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" + } + + /** The type of the payment associated with the pay statement. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") + + @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") + + @JvmField val REGULAR_PAYROLL = of("regular_payroll") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + OFF_CYCLE_PAYROLL, + ONE_TIME_PAYMENT, + REGULAR_PAYROLL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OFF_CYCLE_PAYROLL, + ONE_TIME_PAYMENT, + REGULAR_PAYROLL, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL + ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Value.REGULAR_PAYROLL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL + ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Known.REGULAR_PAYROLL + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PayStatement && earnings == other.earnings && employeeDeductions == other.employeeDeductions && employerContributions == other.employerContributions && grossPay == other.grossPay && individualId == other.individualId && netPay == other.netPay && paymentMethod == other.paymentMethod && taxes == other.taxes && totalHours == other.totalHours && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(earnings, employeeDeductions, employerContributions, grossPay, individualId, netPay, paymentMethod, taxes, totalHours, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PayStatement{earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, individualId=$individualId, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnionMember0 && paging == other.paging && payStatements == other.payStatements && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(paging, payStatements, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember0{paging=$paging, payStatements=$payStatements, additionalProperties=$additionalProperties}" + } + + class BatchError private constructor( - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - @JsonProperty("pay_statements") + private val code: JsonField, + private val message: JsonField, + private val name: JsonField, + private val finchCode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("finch_code") + @ExcludeMissing + finchCode: JsonField = JsonMissing.of(), + ) : this(code, message, name, finchCode, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Double = code.getRequired("code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun finchCode(): Optional = finchCode.getOptional("finch_code") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [finchCode]. + * + * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("finch_code") @ExcludeMissing fun _finchCode(): JsonField = finchCode + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter @ExcludeMissing - payStatements: JsonField> = JsonMissing.of(), - ) : this(paging, payStatements, mutableMapOf()) + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun paging(): Optional = paging.getOptional("paging") + fun toBuilder() = Builder().from(this) - /** - * The array of pay statements for the current payment. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun payStatements(): Optional> = payStatements.getOptional("pay_statements") + companion object { - /** - * 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 + /** + * Returns a mutable builder for constructing an instance of [BatchError]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - /** - * Returns the raw JSON value of [payStatements]. - * - * Unlike [payStatements], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pay_statements") - @ExcludeMissing - fun _payStatements(): JsonField> = payStatements + /** A builder for [BatchError]. */ + class Builder internal constructor() { - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + private var code: JsonField? = null + private var message: JsonField? = null + private var name: JsonField? = null + private var finchCode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) + @JvmSynthetic + internal fun from(batchError: BatchError) = apply { + code = batchError.code + message = batchError.message + name = batchError.name + finchCode = batchError.finchCode + additionalProperties = batchError.additionalProperties.toMutableMap() + } - fun toBuilder() = Builder().from(this) + fun code(code: Double) = code(JsonField.of(code)) - companion object { + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Double] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun code(code: JsonField) = apply { this.code = code } - /** Returns a mutable builder for constructing an instance of [PayStatementResponseBody]. */ - @JvmStatic fun builder() = Builder() - } + fun message(message: String) = message(JsonField.of(message)) - /** A builder for [PayStatementResponseBody]. */ - class Builder internal constructor() { + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } - private var paging: JsonField = JsonMissing.of() - private var payStatements: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() + fun name(name: String) = name(JsonField.of(name)) + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun finchCode(finchCode: String) = finchCode(JsonField.of(finchCode)) + + /** + * Sets [Builder.finchCode] to an arbitrary JSON value. + * + * You should usually call [Builder.finchCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BatchError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BatchError = + BatchError( + checkRequired("code", code), + checkRequired("message", message), + checkRequired("name", name), + finchCode, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BatchError = apply { + if (validated) { + return@apply + } + + code() + message() + name() + finchCode() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ @JvmSynthetic - internal fun from(payStatementResponseBody: PayStatementResponseBody) = apply { - paging = payStatementResponseBody.paging - payStatements = payStatementResponseBody.payStatements.map { it.toMutableList() } - additionalProperties = payStatementResponseBody.additionalProperties.toMutableMap() + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (finchCode.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BatchError && code == other.code && message == other.message && name == other.name && finchCode == other.finchCode && additionalProperties == other.additionalProperties /* spotless:on */ } - fun paging(paging: Paging) = paging(JsonField.of(paging)) + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, message, name, finchCode, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchError{code=$code, message=$message, name=$name, finchCode=$finchCode, additionalProperties=$additionalProperties}" + } + + class UnionMember2 + private constructor( + private val code: JsonField, + private val finchCode: JsonField, + private val message: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("finch_code") + @ExcludeMissing + finchCode: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(code, finchCode, message, name, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Code = code.getRequired("code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun finchCode(): FinchCode = finchCode.getRequired("finch_code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): Message = message.getRequired("message") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): Name = name.getRequired("name") /** - * Sets [Builder.paging] to an arbitrary JSON value. + * Returns the raw JSON value of [code]. * - * 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. + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. */ - fun paging(paging: JsonField) = apply { this.paging = paging } + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - /** The array of pay statements for the current payment. */ - fun payStatements(payStatements: List) = - payStatements(JsonField.of(payStatements)) + /** + * Returns the raw JSON value of [finchCode]. + * + * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("finch_code") + @ExcludeMissing + fun _finchCode(): JsonField = finchCode /** - * Sets [Builder.payStatements] to an arbitrary JSON value. + * Returns the raw JSON value of [message]. * - * You should usually call [Builder.payStatements] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. */ - fun payStatements(payStatements: JsonField>) = apply { - this.payStatements = payStatements.map { it.toMutableList() } - } + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message /** - * Adds a single [PayStatement] to [payStatements]. + * Returns the raw JSON value of [name]. * - * @throws IllegalStateException if the field was previously set to a non-list. + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. */ - fun addPayStatement(payStatement: PayStatement) = apply { - payStatements = - (payStatements ?: JsonField.of(mutableListOf())).also { - checkKnown("payStatements", it).add(payStatement) - } - } + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - 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 [UnionMember2]. + * + * The following fields are required: + * ```java + * .code() + * .finchCode() + * .message() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() } - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) + /** A builder for [UnionMember2]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var finchCode: JsonField? = null + private var message: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(unionMember2: UnionMember2) = apply { + code = unionMember2.code + finchCode = unionMember2.finchCode + message = unionMember2.message + name = unionMember2.name + additionalProperties = unionMember2.additionalProperties.toMutableMap() + } + + fun code(code: Code) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Code] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun finchCode(finchCode: FinchCode) = finchCode(JsonField.of(finchCode)) + + /** + * Sets [Builder.finchCode] to an arbitrary JSON value. + * + * You should usually call [Builder.finchCode] with a well-typed [FinchCode] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } + + fun message(message: Message) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [UnionMember2]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .finchCode() + * .message() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): UnionMember2 = + UnionMember2( + checkRequired("code", code), + checkRequired("finchCode", finchCode), + checkRequired("message", message), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) } - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + private var validated: Boolean = false + + fun validate(): UnionMember2 = apply { + if (validated) { + return@apply + } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) + code().validate() + finchCode().validate() + message().validate() + name().validate() + validated = true } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + /** - * Returns an immutable instance of [PayStatementResponseBody]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): PayStatementResponseBody = - PayStatementResponseBody( - paging, - (payStatements ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic + internal fun validity(): Int = + (code.asKnown().getOrNull()?.validity() ?: 0) + + (finchCode.asKnown().getOrNull()?.validity() ?: 0) + + (message.asKnown().getOrNull()?.validity() ?: 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) - private var validated: Boolean = false + class Code @JsonCreator private constructor(private val value: JsonField) : Enum { - fun validate(): PayStatementResponseBody = apply { - if (validated) { - return@apply + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _202 = of(202.0) + + @JvmStatic fun of(value: Double) = Code(JsonField.of(value)) + } + + /** An enum containing [Code]'s known values. */ + enum class Known { + _202 + } + + /** + * An enum containing [Code]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Code] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _202, + /** An enum member indicating that [Code] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _202 -> Value._202 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _202 -> Known._202 + else -> throw FinchInvalidDataException("Unknown Code: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asDouble(): Double = + _value().asNumber().getOrNull()?.toDouble() + ?: throw FinchInvalidDataException("Value is not a Double") + + private var validated: Boolean = false + + fun validate(): Code = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - paging().ifPresent { it.validate() } - payStatements().ifPresent { it.forEach { it.validate() } } - validated = true - } + class FinchCode @JsonCreator private constructor(private val value: JsonField) : + Enum { - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DATA_SYNC_IN_PROGRESS = of("data_sync_in_progress") + + @JvmStatic fun of(value: String) = FinchCode(JsonField.of(value)) + } + + /** An enum containing [FinchCode]'s known values. */ + enum class Known { + DATA_SYNC_IN_PROGRESS + } + + /** + * An enum containing [FinchCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FinchCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DATA_SYNC_IN_PROGRESS, + /** + * An enum member indicating that [FinchCode] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DATA_SYNC_IN_PROGRESS -> Value.DATA_SYNC_IN_PROGRESS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + DATA_SYNC_IN_PROGRESS -> Known.DATA_SYNC_IN_PROGRESS + else -> throw FinchInvalidDataException("Unknown FinchCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): FinchCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FinchCode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - /** - * 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 = - (paging.asKnown().getOrNull()?.validity() ?: 0) + - (payStatements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + class Message @JsonCreator private constructor(private val value: JsonField) : + Enum { - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER = + of( + "The pay statements for this payment are being fetched. Please check back later." + ) + + @JvmStatic fun of(value: String) = Message(JsonField.of(value)) + } + + /** An enum containing [Message]'s known values. */ + enum class Known { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + } + + /** + * An enum containing [Message]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Message] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER, + /** + * An enum member indicating that [Message] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER -> + Value + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER -> + Known + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + else -> throw FinchInvalidDataException("Unknown Message: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Message && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() } - return /* spotless:off */ other is PayStatementResponseBody && paging == other.paging && payStatements == other.payStatements && additionalProperties == other.additionalProperties /* spotless:on */ - } + class Name @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACCEPTED = of("accepted") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + ACCEPTED + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCEPTED, + /** An enum member indicating that [Name] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCEPTED -> Value.ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + else -> throw FinchInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(paging, payStatements, additionalProperties) } - /* spotless:on */ + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Name && value == other.value /* spotless:on */ + } - override fun hashCode(): Int = hashCode + override fun hashCode() = value.hashCode() - override fun toString() = - "PayStatementResponseBody{paging=$paging, payStatements=$payStatements, additionalProperties=$additionalProperties}" + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is UnionMember2 && code == other.code && finchCode == other.finchCode && message == other.message && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, finchCode, message, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "UnionMember2{code=$code, finchCode=$finchCode, message=$message, name=$name, additionalProperties=$additionalProperties}" + } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Payment.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Payment.kt index 27d85584..c3dfdb32 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Payment.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Payment.kt @@ -12,6 +12,7 @@ import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -83,10 +84,10 @@ private constructor( /** * The unique id for the payment. * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). */ - fun id(): Optional = id.getOptional("id") + fun id(): String = id.getRequired("id") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -273,25 +274,43 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Payment]. */ + /** + * Returns a mutable builder for constructing an instance of [Payment]. + * + * The following fields are required: + * ```java + * .id() + * .companyDebit() + * .debitDate() + * .employeeTaxes() + * .employerTaxes() + * .grossPay() + * .individualIds() + * .netPay() + * .payDate() + * .payFrequencies() + * .payGroupIds() + * .payPeriod() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Payment]. */ class Builder internal constructor() { - private var id: JsonField = JsonMissing.of() - private var companyDebit: JsonField = JsonMissing.of() - private var debitDate: JsonField = JsonMissing.of() - private var employeeTaxes: JsonField = JsonMissing.of() - private var employerTaxes: JsonField = JsonMissing.of() - private var grossPay: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var companyDebit: JsonField? = null + private var debitDate: JsonField? = null + private var employeeTaxes: JsonField? = null + private var employerTaxes: JsonField? = null + private var grossPay: JsonField? = null private var individualIds: JsonField>? = null - private var netPay: JsonField = JsonMissing.of() - private var payDate: JsonField = JsonMissing.of() + private var netPay: JsonField? = null + private var payDate: JsonField? = null private var payFrequencies: JsonField>? = null private var payGroupIds: JsonField>? = null - private var payPeriod: JsonField = JsonMissing.of() + private var payPeriod: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -554,21 +573,39 @@ private constructor( * Returns an immutable instance of [Payment]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .id() + * .companyDebit() + * .debitDate() + * .employeeTaxes() + * .employerTaxes() + * .grossPay() + * .individualIds() + * .netPay() + * .payDate() + * .payFrequencies() + * .payGroupIds() + * .payPeriod() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Payment = Payment( - id, - companyDebit, - debitDate, - employeeTaxes, - employerTaxes, - grossPay, - (individualIds ?: JsonMissing.of()).map { it.toImmutable() }, - netPay, - payDate, - (payFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, - (payGroupIds ?: JsonMissing.of()).map { it.toImmutable() }, - payPeriod, + checkRequired("id", id), + checkRequired("companyDebit", companyDebit), + checkRequired("debitDate", debitDate), + checkRequired("employeeTaxes", employeeTaxes), + checkRequired("employerTaxes", employerTaxes), + checkRequired("grossPay", grossPay), + checkRequired("individualIds", individualIds).map { it.toImmutable() }, + checkRequired("netPay", netPay), + checkRequired("payDate", payDate), + checkRequired("payFrequencies", payFrequencies).map { it.toImmutable() }, + checkRequired("payGroupIds", payGroupIds).map { it.toImmutable() }, + checkRequired("payPeriod", payPeriod), additionalProperties.toMutableMap(), ) } @@ -640,21 +677,21 @@ private constructor( @JvmField val ANNUALLY = of("annually") - @JvmField val SEMI_ANNUALLY = of("semi_annually") + @JvmField val BI_WEEKLY = of("bi_weekly") - @JvmField val QUARTERLY = of("quarterly") + @JvmField val DAILY = of("daily") @JvmField val MONTHLY = of("monthly") - @JvmField val SEMI_MONTHLY = of("semi_monthly") + @JvmField val OTHER = of("other") - @JvmField val BI_WEEKLY = of("bi_weekly") + @JvmField val QUARTERLY = of("quarterly") - @JvmField val WEEKLY = of("weekly") + @JvmField val SEMI_ANNUALLY = of("semi_annually") - @JvmField val DAILY = of("daily") + @JvmField val SEMI_MONTHLY = of("semi_monthly") - @JvmField val OTHER = of("other") + @JvmField val WEEKLY = of("weekly") @JvmStatic fun of(value: String) = PayFrequency(JsonField.of(value)) } @@ -662,14 +699,14 @@ private constructor( /** An enum containing [PayFrequency]'s known values. */ enum class Known { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, } /** @@ -683,14 +720,14 @@ private constructor( */ enum class Value { ANNUALLY, - SEMI_ANNUALLY, - QUARTERLY, - MONTHLY, - SEMI_MONTHLY, BI_WEEKLY, - WEEKLY, DAILY, + MONTHLY, OTHER, + QUARTERLY, + SEMI_ANNUALLY, + SEMI_MONTHLY, + WEEKLY, /** * An enum member indicating that [PayFrequency] was instantiated with an unknown value. */ @@ -707,14 +744,14 @@ private constructor( fun value(): Value = when (this) { ANNUALLY -> Value.ANNUALLY - SEMI_ANNUALLY -> Value.SEMI_ANNUALLY - QUARTERLY -> Value.QUARTERLY - MONTHLY -> Value.MONTHLY - SEMI_MONTHLY -> Value.SEMI_MONTHLY BI_WEEKLY -> Value.BI_WEEKLY - WEEKLY -> Value.WEEKLY DAILY -> Value.DAILY + MONTHLY -> Value.MONTHLY OTHER -> Value.OTHER + QUARTERLY -> Value.QUARTERLY + SEMI_ANNUALLY -> Value.SEMI_ANNUALLY + SEMI_MONTHLY -> Value.SEMI_MONTHLY + WEEKLY -> Value.WEEKLY else -> Value._UNKNOWN } @@ -729,14 +766,14 @@ private constructor( fun known(): Known = when (this) { ANNUALLY -> Known.ANNUALLY - SEMI_ANNUALLY -> Known.SEMI_ANNUALLY - QUARTERLY -> Known.QUARTERLY - MONTHLY -> Known.MONTHLY - SEMI_MONTHLY -> Known.SEMI_MONTHLY BI_WEEKLY -> Known.BI_WEEKLY - WEEKLY -> Known.WEEKLY DAILY -> Known.DAILY + MONTHLY -> Known.MONTHLY OTHER -> Known.OTHER + QUARTERLY -> Known.QUARTERLY + SEMI_ANNUALLY -> Known.SEMI_ANNUALLY + SEMI_MONTHLY -> Known.SEMI_MONTHLY + WEEKLY -> Known.WEEKLY else -> throw FinchInvalidDataException("Unknown PayFrequency: $value") } @@ -848,15 +885,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayPeriod]. */ + /** + * Returns a mutable builder for constructing an instance of [PayPeriod]. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [PayPeriod]. */ class Builder internal constructor() { - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -917,9 +962,21 @@ private constructor( * Returns an immutable instance of [PayPeriod]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .endDate() + * .startDate() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayPeriod = - PayPeriod(endDate, startDate, additionalProperties.toMutableMap()) + PayPeriod( + checkRequired("endDate", endDate), + checkRequired("startDate", startDate), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt index 82188e32..93cbfe99 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt @@ -13,6 +13,7 @@ import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.Params import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.toImmutable @@ -613,10 +614,10 @@ private constructor( /** * A stable Finch `id` (UUID v4) for an individual in the company * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun individualId(): Optional = individualId.getOptional("individual_id") + fun individualId(): String = individualId.getRequired("individual_id") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the @@ -756,7 +757,23 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [PayStatement]. */ + /** + * Returns a mutable builder for constructing an instance of [PayStatement]. + * + * The following fields are required: + * ```java + * .earnings() + * .employeeDeductions() + * .employerContributions() + * .grossPay() + * .individualId() + * .netPay() + * .paymentMethod() + * .taxes() + * .totalHours() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } @@ -766,13 +783,13 @@ private constructor( private var earnings: JsonField>? = null private var employeeDeductions: JsonField>? = null private var employerContributions: JsonField>? = null - private var grossPay: JsonField = JsonMissing.of() - private var individualId: JsonField = JsonMissing.of() - private var netPay: JsonField = JsonMissing.of() - private var paymentMethod: JsonField = JsonMissing.of() + private var grossPay: JsonField? = null + private var individualId: JsonField? = null + private var netPay: JsonField? = null + private var paymentMethod: JsonField? = null private var taxes: JsonField>? = null - private var totalHours: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var totalHours: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1041,19 +1058,39 @@ private constructor( * Returns an immutable instance of [PayStatement]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .earnings() + * .employeeDeductions() + * .employerContributions() + * .grossPay() + * .individualId() + * .netPay() + * .paymentMethod() + * .taxes() + * .totalHours() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): PayStatement = PayStatement( - (earnings ?: JsonMissing.of()).map { it.toImmutable() }, - (employeeDeductions ?: JsonMissing.of()).map { it.toImmutable() }, - (employerContributions ?: JsonMissing.of()).map { it.toImmutable() }, - grossPay, - individualId, - netPay, - paymentMethod, - (taxes ?: JsonMissing.of()).map { it.toImmutable() }, - totalHours, - type, + checkRequired("earnings", earnings).map { it.toImmutable() }, + checkRequired("employeeDeductions", employeeDeductions).map { + it.toImmutable() + }, + checkRequired("employerContributions", employerContributions).map { + it.toImmutable() + }, + checkRequired("grossPay", grossPay), + checkRequired("individualId", individualId), + checkRequired("netPay", netPay), + checkRequired("paymentMethod", paymentMethod), + checkRequired("taxes", taxes).map { it.toImmutable() }, + checkRequired("totalHours", totalHours), + checkRequired("type", type), additionalProperties.toMutableMap(), ) } @@ -1111,27 +1148,27 @@ private constructor( class Earning private constructor( private val amount: JsonField, - private val attributes: JsonField, private val currency: JsonField, private val hours: JsonField, private val name: JsonField, private val type: JsonField, + private val attributes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("hours") @ExcludeMissing hours: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, hours, name, type, mutableMapOf()) + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(amount, currency, hours, name, type, attributes, mutableMapOf()) /** * The earnings amount in cents. @@ -1141,12 +1178,6 @@ private constructor( */ fun amount(): Optional = amount.getOptional("amount") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - /** * The earnings currency code. * @@ -1181,21 +1212,17 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun attributes(): Optional = attributes.getOptional("attributes") /** - * Returns the raw JSON value of [attributes]. + * Returns the raw JSON value of [amount]. * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * Returns the raw JSON value of [currency]. @@ -1226,6 +1253,16 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -1240,29 +1277,40 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Earning]. */ + /** + * Returns a mutable builder for constructing an instance of [Earning]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .hours() + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Earning]. */ class Builder internal constructor() { - private var amount: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null + private var hours: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var hours: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(earning: Earning) = apply { amount = earning.amount - attributes = earning.attributes currency = earning.currency hours = earning.hours name = earning.name type = earning.type + attributes = earning.attributes additionalProperties = earning.additionalProperties.toMutableMap() } @@ -1288,24 +1336,6 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - /** The earnings currency code. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -1376,6 +1406,24 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + fun attributes(attributes: Attributes?) = + attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = + attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1402,15 +1450,26 @@ private constructor( * Returns an immutable instance of [Earning]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .hours() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Earning = Earning( - amount, + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("hours", hours), + checkRequired("name", name), + checkRequired("type", type), attributes, - currency, - hours, - name, - type, additionalProperties.toMutableMap(), ) } @@ -1423,11 +1482,11 @@ private constructor( } amount() - attributes().ifPresent { it.validate() } currency() hours() name() type().ifPresent { it.validate() } + attributes().ifPresent { it.validate() } validated = true } @@ -1448,144 +1507,359 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (hours.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun metadata(): Optional = metadata.getOptional("metadata") + /** The type of earning. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { /** - * Returns the raw JSON value of [metadata]. + * Returns this class instance's raw value. * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { + @JvmField val SALARY = of("salary") - private var metadata: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() + @JvmField val WAGE = of("wage") - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } + @JvmField val REIMBURSEMENT = of("reimbursement") - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + @JvmField val OVERTIME = of("overtime") - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + @JvmField val SEVERANCE = of("severance") - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + @JvmField val DOUBLE_OVERTIME = of("double_overtime") - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + @JvmField val PTO = of("pto") - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } + @JvmField val SICK = of("sick") - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } + @JvmField val BONUS = of("bonus") - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + @JvmField val COMMISSION = of("commission") - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): Attributes = - Attributes(metadata, additionalProperties.toMutableMap()) - } + @JvmField val TIPS = of("tips") - private var validated: Boolean = false + @JvmField val _1099 = of("1099") - fun validate(): Attributes = apply { - if (validated) { - return@apply - } + @JvmField val OTHER = of("other") - metadata().ifPresent { it.validate() } - validated = true + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + /** An enum containing [Type]'s known values. */ + enum class Known { + SALARY, + WAGE, + REIMBURSEMENT, + OVERTIME, + SEVERANCE, + DOUBLE_OVERTIME, + PTO, + SICK, + BONUS, + COMMISSION, + TIPS, + _1099, + OTHER, + } /** - * Returns a score indicating how many valid values are contained in this object - * recursively. + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. * - * Used for best match union deserialization. + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + enum class Value { + SALARY, + WAGE, + REIMBURSEMENT, + OVERTIME, + SEVERANCE, + DOUBLE_OVERTIME, + PTO, + SICK, + BONUS, + COMMISSION, + TIPS, + _1099, + OTHER, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } - class Metadata - private constructor( - private val metadata: JsonField, + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SALARY -> Value.SALARY + WAGE -> Value.WAGE + REIMBURSEMENT -> Value.REIMBURSEMENT + OVERTIME -> Value.OVERTIME + SEVERANCE -> Value.SEVERANCE + DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME + PTO -> Value.PTO + SICK -> Value.SICK + BONUS -> Value.BONUS + COMMISSION -> Value.COMMISSION + TIPS -> Value.TIPS + _1099 -> Value._1099 + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SALARY -> Known.SALARY + WAGE -> Known.WAGE + REIMBURSEMENT -> Known.REIMBURSEMENT + OVERTIME -> Known.OVERTIME + SEVERANCE -> Known.SEVERANCE + DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME + PTO -> Known.PTO + SICK -> Known.SICK + BONUS -> Known.BONUS + COMMISSION -> Known.COMMISSION + TIPS -> Known.TIPS + _1099 -> Known._1099 + OTHER -> Known.OTHER + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, private val additionalProperties: MutableMap, ) { @@ -1601,10 +1875,11 @@ private constructor( * key-value pairs where the values can be of any type (string, number, boolean, * object, array, etc.). * - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): InnerMetadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -1630,14 +1905,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -1691,9 +1973,19 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Metadata = - Metadata(metadata, additionalProperties.toMutableMap()) + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -1703,7 +1995,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -1879,238 +2171,38 @@ private constructor( "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" } - /** The type of earning. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val SALARY = of("salary") - - @JvmField val WAGE = of("wage") - - @JvmField val REIMBURSEMENT = of("reimbursement") - - @JvmField val OVERTIME = of("overtime") - - @JvmField val SEVERANCE = of("severance") - - @JvmField val DOUBLE_OVERTIME = of("double_overtime") - - @JvmField val PTO = of("pto") - - @JvmField val SICK = of("sick") - - @JvmField val BONUS = of("bonus") - - @JvmField val COMMISSION = of("commission") - - @JvmField val TIPS = of("tips") - - @JvmField val _1099 = of("1099") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - OTHER, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - OTHER, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SALARY -> Value.SALARY - WAGE -> Value.WAGE - REIMBURSEMENT -> Value.REIMBURSEMENT - OVERTIME -> Value.OVERTIME - SEVERANCE -> Value.SEVERANCE - DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME - PTO -> Value.PTO - SICK -> Value.SICK - BONUS -> Value.BONUS - COMMISSION -> Value.COMMISSION - TIPS -> Value.TIPS - _1099 -> Value._1099 - OTHER -> Value.OTHER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SALARY -> Known.SALARY - WAGE -> Known.WAGE - REIMBURSEMENT -> Known.REIMBURSEMENT - OVERTIME -> Known.OVERTIME - SEVERANCE -> Known.SEVERANCE - DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME - PTO -> Known.PTO - SICK -> Known.SICK - BONUS -> Known.BONUS - COMMISSION -> Known.COMMISSION - TIPS -> Known.TIPS - _1099 -> Known._1099 - OTHER -> Known.OTHER - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Earning && amount == other.amount && attributes == other.attributes && currency == other.currency && hours == other.hours && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Earning && amount == other.amount && currency == other.currency && hours == other.hours && name == other.name && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, hours, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, currency, hours, name, type, attributes, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Earning{amount=$amount, attributes=$attributes, currency=$currency, hours=$hours, name=$name, type=$type, additionalProperties=$additionalProperties}" + "Earning{amount=$amount, currency=$currency, hours=$hours, name=$name, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" } class EmployeeDeduction private constructor( private val amount: JsonField, - private val attributes: JsonField, private val currency: JsonField, private val name: JsonField, private val preTax: JsonField, private val type: JsonField, + private val attributes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -2121,7 +2213,10 @@ private constructor( @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, name, preTax, type, mutableMapOf()) + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(amount, currency, name, preTax, type, attributes, mutableMapOf()) /** * The deduction amount in cents. @@ -2131,12 +2226,6 @@ private constructor( */ fun amount(): Optional = amount.getOptional("amount") - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - /** * The deduction currency. * @@ -2170,21 +2259,17 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun attributes(): Optional = attributes.getOptional("attributes") /** - * Returns the raw JSON value of [attributes]. + * Returns the raw JSON value of [amount]. * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * Returns the raw JSON value of [currency]. @@ -2215,6 +2300,16 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -2231,6 +2326,15 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [EmployeeDeduction]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .name() + * .preTax() + * .type() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -2238,22 +2342,22 @@ private constructor( /** A builder for [EmployeeDeduction]. */ class Builder internal constructor() { - private var amount: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var currency: JsonField? = null + private var name: JsonField? = null + private var preTax: JsonField? = null + private var type: JsonField? = null private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var preTax: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(employeeDeduction: EmployeeDeduction) = apply { amount = employeeDeduction.amount - attributes = employeeDeduction.attributes currency = employeeDeduction.currency name = employeeDeduction.name preTax = employeeDeduction.preTax type = employeeDeduction.type + attributes = employeeDeduction.attributes additionalProperties = employeeDeduction.additionalProperties.toMutableMap() } @@ -2279,24 +2383,6 @@ private constructor( */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - /** The deduction currency. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -2364,10 +2450,28 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun attributes(attributes: Attributes?) = + attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = + attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } fun putAdditionalProperty(key: String, value: JsonValue) = apply { additionalProperties.put(key, value) @@ -2390,15 +2494,26 @@ private constructor( * Returns an immutable instance of [EmployeeDeduction]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .name() + * .preTax() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): EmployeeDeduction = EmployeeDeduction( - amount, + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("name", name), + checkRequired("preTax", preTax), + checkRequired("type", type), attributes, - currency, - name, - preTax, - type, additionalProperties.toMutableMap(), ) } @@ -2411,11 +2526,11 @@ private constructor( } amount() - attributes().ifPresent { it.validate() } currency() name() preTax() type().ifPresent { it.validate() } + attributes().ifPresent { it.validate() } validated = true } @@ -2436,11 +2551,11 @@ private constructor( @JvmSynthetic internal fun validity(): Int = (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + (if (currency.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + (if (preTax.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) class Attributes private constructor( @@ -2456,10 +2571,11 @@ private constructor( ) : this(metadata, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): Metadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -2485,14 +2601,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Attributes]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2538,9 +2661,19 @@ private constructor( * Returns an immutable instance of [Attributes]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Attributes = - Attributes(metadata, additionalProperties.toMutableMap()) + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -2550,7 +2683,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -2589,10 +2722,11 @@ private constructor( * key-value pairs where the values can be of any type (string, number, boolean, * object, array, etc.). * - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): InnerMetadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -2618,14 +2752,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -2679,9 +2820,19 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Metadata = - Metadata(metadata, additionalProperties.toMutableMap()) + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -2691,7 +2842,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -2872,35 +3023,31 @@ private constructor( return true } - return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && attributes == other.attributes && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, name, preTax, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(amount, currency, name, preTax, type, attributes, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "EmployeeDeduction{amount=$amount, attributes=$attributes, currency=$currency, name=$name, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" + "EmployeeDeduction{amount=$amount, currency=$currency, name=$name, preTax=$preTax, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" } class EmployerContribution private constructor( - private val amount: JsonField, - private val attributes: JsonField, private val currency: JsonField, private val name: JsonField, private val type: JsonField, + private val amount: JsonField, + private val attributes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -2908,21 +3055,11 @@ private constructor( @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, name, type, mutableMapOf()) - - /** - * The contribution amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(currency, name, type, amount, attributes, mutableMapOf()) /** * The contribution currency. @@ -2949,21 +3086,18 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [amount]. + * The contribution amount in cents. * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun amount(): Optional = amount.getOptional("amount") /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes + fun attributes(): Optional = attributes.getOptional("attributes") /** * Returns the raw JSON value of [currency]. @@ -2987,6 +3121,23 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { additionalProperties.put(key, value) @@ -3003,6 +3154,13 @@ private constructor( /** * Returns a mutable builder for constructing an instance of [EmployerContribution]. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .type() + * ``` */ @JvmStatic fun builder() = Builder() } @@ -3010,63 +3168,23 @@ private constructor( /** A builder for [EmployerContribution]. */ class Builder internal constructor() { + private var currency: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null private var amount: JsonField = JsonMissing.of() private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(employerContribution: EmployerContribution) = apply { - amount = employerContribution.amount - attributes = employerContribution.attributes currency = employerContribution.currency name = employerContribution.name type = employerContribution.type + amount = employerContribution.amount + attributes = employerContribution.attributes additionalProperties = employerContribution.additionalProperties.toMutableMap() } - /** The contribution amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - /** The contribution currency. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -3112,6 +3230,46 @@ private constructor( */ fun type(type: JsonField) = apply { this.type = type } + /** The contribution amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun attributes(attributes: Attributes?) = + attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = + attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3138,14 +3296,23 @@ private constructor( * Returns an immutable instance of [EmployerContribution]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): EmployerContribution = EmployerContribution( + checkRequired("currency", currency), + checkRequired("name", name), + checkRequired("type", type), amount, attributes, - currency, - name, - type, additionalProperties.toMutableMap(), ) } @@ -3157,11 +3324,11 @@ private constructor( return@apply } - amount() - attributes().ifPresent { it.validate() } currency() name() type().ifPresent { it.validate() } + amount() + attributes().ifPresent { it.validate() } validated = true } @@ -3181,11 +3348,11 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) class Attributes private constructor( @@ -3201,10 +3368,11 @@ private constructor( ) : this(metadata, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): Metadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -3230,14 +3398,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Attributes]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3283,9 +3458,19 @@ private constructor( * Returns an immutable instance of [Attributes]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Attributes = - Attributes(metadata, additionalProperties.toMutableMap()) + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -3295,7 +3480,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -3334,10 +3519,11 @@ private constructor( * key-value pairs where the values can be of any type (string, number, boolean, * object, array, etc.). * - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): InnerMetadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -3363,14 +3549,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -3424,9 +3617,19 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Metadata = - Metadata(metadata, additionalProperties.toMutableMap()) + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -3436,7 +3639,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -3617,17 +3820,17 @@ private constructor( return true } - return /* spotless:off */ other is EmployerContribution && amount == other.amount && attributes == other.attributes && currency == other.currency && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is EmployerContribution && currency == other.currency && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(currency, name, type, amount, attributes, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "EmployerContribution{amount=$amount, attributes=$attributes, currency=$currency, name=$name, type=$type, additionalProperties=$additionalProperties}" + "EmployerContribution{currency=$currency, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" } /** The payment method. */ @@ -3770,21 +3973,17 @@ private constructor( class Tax private constructor( - private val amount: JsonField, - private val attributes: JsonField, private val currency: JsonField, private val employer: JsonField, private val name: JsonField, private val type: JsonField, + private val amount: JsonField, + private val attributes: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @@ -3793,21 +3992,11 @@ private constructor( employer: JsonField = JsonMissing.of(), @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this(amount, attributes, currency, employer, name, type, mutableMapOf()) - - /** - * The tax amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(currency, employer, name, type, amount, attributes, mutableMapOf()) /** * The currency code. @@ -3842,21 +4031,18 @@ private constructor( fun type(): Optional = type.getOptional("type") /** - * Returns the raw JSON value of [amount]. + * The tax amount in cents. * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + fun amount(): Optional = amount.getOptional("amount") /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes + fun attributes(): Optional = attributes.getOptional("attributes") /** * Returns the raw JSON value of [currency]. @@ -3888,86 +4074,73 @@ private constructor( */ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = Collections.unmodifiableMap(additionalProperties) fun toBuilder() = Builder().from(this) companion object { - /** Returns a mutable builder for constructing an instance of [Tax]. */ + /** + * Returns a mutable builder for constructing an instance of [Tax]. + * + * The following fields are required: + * ```java + * .currency() + * .employer() + * .name() + * .type() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Tax]. */ class Builder internal constructor() { + private var currency: JsonField? = null + private var employer: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null private var amount: JsonField = JsonMissing.of() private var attributes: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var employer: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tax: Tax) = apply { - amount = tax.amount - attributes = tax.attributes currency = tax.currency employer = tax.employer name = tax.name type = tax.type + amount = tax.amount + attributes = tax.attributes additionalProperties = tax.additionalProperties.toMutableMap() } - /** The tax amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - /** The currency code. */ fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) @@ -4033,85 +4206,278 @@ private constructor( * This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + fun type(type: JsonField) = apply { this.type = type } + + /** The tax amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun attributes(attributes: Attributes?) = + attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = + attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tax]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .currency() + * .employer() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tax = + Tax( + checkRequired("currency", currency), + checkRequired("employer", employer), + checkRequired("name", name), + checkRequired("type", type), + amount, + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tax = apply { + if (validated) { + return@apply + } + + currency() + employer() + name() + type().ifPresent { it.validate() } + amount() + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (if (employer.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + /** The type of taxes. */ + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val STATE = of("state") + + @JvmField val FEDERAL = of("federal") + + @JvmField val LOCAL = of("local") + + @JvmField val FICA = of("fica") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + STATE, + FEDERAL, + LOCAL, + FICA, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STATE, + FEDERAL, + LOCAL, + FICA, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STATE -> Value.STATE + FEDERAL -> Value.FEDERAL + LOCAL -> Value.LOCAL + FICA -> Value.FICA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STATE -> Known.STATE + FEDERAL -> Known.FEDERAL + LOCAL -> Known.LOCAL + FICA -> Known.FICA + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } + private var validated: Boolean = false - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) + fun validate(): Type = apply { + if (validated) { + return@apply } - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) + known() + validated = true } - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } /** - * Returns an immutable instance of [Tax]. + * Returns a score indicating how many valid values are contained in this object + * recursively. * - * Further updates to this [Builder] will not mutate the returned instance. + * Used for best match union deserialization. */ - fun build(): Tax = - Tax( - amount, - attributes, - currency, - employer, - name, - type, - additionalProperties.toMutableMap(), - ) - } + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - private var validated: Boolean = false + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - fun validate(): Tax = apply { - if (validated) { - return@apply + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ } - amount() - attributes().ifPresent { it.validate() } - currency() - employer() - name() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } + override fun hashCode() = value.hashCode() - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (employer.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + override fun toString() = value.toString() + } class Attributes private constructor( @@ -4127,10 +4493,11 @@ private constructor( ) : this(metadata, mutableMapOf()) /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): Metadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -4156,14 +4523,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Attributes]. */ + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Attributes]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4209,9 +4583,19 @@ private constructor( * Returns an immutable instance of [Attributes]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Attributes = - Attributes(metadata, additionalProperties.toMutableMap()) + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -4221,7 +4605,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -4260,10 +4644,11 @@ private constructor( * key-value pairs where the values can be of any type (string, number, boolean, * object, array, etc.). * - * @throws FinchInvalidDataException if the JSON field has an unexpected type - * (e.g. if the server responded with an unexpected value). + * @throws FinchInvalidDataException if the JSON field has an unexpected type or + * is unexpectedly missing or null (e.g. if the server responded with an + * unexpected value). */ - fun metadata(): Optional = metadata.getOptional("metadata") + fun metadata(): InnerMetadata = metadata.getRequired("metadata") /** * Returns the raw JSON value of [metadata]. @@ -4289,14 +4674,21 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Metadata]. */ + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ @JvmStatic fun builder() = Builder() } /** A builder for [Metadata]. */ class Builder internal constructor() { - private var metadata: JsonField = JsonMissing.of() + private var metadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4350,9 +4742,19 @@ private constructor( * Returns an immutable instance of [Metadata]. * * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. */ fun build(): Metadata = - Metadata(metadata, additionalProperties.toMutableMap()) + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) } private var validated: Boolean = false @@ -4362,7 +4764,7 @@ private constructor( return@apply } - metadata().ifPresent { it.validate() } + metadata().validate() validated = true } @@ -4538,165 +4940,22 @@ private constructor( "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" } - /** The type of taxes. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val STATE = of("state") - - @JvmField val FEDERAL = of("federal") - - @JvmField val LOCAL = of("local") - - @JvmField val FICA = of("fica") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - STATE, - FEDERAL, - LOCAL, - FICA, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - STATE, - FEDERAL, - LOCAL, - FICA, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - STATE -> Value.STATE - FEDERAL -> Value.FEDERAL - LOCAL -> Value.LOCAL - FICA -> Value.FICA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - STATE -> Known.STATE - FEDERAL -> Known.FEDERAL - LOCAL -> Known.LOCAL - FICA -> Known.FICA - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - override fun equals(other: Any?): Boolean { if (this === other) { return true } - return /* spotless:off */ other is Tax && amount == other.amount && attributes == other.attributes && currency == other.currency && employer == other.employer && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is Tax && currency == other.currency && employer == other.employer && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, attributes, currency, employer, name, type, additionalProperties) } + private val hashCode: Int by lazy { Objects.hash(currency, employer, name, type, amount, attributes, additionalProperties) } /* spotless:on */ override fun hashCode(): Int = hashCode override fun toString() = - "Tax{amount=$amount, attributes=$attributes, currency=$currency, employer=$employer, name=$name, type=$type, additionalProperties=$additionalProperties}" + "Tax{currency=$currency, employer=$employer, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" } /** The type of the payment associated with the pay statement. */ @@ -4714,20 +4973,20 @@ private constructor( companion object { - @JvmField val REGULAR_PAYROLL = of("regular_payroll") - @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") + @JvmField val REGULAR_PAYROLL = of("regular_payroll") + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) } /** An enum containing [Type]'s known values. */ enum class Known { - REGULAR_PAYROLL, OFF_CYCLE_PAYROLL, ONE_TIME_PAYMENT, + REGULAR_PAYROLL, } /** @@ -4740,9 +4999,9 @@ private constructor( * - It was constructed with an arbitrary value using the [of] method. */ enum class Value { - REGULAR_PAYROLL, OFF_CYCLE_PAYROLL, ONE_TIME_PAYMENT, + REGULAR_PAYROLL, /** An enum member indicating that [Type] was instantiated with an unknown value. */ _UNKNOWN, } @@ -4756,9 +5015,9 @@ private constructor( */ fun value(): Value = when (this) { - REGULAR_PAYROLL -> Value.REGULAR_PAYROLL OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Value.REGULAR_PAYROLL else -> Value._UNKNOWN } @@ -4773,9 +5032,9 @@ private constructor( */ fun known(): Known = when (this) { - REGULAR_PAYROLL -> Known.REGULAR_PAYROLL OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Known.REGULAR_PAYROLL else -> throw FinchInvalidDataException("Unknown Type: $value") } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt index 7f4ae9bc..17bf547a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/CompanyBenefitTest.kt @@ -27,7 +27,7 @@ internal class CompanyBenefitTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() assertThat(companyBenefit.benefitId()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") @@ -45,7 +45,7 @@ internal class CompanyBenefitTest { ) assertThat(companyBenefit.description()).contains("description") assertThat(companyBenefit.frequency()).contains(BenefitFrequency.ONE_TIME) - assertThat(companyBenefit.type()).contains(BenefitType._401K) + assertThat(companyBenefit.type()).contains(BenefitType._457) } @Test @@ -67,7 +67,7 @@ internal class CompanyBenefitTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() val roundtrippedCompanyBenefit = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt index 20f9ee8d..78156f0f 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt @@ -17,12 +17,6 @@ internal class EmploymentDataResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder().name("name").build() ) @@ -58,7 +52,12 @@ internal class EmploymentDataResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) @@ -76,6 +75,7 @@ internal class EmploymentDataResponseTest { .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) @@ -88,12 +88,6 @@ internal class EmploymentDataResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder().name("name").build() ) @@ -129,7 +123,12 @@ internal class EmploymentDataResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) @@ -147,6 +146,7 @@ internal class EmploymentDataResponseTest { .build() ) .sourceId("source_id") + .workId("work_id") .build() ) ) @@ -164,12 +164,6 @@ internal class EmploymentDataResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder().name("name").build() ) @@ -205,7 +199,12 @@ internal class EmploymentDataResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) @@ -223,6 +222,7 @@ internal class EmploymentDataResponseTest { .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt index 17190be2..ea01aa1c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt @@ -20,12 +20,6 @@ internal class EmploymentDataTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department(EmploymentData.UnionMember0.Department.builder().name("name").build()) .employment( EmploymentData.UnionMember0.Employment.builder() @@ -59,7 +53,12 @@ internal class EmploymentDataTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) @@ -77,6 +76,7 @@ internal class EmploymentDataTest { .build() ) .sourceId("source_id") + .workId("work_id") .build() val employmentData = EmploymentData.ofUnionMember0(unionMember0) @@ -93,12 +93,6 @@ internal class EmploymentDataTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder().name("name").build() ) @@ -134,7 +128,12 @@ internal class EmploymentDataTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) @@ -152,6 +151,7 @@ internal class EmploymentDataTest { .build() ) .sourceId("source_id") + .workId("work_id") .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt index d16fa73a..65de7bff 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisBenefitCreateParamsTest.kt @@ -23,7 +23,7 @@ internal class HrisBenefitCreateParamsTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() } @@ -44,7 +44,7 @@ internal class HrisBenefitCreateParamsTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() val body = params._body() @@ -63,7 +63,7 @@ internal class HrisBenefitCreateParamsTest { ) assertThat(body.description()).contains("description") assertThat(body.frequency()).contains(BenefitFrequency.ONE_TIME) - assertThat(body.type()).contains(BenefitType._401K) + assertThat(body.type()).contains(BenefitType._457) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt index 73041054..aca870bd 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageResponseTest.kt @@ -18,12 +18,12 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() @@ -39,12 +39,12 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() @@ -64,12 +64,12 @@ internal class HrisCompanyPayStatementItemListPageResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt index 1f2186bb..81c94a15 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt @@ -19,12 +19,6 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder() .name("name") @@ -66,7 +60,12 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) @@ -84,6 +83,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) @@ -99,12 +99,6 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder() .name("name") @@ -144,7 +138,12 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) @@ -162,6 +161,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) @@ -181,12 +181,6 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { EmploymentData.UnionMember0.builder() .id("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .classCode("class_code") - .addCustomField( - EmploymentData.UnionMember0.CustomField.builder() - .name("name") - .value("string") - .build() - ) .department( EmploymentData.UnionMember0.Department.builder() .name("name") @@ -228,7 +222,12 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .middleName("middle_name") .startDate("start_date") .title("title") - .workId("work_id") + .addCustomField( + EmploymentData.UnionMember0.CustomField.builder() + .name("name") + .value("string") + .build() + ) .income( Income.builder() .amount(0L) @@ -246,6 +245,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { .build() ) .sourceId("source_id") + .workId("work_id") .build() ) .code(0L) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt index 21ccd032..7f6f032d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt @@ -17,20 +17,49 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .addResponse( PayStatementResponse.builder() .body( - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + PayStatementResponseBody.UnionMember0.builder() + .paging( + PayStatementResponseBody.UnionMember0.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( - PayStatement.builder() + PayStatementResponseBody.UnionMember0.PayStatement.builder() .addEarning( - PayStatement.Earning.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Type + .SALARY + ) .attributes( - PayStatement.Earning.Attributes.builder() + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .builder() .metadata( - PayStatement.Earning.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata .builder() .metadata( - PayStatement.Earning.Attributes + PayStatementResponseBody + .UnionMember0 + .PayStatement + .Earning + .Attributes .Metadata .InnerMetadata .builder() @@ -46,25 +75,35 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .builder() .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( - PayStatement.EmployeeDeduction.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes .builder() .metadata( - PayStatement.EmployeeDeduction + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction .Attributes .Metadata .builder() .metadata( - PayStatement.EmployeeDeduction + PayStatementResponseBody + .UnionMember0 + .PayStatement + .EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -81,25 +120,33 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( - PayStatement.EmployerContribution.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes .builder() .metadata( - PayStatement.EmployerContribution + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution .Attributes .Metadata .builder() .metadata( - PayStatement + PayStatementResponseBody + .UnionMember0 + .PayStatement .EmployerContribution .Attributes .Metadata @@ -117,9 +164,6 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay( @@ -129,17 +173,44 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .netPay( Money.builder().amount(0L).currency("currency").build() ) - .paymentMethod(PayStatement.PaymentMethod.CHECK) + .paymentMethod( + PayStatementResponseBody.UnionMember0.PayStatement + .PaymentMethod + .CHECK + ) .addTax( - PayStatement.Tax.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .builder() + .currency("currency") + .employer(true) + .name("name") + .type( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Type + .STATE + ) .amount(0L) .attributes( - PayStatement.Tax.Attributes.builder() + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata .builder() .metadata( - PayStatement.Tax.Attributes + PayStatementResponseBody + .UnionMember0 + .PayStatement + .Tax + .Attributes .Metadata .InnerMetadata .builder() @@ -155,14 +226,13 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Type + .OFF_CYCLE_PAYROLL + ) .build() ) .build() @@ -177,20 +247,46 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .containsExactly( PayStatementResponse.builder() .body( - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + PayStatementResponseBody.UnionMember0.builder() + .paging( + PayStatementResponseBody.UnionMember0.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( - PayStatement.builder() + PayStatementResponseBody.UnionMember0.PayStatement.builder() .addEarning( - PayStatement.Earning.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Earning + .builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Type + .SALARY + ) .attributes( - PayStatement.Earning.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Attributes + .builder() .metadata( - PayStatement.Earning.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata .builder() .metadata( - PayStatement.Earning.Attributes + PayStatementResponseBody + .UnionMember0 + .PayStatement + .Earning + .Attributes .Metadata .InnerMetadata .builder() @@ -206,23 +302,34 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .builder() .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .Attributes + .builder() .metadata( - PayStatement.EmployeeDeduction.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes .Metadata .builder() .metadata( - PayStatement.EmployeeDeduction + PayStatementResponseBody + .UnionMember0 + .PayStatement + .EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -239,24 +346,33 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( - PayStatement.EmployerContribution.Attributes + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .Attributes .builder() .metadata( - PayStatement.EmployerContribution.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes .Metadata .builder() .metadata( - PayStatement.EmployerContribution + PayStatementResponseBody + .UnionMember0 + .PayStatement + .EmployerContribution .Attributes .Metadata .InnerMetadata @@ -273,9 +389,6 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay( @@ -283,17 +396,43 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) + .paymentMethod( + PayStatementResponseBody.UnionMember0.PayStatement + .PaymentMethod + .CHECK + ) .addTax( - PayStatement.Tax.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .builder() + .currency("currency") + .employer(true) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement + .Tax + .Type + .STATE + ) .amount(0L) .attributes( - PayStatement.Tax.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .Tax + .Attributes + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata .builder() .metadata( - PayStatement.Tax.Attributes.Metadata + PayStatementResponseBody + .UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -308,14 +447,13 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Type + .OFF_CYCLE_PAYROLL + ) .build() ) .build() @@ -334,20 +472,49 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .addResponse( PayStatementResponse.builder() .body( - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + PayStatementResponseBody.UnionMember0.builder() + .paging( + PayStatementResponseBody.UnionMember0.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( - PayStatement.builder() + PayStatementResponseBody.UnionMember0.PayStatement.builder() .addEarning( - PayStatement.Earning.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Type + .SALARY + ) .attributes( - PayStatement.Earning.Attributes.builder() + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .builder() .metadata( - PayStatement.Earning.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata .builder() .metadata( - PayStatement.Earning.Attributes + PayStatementResponseBody + .UnionMember0 + .PayStatement + .Earning + .Attributes .Metadata .InnerMetadata .builder() @@ -363,25 +530,35 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .builder() .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( - PayStatement.EmployeeDeduction.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes .builder() .metadata( - PayStatement.EmployeeDeduction + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction .Attributes .Metadata .builder() .metadata( - PayStatement.EmployeeDeduction + PayStatementResponseBody + .UnionMember0 + .PayStatement + .EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -398,25 +575,33 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( - PayStatement.EmployerContribution.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes .builder() .metadata( - PayStatement.EmployerContribution + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution .Attributes .Metadata .builder() .metadata( - PayStatement + PayStatementResponseBody + .UnionMember0 + .PayStatement .EmployerContribution .Attributes .Metadata @@ -434,9 +619,6 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay( @@ -446,17 +628,44 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .netPay( Money.builder().amount(0L).currency("currency").build() ) - .paymentMethod(PayStatement.PaymentMethod.CHECK) + .paymentMethod( + PayStatementResponseBody.UnionMember0.PayStatement + .PaymentMethod + .CHECK + ) .addTax( - PayStatement.Tax.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .builder() + .currency("currency") + .employer(true) + .name("name") + .type( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Type + .STATE + ) .amount(0L) .attributes( - PayStatement.Tax.Attributes.builder() + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata .builder() .metadata( - PayStatement.Tax.Attributes + PayStatementResponseBody + .UnionMember0 + .PayStatement + .Tax + .Attributes .Metadata .InnerMetadata .builder() @@ -472,14 +681,13 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Type + .OFF_CYCLE_PAYROLL + ) .build() ) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/MoneyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/MoneyTest.kt index 76045e09..a9e57056 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/MoneyTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/MoneyTest.kt @@ -14,7 +14,7 @@ internal class MoneyTest { val money = Money.builder().amount(0L).currency("currency").build() assertThat(money.amount()).contains(0L) - assertThat(money.currency()).contains("currency") + assertThat(money.currency()).isEqualTo("currency") } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupListResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupListResponseTest.kt index e696a7ea..a0cd4fb7 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupListResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayGroupListResponseTest.kt @@ -4,7 +4,6 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -19,9 +18,9 @@ internal class PayGroupListResponseTest { .addPayFrequency(PayGroupListResponse.PayFrequency.ANNUALLY) .build() - assertThat(payGroupListResponse.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") - assertThat(payGroupListResponse.name()).contains("name") - assertThat(payGroupListResponse.payFrequencies().getOrNull()) + assertThat(payGroupListResponse.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(payGroupListResponse.name()).isEqualTo("name") + assertThat(payGroupListResponse.payFrequencies()) .containsExactly(PayGroupListResponse.PayFrequency.ANNUALLY) } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt index 56558e40..332a3257 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementItemListResponseTest.kt @@ -16,12 +16,12 @@ internal class PayStatementItemListResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() @@ -31,21 +31,21 @@ internal class PayStatementItemListResponseTest { .build() assertThat(payStatementItemListResponse.attributes()) - .contains( + .isEqualTo( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() ) assertThat(payStatementItemListResponse.category()) - .contains(PayStatementItemListResponse.Category.EARNINGS) - assertThat(payStatementItemListResponse.name()).contains("name") + .isEqualTo(PayStatementItemListResponse.Category.EARNINGS) + assertThat(payStatementItemListResponse.name()).isEqualTo("name") } @Test @@ -55,12 +55,12 @@ internal class PayStatementItemListResponseTest { PayStatementItemListResponse.builder() .attributes( PayStatementItemListResponse.Attributes.builder() - .employer(true) .metadata( PayStatementItemListResponse.Attributes.Metadata.builder() .putAdditionalProperty("foo", JsonValue.from("bar")) .build() ) + .employer(true) .preTax(true) .type("type") .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt index 40b61151..44cb939a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt @@ -5,28 +5,53 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull +import com.tryfinch.api.errors.FinchInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource internal class PayStatementResponseBodyTest { @Test - fun create() { - val payStatementResponseBody = - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + fun ofUnionMember0() { + val unionMember0 = + PayStatementResponseBody.UnionMember0.builder() + .paging( + PayStatementResponseBody.UnionMember0.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( - PayStatement.builder() + PayStatementResponseBody.UnionMember0.PayStatement.builder() .addEarning( - PayStatement.Earning.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Earning.Type + .SALARY + ) .attributes( - PayStatement.Earning.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Earning + .Attributes + .builder() .metadata( - PayStatement.Earning.Attributes.Metadata.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Attributes + .Metadata + .builder() .metadata( - PayStatement.Earning.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -39,22 +64,32 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + PayStatementResponseBody.UnionMember0.PayStatement.EmployeeDeduction + .builder() .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .Attributes + .builder() .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .Attributes + .Metadata .builder() .metadata( - PayStatement.EmployeeDeduction.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes .Metadata .InnerMetadata .builder() @@ -68,22 +103,31 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() + PayStatementResponseBody.UnionMember0.PayStatement.EmployerContribution + .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( - PayStatement.EmployerContribution.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .Attributes + .builder() .metadata( - PayStatement.EmployerContribution.Attributes.Metadata + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .Attributes + .Metadata .builder() .metadata( - PayStatement.EmployerContribution.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes .Metadata .InnerMetadata .builder() @@ -97,24 +141,39 @@ internal class PayStatementResponseBodyTest { ) .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) + .paymentMethod( + PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod.CHECK + ) .addTax( - PayStatement.Tax.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Tax.Type + .STATE + ) .amount(0L) .attributes( - PayStatement.Tax.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Attributes + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Attributes + .Metadata + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -127,37 +186,72 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Type + .OFF_CYCLE_PAYROLL + ) .build() ) .build() - assertThat(payStatementResponseBody.paging()) - .contains(Paging.builder().offset(0L).count(0L).build()) - assertThat(payStatementResponseBody.payStatements().getOrNull()) - .containsExactly( - PayStatement.builder() - .addEarning( - PayStatement.Earning.builder() - .amount(0L) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() + val payStatementResponseBody = PayStatementResponseBody.ofUnionMember0(unionMember0) + + assertThat(payStatementResponseBody.unionMember0()).contains(unionMember0) + assertThat(payStatementResponseBody.batchError()).isEmpty + assertThat(payStatementResponseBody.unionMember2()).isEmpty + } + + @Test + fun ofUnionMember0Roundtrip() { + val jsonMapper = jsonMapper() + val payStatementResponseBody = + PayStatementResponseBody.ofUnionMember0( + PayStatementResponseBody.UnionMember0.builder() + .paging( + PayStatementResponseBody.UnionMember0.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) + .addPayStatement( + PayStatementResponseBody.UnionMember0.PayStatement.builder() + .addEarning( + PayStatementResponseBody.UnionMember0.PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Earning + .Type + .SALARY + ) + .attributes( + PayStatementResponseBody.UnionMember0.PayStatement.Earning + .Attributes + .builder() .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Attributes + .Metadata .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() ) .build() ) @@ -165,26 +259,38 @@ internal class PayStatementResponseBodyTest { ) .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() + .addEmployeeDeduction( + PayStatementResponseBody.UnionMember0.PayStatement.EmployeeDeduction + .builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) + .attributes( + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .Attributes + .builder() .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .Attributes + .Metadata .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() ) .build() ) @@ -192,28 +298,38 @@ internal class PayStatementResponseBodyTest { ) .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 + .addEmployerContribution( + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) + .amount(0L) + .attributes( + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .Attributes .builder() .metadata( - PayStatement.EmployerContribution.Attributes + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .Attributes .Metadata - .InnerMetadata .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() ) .build() ) @@ -221,28 +337,46 @@ internal class PayStatementResponseBodyTest { ) .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() + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod( + PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod + .CHECK + ) + .addTax( + PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Tax.Type + .STATE + ) + .amount(0L) + .attributes( + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Attributes + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata + PayStatementResponseBody.UnionMember0.PayStatement + .Tax + .Attributes + .Metadata .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() ) .build() ) @@ -250,147 +384,102 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) + .totalHours(0.0) + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Type + .OFF_CYCLE_PAYROLL + ) .build() ) - .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) .build() ) + + val roundtrippedPayStatementResponseBody = + jsonMapper.readValue( + jsonMapper.writeValueAsString(payStatementResponseBody), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPayStatementResponseBody).isEqualTo(payStatementResponseBody) + } + + @Test + fun ofBatchError() { + val batchError = + PayStatementResponseBody.BatchError.builder() + .code(0.0) + .message("message") + .name("name") + .finchCode("finch_code") + .build() + + val payStatementResponseBody = PayStatementResponseBody.ofBatchError(batchError) + + assertThat(payStatementResponseBody.unionMember0()).isEmpty + assertThat(payStatementResponseBody.batchError()).contains(batchError) + assertThat(payStatementResponseBody.unionMember2()).isEmpty } @Test - fun roundtrip() { + fun ofBatchErrorRoundtrip() { val jsonMapper = jsonMapper() val payStatementResponseBody = - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) - .addPayStatement( - PayStatement.builder() - .addEarning( - PayStatement.Earning.builder() - .amount(0L) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) - .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) - .addTax( - PayStatement.Tax.builder() - .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) - .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) - .build() + PayStatementResponseBody.ofBatchError( + PayStatementResponseBody.BatchError.builder() + .code(0.0) + .message("message") + .name("name") + .finchCode("finch_code") + .build() + ) + + val roundtrippedPayStatementResponseBody = + jsonMapper.readValue( + jsonMapper.writeValueAsString(payStatementResponseBody), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPayStatementResponseBody).isEqualTo(payStatementResponseBody) + } + + @Test + fun ofUnionMember2() { + val unionMember2 = + PayStatementResponseBody.UnionMember2.builder() + .code(PayStatementResponseBody.UnionMember2.Code._202) + .finchCode(PayStatementResponseBody.UnionMember2.FinchCode.DATA_SYNC_IN_PROGRESS) + .message( + PayStatementResponseBody.UnionMember2.Message + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER ) + .name(PayStatementResponseBody.UnionMember2.Name.ACCEPTED) .build() + val payStatementResponseBody = PayStatementResponseBody.ofUnionMember2(unionMember2) + + assertThat(payStatementResponseBody.unionMember0()).isEmpty + assertThat(payStatementResponseBody.batchError()).isEmpty + assertThat(payStatementResponseBody.unionMember2()).contains(unionMember2) + } + + @Test + fun ofUnionMember2Roundtrip() { + val jsonMapper = jsonMapper() + val payStatementResponseBody = + PayStatementResponseBody.ofUnionMember2( + PayStatementResponseBody.UnionMember2.builder() + .code(PayStatementResponseBody.UnionMember2.Code._202) + .finchCode( + PayStatementResponseBody.UnionMember2.FinchCode.DATA_SYNC_IN_PROGRESS + ) + .message( + PayStatementResponseBody.UnionMember2.Message + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + ) + .name(PayStatementResponseBody.UnionMember2.Name.ACCEPTED) + .build() + ) + val roundtrippedPayStatementResponseBody = jsonMapper.readValue( jsonMapper.writeValueAsString(payStatementResponseBody), @@ -399,4 +488,22 @@ internal class PayStatementResponseBodyTest { assertThat(roundtrippedPayStatementResponseBody).isEqualTo(payStatementResponseBody) } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val payStatementResponseBody = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { payStatementResponseBody.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt index b436711a..0812b768 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt @@ -15,20 +15,46 @@ internal class PayStatementResponseTest { val payStatementResponse = PayStatementResponse.builder() .body( - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + PayStatementResponseBody.UnionMember0.builder() + .paging( + PayStatementResponseBody.UnionMember0.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( - PayStatement.builder() + PayStatementResponseBody.UnionMember0.PayStatement.builder() .addEarning( - PayStatement.Earning.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Earning + .builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Type + .SALARY + ) .attributes( - PayStatement.Earning.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Attributes + .builder() .metadata( - PayStatement.Earning.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata .builder() .metadata( - PayStatement.Earning.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -43,23 +69,33 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .builder() .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .Attributes + .builder() .metadata( - PayStatement.EmployeeDeduction.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes .Metadata .builder() .metadata( - PayStatement.EmployeeDeduction + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -76,23 +112,32 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( - PayStatement.EmployerContribution.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .Attributes + .builder() .metadata( - PayStatement.EmployerContribution.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes .Metadata .builder() .metadata( - PayStatement.EmployerContribution + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution .Attributes .Metadata .InnerMetadata @@ -109,24 +154,43 @@ internal class PayStatementResponseTest { ) .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) + .paymentMethod( + PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod + .CHECK + ) .addTax( - PayStatement.Tax.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Type + .STATE + ) .amount(0L) .attributes( - PayStatement.Tax.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Attributes + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata.builder() + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -141,14 +205,13 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Type + .OFF_CYCLE_PAYROLL + ) .build() ) .build() @@ -158,135 +221,212 @@ internal class PayStatementResponseTest { .build() assertThat(payStatementResponse.body()) - .contains( - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) - .addPayStatement( - PayStatement.builder() - .addEarning( - PayStatement.Earning.builder() - .amount(0L) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) - .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) - .addTax( - PayStatement.Tax.builder() - .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) - .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) - .build() - ) - .build() + .isEqualTo( + PayStatementResponseBody.ofUnionMember0( + PayStatementResponseBody.UnionMember0.builder() + .paging( + PayStatementResponseBody.UnionMember0.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) + .addPayStatement( + PayStatementResponseBody.UnionMember0.PayStatement.builder() + .addEarning( + PayStatementResponseBody.UnionMember0.PayStatement.Earning + .builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Type + .SALARY + ) + .attributes( + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Attributes + .builder() + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata + .builder() + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployeeDeduction( + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) + .attributes( + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .Attributes + .builder() + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes + .Metadata + .builder() + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployerContribution( + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) + .amount(0L) + .attributes( + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .Attributes + .builder() + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes + .Metadata + .builder() + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod( + PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod + .CHECK + ) + .addTax( + PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Type + .STATE + ) + .amount(0L) + .attributes( + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Attributes + .builder() + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata + .builder() + .metadata( + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from( + mapOf() + ), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .totalHours(0.0) + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Type + .OFF_CYCLE_PAYROLL + ) + .build() + ) + .build() + ) ) - assertThat(payStatementResponse.code()).contains(0L) - assertThat(payStatementResponse.paymentId()).contains("payment_id") + assertThat(payStatementResponse.code()).isEqualTo(0L) + assertThat(payStatementResponse.paymentId()).isEqualTo("payment_id") } @Test @@ -295,20 +435,46 @@ internal class PayStatementResponseTest { val payStatementResponse = PayStatementResponse.builder() .body( - PayStatementResponseBody.builder() - .paging(Paging.builder().offset(0L).count(0L).build()) + PayStatementResponseBody.UnionMember0.builder() + .paging( + PayStatementResponseBody.UnionMember0.Paging.builder() + .offset(0L) + .count(0L) + .build() + ) .addPayStatement( - PayStatement.builder() + PayStatementResponseBody.UnionMember0.PayStatement.builder() .addEarning( - PayStatement.Earning.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Earning + .builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Type + .SALARY + ) .attributes( - PayStatement.Earning.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .Earning + .Attributes + .builder() .metadata( - PayStatement.Earning.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata .builder() .metadata( - PayStatement.Earning.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Earning + .Attributes + .Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -323,23 +489,33 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .builder() .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployeeDeduction + .Attributes + .builder() .metadata( - PayStatement.EmployeeDeduction.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction + .Attributes .Metadata .builder() .metadata( - PayStatement.EmployeeDeduction + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -356,23 +532,32 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( - PayStatement.EmployerContribution.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement + .EmployerContribution + .Attributes + .builder() .metadata( - PayStatement.EmployerContribution.Attributes + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution + .Attributes .Metadata .builder() .metadata( - PayStatement.EmployerContribution + PayStatementResponseBody.UnionMember0 + .PayStatement + .EmployerContribution .Attributes .Metadata .InnerMetadata @@ -389,24 +574,43 @@ internal class PayStatementResponseTest { ) .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) + .paymentMethod( + PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod + .CHECK + ) .addTax( - PayStatement.Tax.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Type + .STATE + ) .amount(0L) .attributes( - PayStatement.Tax.Attributes.builder() + PayStatementResponseBody.UnionMember0.PayStatement.Tax + .Attributes + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata.builder() + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata + .builder() .metadata( - PayStatement.Tax.Attributes.Metadata + PayStatementResponseBody.UnionMember0 + .PayStatement + .Tax + .Attributes + .Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -421,14 +625,13 @@ internal class PayStatementResponseTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) + .type( + PayStatementResponseBody.UnionMember0.PayStatement.Type + .OFF_CYCLE_PAYROLL + ) .build() ) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt deleted file mode 100644 index 3724bb43..00000000 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt +++ /dev/null @@ -1,375 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.tryfinch.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class PayStatementTest { - - @Test - fun create() { - val payStatement = - PayStatement.builder() - .addEarning( - PayStatement.Earning.builder() - .amount(0L) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) - .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) - .addTax( - PayStatement.Tax.builder() - .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) - .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) - .build() - - assertThat(payStatement.earnings().getOrNull()) - .containsExactly( - PayStatement.Earning.builder() - .amount(0L) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) - assertThat(payStatement.employeeDeductions().getOrNull()) - .containsExactly( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - assertThat(payStatement.employerContributions().getOrNull()) - .containsExactly( - PayStatement.EmployerContribution.builder() - .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - assertThat(payStatement.grossPay()) - .contains(Money.builder().amount(0L).currency("currency").build()) - assertThat(payStatement.individualId()).contains("individual_id") - assertThat(payStatement.netPay()) - .contains(Money.builder().amount(0L).currency("currency").build()) - assertThat(payStatement.paymentMethod()).contains(PayStatement.PaymentMethod.CHECK) - assertThat(payStatement.taxes().getOrNull()) - .containsExactly( - PayStatement.Tax.builder() - .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata.builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) - assertThat(payStatement.totalHours()).contains(0.0) - assertThat(payStatement.type()).contains(PayStatement.Type.REGULAR_PAYROLL) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val payStatement = - PayStatement.builder() - .addEarning( - PayStatement.Earning.builder() - .amount(0L) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .build() - ) - .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() - .amount(0L) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._401K) - .build() - ) - .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .name("name") - .type(BenefitType._401K) - .build() - ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) - .addTax( - PayStatement.Tax.builder() - .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) - .build() - ) - .totalHours(0.0) - .type(PayStatement.Type.REGULAR_PAYROLL) - .build() - - val roundtrippedPayStatement = - jsonMapper.readValue( - jsonMapper.writeValueAsString(payStatement), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPayStatement).isEqualTo(payStatement) - } -} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PaymentTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PaymentTest.kt index fce8572b..c21eb02e 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PaymentTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PaymentTest.kt @@ -30,7 +30,7 @@ internal class PaymentTest { ) .build() - assertThat(payment.id()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(payment.id()).isEqualTo("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") assertThat(payment.companyDebit()) .contains(Money.builder().amount(0L).currency("currency").build()) assertThat(payment.debitDate()).contains("debit_date") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt index 0f9cfcf9..688d6937 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt @@ -18,6 +18,10 @@ internal class SandboxPaymentCreateParamsTest { .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) .attributes( SandboxPaymentCreateParams.PayStatement.Earning.Attributes.builder() .metadata( @@ -40,15 +44,15 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes .builder() @@ -74,14 +78,13 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployerContribution @@ -109,17 +112,18 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() @@ -143,14 +147,10 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .startDate("start_date") @@ -167,6 +167,10 @@ internal class SandboxPaymentCreateParamsTest { .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) .attributes( SandboxPaymentCreateParams.PayStatement.Earning.Attributes .builder() @@ -191,15 +195,15 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -227,14 +231,13 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployerContribution @@ -263,17 +266,18 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() @@ -297,14 +301,10 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .startDate("start_date") @@ -319,6 +319,10 @@ internal class SandboxPaymentCreateParamsTest { .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) .attributes( SandboxPaymentCreateParams.PayStatement.Earning.Attributes.builder() .metadata( @@ -341,15 +345,15 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes .builder() @@ -375,14 +379,13 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployerContribution @@ -410,17 +413,18 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() @@ -444,14 +448,10 @@ internal class SandboxPaymentCreateParamsTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) assertThat(body.startDate()).contains("start_date") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt index 9d4af287..99d7b0e9 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncTest.kt @@ -42,7 +42,7 @@ internal class BenefitServiceAsyncTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt index fc235e7b..ef9568d4 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt @@ -32,6 +32,12 @@ internal class PaymentServiceAsyncTest { .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY + ) .attributes( SandboxPaymentCreateParams.PayStatement.Earning.Attributes .builder() @@ -57,17 +63,15 @@ internal class PaymentServiceAsyncTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY - ) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -95,15 +99,14 @@ internal class PaymentServiceAsyncTest { ) .build() ) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployerContribution @@ -132,19 +135,20 @@ internal class PaymentServiceAsyncTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod( SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK ) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.Tax.Attributes @@ -170,14 +174,10 @@ internal class PaymentServiceAsyncTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .startDate("start_date") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt index ff54482a..334986ff 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceTest.kt @@ -42,7 +42,7 @@ internal class BenefitServiceTest { ) .description("description") .frequency(BenefitFrequency.ONE_TIME) - .type(BenefitType._401K) + .type(BenefitType._457) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt index 1a8dba8b..f95640aa 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt @@ -32,6 +32,12 @@ internal class PaymentServiceTest { .addEarning( SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type( + SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY + ) .attributes( SandboxPaymentCreateParams.PayStatement.Earning.Attributes .builder() @@ -57,17 +63,15 @@ internal class PaymentServiceTest { ) .build() ) - .currency("currency") - .hours(0.0) - .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY - ) .build() ) .addEmployeeDeduction( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() - .amount(2000L) + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) .attributes( SandboxPaymentCreateParams.PayStatement.EmployeeDeduction .Attributes @@ -95,15 +99,14 @@ internal class PaymentServiceTest { ) .build() ) - .currency("usd") - .name("401k test") - .preTax(true) - .type(BenefitType._401K) .build() ) .addEmployerContribution( SandboxPaymentCreateParams.PayStatement.EmployerContribution .builder() + .currency("currency") + .name("name") + .type(BenefitType._457) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.EmployerContribution @@ -132,19 +135,20 @@ internal class PaymentServiceTest { ) .build() ) - .currency("currency") - .name("name") - .type(BenefitType._401K) .build() ) .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("b2338cfb-472f-4f72-9faa-e028c083144a") + .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) .paymentMethod( SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK ) .addTax( SandboxPaymentCreateParams.PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .amount(0L) .attributes( SandboxPaymentCreateParams.PayStatement.Tax.Attributes @@ -170,14 +174,10 @@ internal class PaymentServiceTest { ) .build() ) - .currency("currency") - .employer(true) - .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.REGULAR_PAYROLL) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .startDate("start_date") From 3bf7c8351c4b0429cea1da737e6ca12e10536e3c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 12:28:17 +0000 Subject: [PATCH 04/26] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 739ef65d..326eb9f3 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-5b7ee4cddd08558fb0cc5010d36899c0bbe5d6a8d39c8171f65b70b68927df3c.yml -openapi_spec_hash: c01482dc89e9bf7ae4c9dad0fb547e62 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bee51b1baafbccc6806b5165e0ed78ecf537826794fe15ceb0141897c73d8b8a.yml +openapi_spec_hash: 12440ed643b40a8690740b6b16ad410a config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 4cda84cda5643a2f85c5c19c79fb4eb6a7b49daf Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 23 May 2025 22:17:47 +0000 Subject: [PATCH 05/26] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 326eb9f3..98eb96ba 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bee51b1baafbccc6806b5165e0ed78ecf537826794fe15ceb0141897c73d8b8a.yml -openapi_spec_hash: 12440ed643b40a8690740b6b16ad410a +openapi_spec_hash: 5017bc383c3a779ccbc2d9b6d93b26b4 config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 From 8cfd398b763a91364e372a22d3bf7a8f62419191 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 27 May 2025 13:26:00 +0000 Subject: [PATCH 06/26] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 98eb96ba..3a00091a 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bee51b1baafbccc6806b5165e0ed78ecf537826794fe15ceb0141897c73d8b8a.yml openapi_spec_hash: 5017bc383c3a779ccbc2d9b6d93b26b4 -config_hash: 53778a0b839c4f6ad34fbba051f5e8a6 +config_hash: acf5ff659c4400f8c6ee5a2488a83904 From b0f69c49f1e0e9abfea316da092bfc8d0ec221d4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 27 May 2025 16:10:44 +0000 Subject: [PATCH 07/26] codegen metadata --- .stats.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 3a00091a..7e4f582f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-bee51b1baafbccc6806b5165e0ed78ecf537826794fe15ceb0141897c73d8b8a.yml -openapi_spec_hash: 5017bc383c3a779ccbc2d9b6d93b26b4 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-fb9ba13b8189c4223972e38677ea301c3121358e88fbfc9e4ec95ea5cc92f530.yml +openapi_spec_hash: 7bd02ce73505e51c5fd78608fed55c62 config_hash: acf5ff659c4400f8c6ee5a2488a83904 From 6c2f07f7ce293abdf78dd6584111eb1fcb6b7b52 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 28 May 2025 15:58:41 +0000 Subject: [PATCH 08/26] chore(tests): skip endpoints with basic auth --- .stats.yml | 4 ++-- .../api/services/async/connect/SessionServiceAsyncTest.kt | 3 +++ .../api/services/async/sandbox/ConnectionServiceAsyncTest.kt | 2 ++ .../async/sandbox/connections/AccountServiceAsyncTest.kt | 2 ++ .../api/services/blocking/connect/SessionServiceTest.kt | 3 +++ .../api/services/blocking/sandbox/ConnectionServiceTest.kt | 2 ++ .../blocking/sandbox/connections/AccountServiceTest.kt | 2 ++ 7 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.stats.yml b/.stats.yml index 7e4f582f..0fe808d1 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-fb9ba13b8189c4223972e38677ea301c3121358e88fbfc9e4ec95ea5cc92f530.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-1a82d3230c420c8562600b0ad45133d79ab68ffd21d524ab26eef11e163dba09.yml openapi_spec_hash: 7bd02ce73505e51c5fd78608fed55c62 -config_hash: acf5ff659c4400f8c6ee5a2488a83904 +config_hash: 81eb5297df860cf29f8c5bdbf9f89608 diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncTest.kt index 05610d63..78721b51 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncTest.kt @@ -6,12 +6,14 @@ import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SessionServiceAsyncTest { + @Disabled("prism tests are broken") @Test fun new_() { val client = @@ -45,6 +47,7 @@ internal class SessionServiceAsyncTest { response.validate() } + @Disabled("prism tests are broken") @Test fun reauthenticate() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncTest.kt index 197e0ec5..d0051d2b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncTest.kt @@ -5,12 +5,14 @@ package com.tryfinch.api.services.async.sandbox import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.SandboxConnectionCreateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ConnectionServiceAsyncTest { + @Disabled("prism tests are broken") @Test fun create() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncTest.kt index c45deebb..317d3121 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncTest.kt @@ -7,12 +7,14 @@ import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.models.ConnectionStatusType import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AccountServiceAsyncTest { + @Disabled("prism tests are broken") @Test fun create() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceTest.kt index 276f3066..31ee69fa 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceTest.kt @@ -6,12 +6,14 @@ import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class SessionServiceTest { + @Disabled("prism tests are broken") @Test fun new_() { val client = @@ -44,6 +46,7 @@ internal class SessionServiceTest { response.validate() } + @Disabled("prism tests are broken") @Test fun reauthenticate() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceTest.kt index af59feec..35591a08 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceTest.kt @@ -5,12 +5,14 @@ package com.tryfinch.api.services.blocking.sandbox import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.SandboxConnectionCreateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class ConnectionServiceTest { + @Disabled("prism tests are broken") @Test fun create() { val client = diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceTest.kt index 5cf6c67d..fdd7ec31 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceTest.kt @@ -7,12 +7,14 @@ import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.models.ConnectionStatusType import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams +import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @ExtendWith(TestServerExtension::class) internal class AccountServiceTest { + @Disabled("prism tests are broken") @Test fun create() { val client = From 17cef164e3b1da2ee49ed2c8e134bc3b2ff22e18 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 29 May 2025 02:02:09 +0000 Subject: [PATCH 09/26] fix(client): remove `@MustBeClosed` for future returning methods --- .../services/async/AccessTokenServiceAsync.kt | 3 --- .../api/services/async/AccountServiceAsync.kt | 9 ------- .../services/async/ProviderServiceAsync.kt | 5 ---- .../async/RequestForwardingServiceAsync.kt | 3 --- .../async/connect/SessionServiceAsync.kt | 5 ---- .../async/hris/BenefitServiceAsync.kt | 25 ------------------- .../async/hris/CompanyServiceAsync.kt | 5 ---- .../async/hris/DirectoryServiceAsync.kt | 9 ------- .../async/hris/DocumentServiceAsync.kt | 11 -------- .../async/hris/EmploymentServiceAsync.kt | 3 --- .../async/hris/IndividualServiceAsync.kt | 5 ---- .../async/hris/PayStatementServiceAsync.kt | 3 --- .../async/hris/PaymentServiceAsync.kt | 3 --- .../hris/benefits/IndividualServiceAsync.kt | 19 -------------- .../company/PayStatementItemServiceAsync.kt | 5 ---- .../payStatementItem/RuleServiceAsync.kt | 21 ---------------- .../async/jobs/AutomatedServiceAsync.kt | 15 ----------- .../services/async/jobs/ManualServiceAsync.kt | 7 ------ .../async/payroll/PayGroupServiceAsync.kt | 11 -------- .../async/sandbox/CompanyServiceAsync.kt | 3 --- .../async/sandbox/ConnectionServiceAsync.kt | 3 --- .../async/sandbox/DirectoryServiceAsync.kt | 5 ---- .../async/sandbox/EmploymentServiceAsync.kt | 7 ------ .../async/sandbox/IndividualServiceAsync.kt | 7 ------ .../services/async/sandbox/JobServiceAsync.kt | 3 --- .../async/sandbox/PaymentServiceAsync.kt | 5 ---- .../connections/AccountServiceAsync.kt | 7 ------ .../sandbox/jobs/ConfigurationServiceAsync.kt | 7 ------ 28 files changed, 214 deletions(-) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt index 7dd0db87..4857cd1e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccessTokenCreateParams @@ -36,14 +35,12 @@ interface AccessTokenServiceAsync { * Returns a raw HTTP response for `post /auth/token`, but is otherwise the same as * [AccessTokenServiceAsync.create]. */ - @MustBeClosed fun create( params: AccessTokenCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: AccessTokenCreateParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt index 787a514b..78f646be 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountDisconnectParams @@ -64,26 +63,22 @@ interface AccountServiceAsync { * Returns a raw HTTP response for `post /disconnect`, but is otherwise the same as * [AccountServiceAsync.disconnect]. */ - @MustBeClosed fun disconnect(): CompletableFuture> = disconnect(AccountDisconnectParams.none()) /** @see [disconnect] */ - @MustBeClosed fun disconnect( params: AccountDisconnectParams = AccountDisconnectParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [disconnect] */ - @MustBeClosed fun disconnect( params: AccountDisconnectParams = AccountDisconnectParams.none() ): CompletableFuture> = disconnect(params, RequestOptions.none()) /** @see [disconnect] */ - @MustBeClosed fun disconnect( requestOptions: RequestOptions ): CompletableFuture> = @@ -93,26 +88,22 @@ interface AccountServiceAsync { * Returns a raw HTTP response for `get /introspect`, but is otherwise the same as * [AccountServiceAsync.introspect]. */ - @MustBeClosed fun introspect(): CompletableFuture> = introspect(AccountIntrospectParams.none()) /** @see [introspect] */ - @MustBeClosed fun introspect( params: AccountIntrospectParams = AccountIntrospectParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [introspect] */ - @MustBeClosed fun introspect( params: AccountIntrospectParams = AccountIntrospectParams.none() ): CompletableFuture> = introspect(params, RequestOptions.none()) /** @see [introspect] */ - @MustBeClosed fun introspect( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt index 4f112fda..a7ff5368 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ProviderListPageAsync @@ -43,26 +42,22 @@ interface ProviderServiceAsync { * Returns a raw HTTP response for `get /providers`, but is otherwise the same as * [ProviderServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(ProviderListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: ProviderListParams = ProviderListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: ProviderListParams = ProviderListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt index 323e5566..764b0e6b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.RequestForwardingForwardParams @@ -41,14 +40,12 @@ interface RequestForwardingServiceAsync { * Returns a raw HTTP response for `post /forward`, but is otherwise the same as * [RequestForwardingServiceAsync.forward]. */ - @MustBeClosed fun forward( params: RequestForwardingForwardParams ): CompletableFuture> = forward(params, RequestOptions.none()) /** @see [forward] */ - @MustBeClosed fun forward( params: RequestForwardingForwardParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt index 3b1e18cb..9d4fc709 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.connect -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectSessionNewParams @@ -49,14 +48,12 @@ interface SessionServiceAsync { * Returns a raw HTTP response for `post /connect/sessions`, but is otherwise the same as * [SessionServiceAsync.new_]. */ - @MustBeClosed fun new_( params: ConnectSessionNewParams ): CompletableFuture> = new_(params, RequestOptions.none()) /** @see [new_] */ - @MustBeClosed fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -66,14 +63,12 @@ interface SessionServiceAsync { * Returns a raw HTTP response for `post /connect/sessions/reauthenticate`, but is otherwise * the same as [SessionServiceAsync.reauthenticate]. */ - @MustBeClosed fun reauthenticate( params: ConnectSessionReauthenticateParams ): CompletableFuture> = reauthenticate(params, RequestOptions.none()) /** @see [reauthenticate] */ - @MustBeClosed fun reauthenticate( params: ConnectSessionReauthenticateParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt index 78490ed2..5f8c15a9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyBenefit @@ -173,26 +172,22 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `post /employer/benefits`, but is otherwise the same as * [BenefitServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(HrisBenefitCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: HrisBenefitCreateParams = HrisBenefitCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: HrisBenefitCreateParams = HrisBenefitCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -202,12 +197,10 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}`, but is otherwise * the same as [BenefitServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(benefitId: String): CompletableFuture> = retrieve(benefitId, HrisBenefitRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( benefitId: String, params: HrisBenefitRetrieveParams = HrisBenefitRetrieveParams.none(), @@ -216,7 +209,6 @@ interface BenefitServiceAsync { retrieve(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( benefitId: String, params: HrisBenefitRetrieveParams = HrisBenefitRetrieveParams.none(), @@ -224,21 +216,18 @@ interface BenefitServiceAsync { retrieve(benefitId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: HrisBenefitRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: HrisBenefitRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( benefitId: String, requestOptions: RequestOptions, @@ -249,14 +238,12 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `post /employer/benefits/{benefit_id}`, but is otherwise * the same as [BenefitServiceAsync.update]. */ - @MustBeClosed fun update( benefitId: String ): CompletableFuture> = update(benefitId, HrisBenefitUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( benefitId: String, params: HrisBenefitUpdateParams = HrisBenefitUpdateParams.none(), @@ -265,7 +252,6 @@ interface BenefitServiceAsync { update(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( benefitId: String, params: HrisBenefitUpdateParams = HrisBenefitUpdateParams.none(), @@ -273,21 +259,18 @@ interface BenefitServiceAsync { update(benefitId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: HrisBenefitUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: HrisBenefitUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( benefitId: String, requestOptions: RequestOptions, @@ -298,26 +281,22 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `get /employer/benefits`, but is otherwise the same as * [BenefitServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisBenefitListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisBenefitListParams = HrisBenefitListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisBenefitListParams = HrisBenefitListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -327,13 +306,11 @@ interface BenefitServiceAsync { * Returns a raw HTTP response for `get /employer/benefits/meta`, but is otherwise the same * as [BenefitServiceAsync.listSupportedBenefits]. */ - @MustBeClosed fun listSupportedBenefits(): CompletableFuture> = listSupportedBenefits(HrisBenefitListSupportedBenefitsParams.none()) /** @see [listSupportedBenefits] */ - @MustBeClosed fun listSupportedBenefits( params: HrisBenefitListSupportedBenefitsParams = HrisBenefitListSupportedBenefitsParams.none(), @@ -341,7 +318,6 @@ interface BenefitServiceAsync { ): CompletableFuture> /** @see [listSupportedBenefits] */ - @MustBeClosed fun listSupportedBenefits( params: HrisBenefitListSupportedBenefitsParams = HrisBenefitListSupportedBenefitsParams.none() @@ -349,7 +325,6 @@ interface BenefitServiceAsync { listSupportedBenefits(params, RequestOptions.none()) /** @see [listSupportedBenefits] */ - @MustBeClosed fun listSupportedBenefits( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt index cfdf2ff3..6eeb46cd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.Company @@ -48,25 +47,21 @@ interface CompanyServiceAsync { * Returns a raw HTTP response for `get /employer/company`, but is otherwise the same as * [CompanyServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(): CompletableFuture> = retrieve(HrisCompanyRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: HrisCompanyRetrieveParams = HrisCompanyRetrieveParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: HrisCompanyRetrieveParams = HrisCompanyRetrieveParams.none() ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve(requestOptions: RequestOptions): CompletableFuture> = retrieve(HrisCompanyRetrieveParams.none(), requestOptions) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt index 83b5b834..fa2b7b87 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisDirectoryListIndividualsPageAsync @@ -71,26 +70,22 @@ interface DirectoryServiceAsync { * Returns a raw HTTP response for `get /employer/directory`, but is otherwise the same as * [DirectoryServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisDirectoryListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisDirectoryListParams = HrisDirectoryListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisDirectoryListParams = HrisDirectoryListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -101,14 +96,12 @@ interface DirectoryServiceAsync { * [DirectoryServiceAsync.listIndividuals]. */ @Deprecated("use `list` instead") - @MustBeClosed fun listIndividuals(): CompletableFuture> = listIndividuals(HrisDirectoryListIndividualsParams.none()) /** @see [listIndividuals] */ @Deprecated("use `list` instead") - @MustBeClosed fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none(), requestOptions: RequestOptions = RequestOptions.none(), @@ -116,7 +109,6 @@ interface DirectoryServiceAsync { /** @see [listIndividuals] */ @Deprecated("use `list` instead") - @MustBeClosed fun listIndividuals( params: HrisDirectoryListIndividualsParams = HrisDirectoryListIndividualsParams.none() ): CompletableFuture> = @@ -124,7 +116,6 @@ interface DirectoryServiceAsync { /** @see [listIndividuals] */ @Deprecated("use `list` instead") - @MustBeClosed fun listIndividuals( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt index 5688823e..bf6a4a3b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DocumentListResponse @@ -86,26 +85,22 @@ interface DocumentServiceAsync { * Returns a raw HTTP response for `get /employer/documents`, but is otherwise the same as * [DocumentServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisDocumentListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisDocumentListParams = HrisDocumentListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisDocumentListParams = HrisDocumentListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -115,14 +110,12 @@ interface DocumentServiceAsync { * Returns a raw HTTP response for `get /employer/documents/{document_id}`, but is otherwise * the same as [DocumentServiceAsync.retreive]. */ - @MustBeClosed fun retreive( documentId: String ): CompletableFuture> = retreive(documentId, HrisDocumentRetreiveParams.none()) /** @see [retreive] */ - @MustBeClosed fun retreive( documentId: String, params: HrisDocumentRetreiveParams = HrisDocumentRetreiveParams.none(), @@ -131,7 +124,6 @@ interface DocumentServiceAsync { retreive(params.toBuilder().documentId(documentId).build(), requestOptions) /** @see [retreive] */ - @MustBeClosed fun retreive( documentId: String, params: HrisDocumentRetreiveParams = HrisDocumentRetreiveParams.none(), @@ -139,21 +131,18 @@ interface DocumentServiceAsync { retreive(documentId, params, RequestOptions.none()) /** @see [retreive] */ - @MustBeClosed fun retreive( params: HrisDocumentRetreiveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retreive] */ - @MustBeClosed fun retreive( params: HrisDocumentRetreiveParams ): CompletableFuture> = retreive(params, RequestOptions.none()) /** @see [retreive] */ - @MustBeClosed fun retreive( documentId: String, requestOptions: RequestOptions, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt index 9b0987cd..aeb30c65 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageAsync @@ -38,14 +37,12 @@ interface EmploymentServiceAsync { * Returns a raw HTTP response for `post /employer/employment`, but is otherwise the same as * [EmploymentServiceAsync.retrieveMany]. */ - @MustBeClosed fun retrieveMany( params: HrisEmploymentRetrieveManyParams ): CompletableFuture> = retrieveMany(params, RequestOptions.none()) /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( params: HrisEmploymentRetrieveManyParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt index e51cd00b..04e8c2f7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisIndividualRetrieveManyPageAsync @@ -48,27 +47,23 @@ interface IndividualServiceAsync { * Returns a raw HTTP response for `post /employer/individual`, but is otherwise the same as * [IndividualServiceAsync.retrieveMany]. */ - @MustBeClosed fun retrieveMany(): CompletableFuture> = retrieveMany(HrisIndividualRetrieveManyParams.none()) /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( params: HrisIndividualRetrieveManyParams = HrisIndividualRetrieveManyParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( params: HrisIndividualRetrieveManyParams = HrisIndividualRetrieveManyParams.none() ): CompletableFuture> = retrieveMany(params, RequestOptions.none()) /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt index 79077b3a..f500d3e4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageAsync @@ -42,14 +41,12 @@ interface PayStatementServiceAsync { * Returns a raw HTTP response for `post /employer/pay-statement`, but is otherwise the same * as [PayStatementServiceAsync.retrieveMany]. */ - @MustBeClosed fun retrieveMany( params: HrisPayStatementRetrieveManyParams ): CompletableFuture> = retrieveMany(params, RequestOptions.none()) /** @see [retrieveMany] */ - @MustBeClosed fun retrieveMany( params: HrisPayStatementRetrieveManyParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt index f0d25be6..fd439bf5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPaymentListPageAsync @@ -35,14 +34,12 @@ interface PaymentServiceAsync { * Returns a raw HTTP response for `get /employer/payment`, but is otherwise the same as * [PaymentServiceAsync.list]. */ - @MustBeClosed fun list( params: HrisPaymentListParams ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisPaymentListParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt index 12b6ea0f..37349762 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris.benefits -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams @@ -155,14 +154,12 @@ interface IndividualServiceAsync { * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/enrolled`, but is * otherwise the same as [IndividualServiceAsync.enrolledIds]. */ - @MustBeClosed fun enrolledIds( benefitId: String ): CompletableFuture> = enrolledIds(benefitId, HrisBenefitIndividualEnrolledIdsParams.none()) /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( benefitId: String, params: HrisBenefitIndividualEnrolledIdsParams = @@ -172,7 +169,6 @@ interface IndividualServiceAsync { enrolledIds(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( benefitId: String, params: HrisBenefitIndividualEnrolledIdsParams = @@ -181,21 +177,18 @@ interface IndividualServiceAsync { enrolledIds(benefitId, params, RequestOptions.none()) /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams ): CompletableFuture> = enrolledIds(params, RequestOptions.none()) /** @see [enrolledIds] */ - @MustBeClosed fun enrolledIds( benefitId: String, requestOptions: RequestOptions, @@ -206,14 +199,12 @@ interface IndividualServiceAsync { * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/individuals`, but is * otherwise the same as [IndividualServiceAsync.retrieveManyBenefits]. */ - @MustBeClosed fun retrieveManyBenefits( benefitId: String ): CompletableFuture> = retrieveManyBenefits(benefitId, HrisBenefitIndividualRetrieveManyBenefitsParams.none()) /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( benefitId: String, params: HrisBenefitIndividualRetrieveManyBenefitsParams = @@ -223,7 +214,6 @@ interface IndividualServiceAsync { retrieveManyBenefits(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( benefitId: String, params: HrisBenefitIndividualRetrieveManyBenefitsParams = @@ -232,21 +222,18 @@ interface IndividualServiceAsync { retrieveManyBenefits(benefitId, params, RequestOptions.none()) /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( params: HrisBenefitIndividualRetrieveManyBenefitsParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( params: HrisBenefitIndividualRetrieveManyBenefitsParams ): CompletableFuture> = retrieveManyBenefits(params, RequestOptions.none()) /** @see [retrieveManyBenefits] */ - @MustBeClosed fun retrieveManyBenefits( benefitId: String, requestOptions: RequestOptions, @@ -261,14 +248,12 @@ interface IndividualServiceAsync { * Returns a raw HTTP response for `delete /employer/benefits/{benefit_id}/individuals`, but * is otherwise the same as [IndividualServiceAsync.unenrollMany]. */ - @MustBeClosed fun unenrollMany( benefitId: String ): CompletableFuture> = unenrollMany(benefitId, HrisBenefitIndividualUnenrollManyParams.none()) /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( benefitId: String, params: HrisBenefitIndividualUnenrollManyParams = @@ -278,7 +263,6 @@ interface IndividualServiceAsync { unenrollMany(params.toBuilder().benefitId(benefitId).build(), requestOptions) /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( benefitId: String, params: HrisBenefitIndividualUnenrollManyParams = @@ -287,21 +271,18 @@ interface IndividualServiceAsync { unenrollMany(benefitId, params, RequestOptions.none()) /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( params: HrisBenefitIndividualUnenrollManyParams ): CompletableFuture> = unenrollMany(params, RequestOptions.none()) /** @see [unenrollMany] */ - @MustBeClosed fun unenrollMany( benefitId: String, requestOptions: RequestOptions, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt index a0fdb11b..6af3fb5b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris.company -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemListPageAsync @@ -58,12 +57,10 @@ interface PayStatementItemServiceAsync { * Returns a raw HTTP response for `get /employer/pay-statement-item`, but is otherwise the * same as [PayStatementItemServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisCompanyPayStatementItemListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisCompanyPayStatementItemListParams = HrisCompanyPayStatementItemListParams.none(), @@ -71,7 +68,6 @@ interface PayStatementItemServiceAsync { ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisCompanyPayStatementItemListParams = HrisCompanyPayStatementItemListParams.none() @@ -79,7 +75,6 @@ interface PayStatementItemServiceAsync { list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt index 613b9577..ff332b44 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.hris.company.payStatementItem -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleCreateParams @@ -165,12 +164,10 @@ interface RuleServiceAsync { * Returns a raw HTTP response for `post /employer/pay-statement-item/rule`, but is * otherwise the same as [RuleServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(HrisCompanyPayStatementItemRuleCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: HrisCompanyPayStatementItemRuleCreateParams = HrisCompanyPayStatementItemRuleCreateParams.none(), @@ -178,7 +175,6 @@ interface RuleServiceAsync { ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: HrisCompanyPayStatementItemRuleCreateParams = HrisCompanyPayStatementItemRuleCreateParams.none() @@ -186,7 +182,6 @@ interface RuleServiceAsync { create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -196,12 +191,10 @@ interface RuleServiceAsync { * Returns a raw HTTP response for `put /employer/pay-statement-item/rule/{rule_id}`, but is * otherwise the same as [RuleServiceAsync.update]. */ - @MustBeClosed fun update(ruleId: String): CompletableFuture> = update(ruleId, HrisCompanyPayStatementItemRuleUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( ruleId: String, params: HrisCompanyPayStatementItemRuleUpdateParams = @@ -211,7 +204,6 @@ interface RuleServiceAsync { update(params.toBuilder().ruleId(ruleId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( ruleId: String, params: HrisCompanyPayStatementItemRuleUpdateParams = @@ -220,21 +212,18 @@ interface RuleServiceAsync { update(ruleId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: HrisCompanyPayStatementItemRuleUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: HrisCompanyPayStatementItemRuleUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( ruleId: String, requestOptions: RequestOptions, @@ -245,13 +234,11 @@ interface RuleServiceAsync { * Returns a raw HTTP response for `get /employer/pay-statement-item/rule`, but is otherwise * the same as [RuleServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(HrisCompanyPayStatementItemRuleListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: HrisCompanyPayStatementItemRuleListParams = HrisCompanyPayStatementItemRuleListParams.none(), @@ -259,7 +246,6 @@ interface RuleServiceAsync { ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: HrisCompanyPayStatementItemRuleListParams = HrisCompanyPayStatementItemRuleListParams.none() @@ -267,7 +253,6 @@ interface RuleServiceAsync { list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = @@ -277,12 +262,10 @@ interface RuleServiceAsync { * Returns a raw HTTP response for `delete /employer/pay-statement-item/rule/{rule_id}`, but * is otherwise the same as [RuleServiceAsync.delete]. */ - @MustBeClosed fun delete(ruleId: String): CompletableFuture> = delete(ruleId, HrisCompanyPayStatementItemRuleDeleteParams.none()) /** @see [delete] */ - @MustBeClosed fun delete( ruleId: String, params: HrisCompanyPayStatementItemRuleDeleteParams = @@ -292,7 +275,6 @@ interface RuleServiceAsync { delete(params.toBuilder().ruleId(ruleId).build(), requestOptions) /** @see [delete] */ - @MustBeClosed fun delete( ruleId: String, params: HrisCompanyPayStatementItemRuleDeleteParams = @@ -301,21 +283,18 @@ interface RuleServiceAsync { delete(ruleId, params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( params: HrisCompanyPayStatementItemRuleDeleteParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [delete] */ - @MustBeClosed fun delete( params: HrisCompanyPayStatementItemRuleDeleteParams ): CompletableFuture> = delete(params, RequestOptions.none()) /** @see [delete] */ - @MustBeClosed fun delete( ruleId: String, requestOptions: RequestOptions, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt index 90fc195c..2d46e589 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.jobs -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AutomatedAsyncJob @@ -119,26 +118,22 @@ interface AutomatedServiceAsync { * Returns a raw HTTP response for `post /jobs/automated`, but is otherwise the same as * [AutomatedServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(JobAutomatedCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: JobAutomatedCreateParams = JobAutomatedCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: JobAutomatedCreateParams = JobAutomatedCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = @@ -148,12 +143,10 @@ interface AutomatedServiceAsync { * Returns a raw HTTP response for `get /jobs/automated/{job_id}`, but is otherwise the same * as [AutomatedServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(jobId: String): CompletableFuture> = retrieve(jobId, JobAutomatedRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, params: JobAutomatedRetrieveParams = JobAutomatedRetrieveParams.none(), @@ -162,7 +155,6 @@ interface AutomatedServiceAsync { retrieve(params.toBuilder().jobId(jobId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, params: JobAutomatedRetrieveParams = JobAutomatedRetrieveParams.none(), @@ -170,21 +162,18 @@ interface AutomatedServiceAsync { retrieve(jobId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobAutomatedRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobAutomatedRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, requestOptions: RequestOptions, @@ -195,26 +184,22 @@ interface AutomatedServiceAsync { * Returns a raw HTTP response for `get /jobs/automated`, but is otherwise the same as * [AutomatedServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(JobAutomatedListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: JobAutomatedListParams = JobAutomatedListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: JobAutomatedListParams = JobAutomatedListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt index 9d131db4..2d0e0e00 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.jobs -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobManualRetrieveParams @@ -60,12 +59,10 @@ interface ManualServiceAsync { * Returns a raw HTTP response for `get /jobs/manual/{job_id}`, but is otherwise the same as * [ManualServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(jobId: String): CompletableFuture> = retrieve(jobId, JobManualRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, params: JobManualRetrieveParams = JobManualRetrieveParams.none(), @@ -74,7 +71,6 @@ interface ManualServiceAsync { retrieve(params.toBuilder().jobId(jobId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, params: JobManualRetrieveParams = JobManualRetrieveParams.none(), @@ -82,21 +78,18 @@ interface ManualServiceAsync { retrieve(jobId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobManualRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: JobManualRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( jobId: String, requestOptions: RequestOptions, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt index 303f01d7..7dffeec5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.payroll -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PayGroupRetrieveResponse @@ -83,14 +82,12 @@ interface PayGroupServiceAsync { * Returns a raw HTTP response for `get /employer/pay-groups/{pay_group_id}`, but is * otherwise the same as [PayGroupServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve( payGroupId: String ): CompletableFuture> = retrieve(payGroupId, PayrollPayGroupRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( payGroupId: String, params: PayrollPayGroupRetrieveParams = PayrollPayGroupRetrieveParams.none(), @@ -99,7 +96,6 @@ interface PayGroupServiceAsync { retrieve(params.toBuilder().payGroupId(payGroupId).build(), requestOptions) /** @see [retrieve] */ - @MustBeClosed fun retrieve( payGroupId: String, params: PayrollPayGroupRetrieveParams = PayrollPayGroupRetrieveParams.none(), @@ -107,21 +103,18 @@ interface PayGroupServiceAsync { retrieve(payGroupId, params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: PayrollPayGroupRetrieveParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: PayrollPayGroupRetrieveParams ): CompletableFuture> = retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( payGroupId: String, requestOptions: RequestOptions, @@ -132,26 +125,22 @@ interface PayGroupServiceAsync { * Returns a raw HTTP response for `get /employer/pay-groups`, but is otherwise the same as * [PayGroupServiceAsync.list]. */ - @MustBeClosed fun list(): CompletableFuture> = list(PayrollPayGroupListParams.none()) /** @see [list] */ - @MustBeClosed fun list( params: PayrollPayGroupListParams = PayrollPayGroupListParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [list] */ - @MustBeClosed fun list( params: PayrollPayGroupListParams = PayrollPayGroupListParams.none() ): CompletableFuture> = list(params, RequestOptions.none()) /** @see [list] */ - @MustBeClosed fun list( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt index 5b946b43..c0a59b23 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyUpdateResponse @@ -35,14 +34,12 @@ interface CompanyServiceAsync { * Returns a raw HTTP response for `put /sandbox/company`, but is otherwise the same as * [CompanyServiceAsync.update]. */ - @MustBeClosed fun update( params: SandboxCompanyUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxCompanyUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt index 77f7287e..4a311397 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectionCreateResponse @@ -41,14 +40,12 @@ interface ConnectionServiceAsync { * Returns a raw HTTP response for `post /sandbox/connections`, but is otherwise the same as * [ConnectionServiceAsync.create]. */ - @MustBeClosed fun create( params: SandboxConnectionCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxConnectionCreateParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt index 66f7b336..b85d5326 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DirectoryCreateResponse @@ -44,26 +43,22 @@ interface DirectoryServiceAsync { * Returns a raw HTTP response for `post /sandbox/directory`, but is otherwise the same as * [DirectoryServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture>> = create(SandboxDirectoryCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxDirectoryCreateParams = SandboxDirectoryCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture>> /** @see [create] */ - @MustBeClosed fun create( params: SandboxDirectoryCreateParams = SandboxDirectoryCreateParams.none() ): CompletableFuture>> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture>> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt index 1828a047..2789998e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.EmploymentUpdateResponse @@ -62,14 +61,12 @@ interface EmploymentServiceAsync { * Returns a raw HTTP response for `put /sandbox/employment/{individual_id}`, but is * otherwise the same as [EmploymentServiceAsync.update]. */ - @MustBeClosed fun update( individualId: String ): CompletableFuture> = update(individualId, SandboxEmploymentUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( individualId: String, params: SandboxEmploymentUpdateParams = SandboxEmploymentUpdateParams.none(), @@ -78,7 +75,6 @@ interface EmploymentServiceAsync { update(params.toBuilder().individualId(individualId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( individualId: String, params: SandboxEmploymentUpdateParams = SandboxEmploymentUpdateParams.none(), @@ -86,21 +82,18 @@ interface EmploymentServiceAsync { update(individualId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxEmploymentUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: SandboxEmploymentUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( individualId: String, requestOptions: RequestOptions, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt index 74ba9437..503a8a59 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.IndividualUpdateResponse @@ -62,14 +61,12 @@ interface IndividualServiceAsync { * Returns a raw HTTP response for `put /sandbox/individual/{individual_id}`, but is * otherwise the same as [IndividualServiceAsync.update]. */ - @MustBeClosed fun update( individualId: String ): CompletableFuture> = update(individualId, SandboxIndividualUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( individualId: String, params: SandboxIndividualUpdateParams = SandboxIndividualUpdateParams.none(), @@ -78,7 +75,6 @@ interface IndividualServiceAsync { update(params.toBuilder().individualId(individualId).build(), requestOptions) /** @see [update] */ - @MustBeClosed fun update( individualId: String, params: SandboxIndividualUpdateParams = SandboxIndividualUpdateParams.none(), @@ -86,21 +82,18 @@ interface IndividualServiceAsync { update(individualId, params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxIndividualUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: SandboxIndividualUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( individualId: String, requestOptions: RequestOptions, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt index e5cb1480..62432ff8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobCreateResponse @@ -38,14 +37,12 @@ interface JobServiceAsync { * Returns a raw HTTP response for `post /sandbox/jobs`, but is otherwise the same as * [JobServiceAsync.create]. */ - @MustBeClosed fun create( params: SandboxJobCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxJobCreateParams, requestOptions: RequestOptions = RequestOptions.none(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt index 57cf34ff..b2d0c98c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PaymentCreateResponse @@ -44,26 +43,22 @@ interface PaymentServiceAsync { * Returns a raw HTTP response for `post /sandbox/payment`, but is otherwise the same as * [PaymentServiceAsync.create]. */ - @MustBeClosed fun create(): CompletableFuture> = create(SandboxPaymentCreateParams.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxPaymentCreateParams = SandboxPaymentCreateParams.none(), requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> /** @see [create] */ - @MustBeClosed fun create( params: SandboxPaymentCreateParams = SandboxPaymentCreateParams.none() ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt index 600917c9..2e7483b7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox.connections -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountCreateResponse @@ -60,14 +59,12 @@ interface AccountServiceAsync { * Returns a raw HTTP response for `post /sandbox/connections/accounts`, but is otherwise * the same as [AccountServiceAsync.create]. */ - @MustBeClosed fun create( params: SandboxConnectionAccountCreateParams ): CompletableFuture> = create(params, RequestOptions.none()) /** @see [create] */ - @MustBeClosed fun create( params: SandboxConnectionAccountCreateParams, requestOptions: RequestOptions = RequestOptions.none(), @@ -77,12 +74,10 @@ interface AccountServiceAsync { * Returns a raw HTTP response for `put /sandbox/connections/accounts`, but is otherwise the * same as [AccountServiceAsync.update]. */ - @MustBeClosed fun update(): CompletableFuture> = update(SandboxConnectionAccountUpdateParams.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxConnectionAccountUpdateParams = SandboxConnectionAccountUpdateParams.none(), @@ -90,7 +85,6 @@ interface AccountServiceAsync { ): CompletableFuture> /** @see [update] */ - @MustBeClosed fun update( params: SandboxConnectionAccountUpdateParams = SandboxConnectionAccountUpdateParams.none() @@ -98,7 +92,6 @@ interface AccountServiceAsync { update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( requestOptions: RequestOptions ): CompletableFuture> = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt index 683e02e8..77dfa8c7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.services.async.sandbox.jobs -import com.google.errorprone.annotations.MustBeClosed import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.SandboxJobConfiguration @@ -58,12 +57,10 @@ interface ConfigurationServiceAsync { * Returns a raw HTTP response for `get /sandbox/jobs/configuration`, but is otherwise the * same as [ConfigurationServiceAsync.retrieve]. */ - @MustBeClosed fun retrieve(): CompletableFuture>> = retrieve(SandboxJobConfigurationRetrieveParams.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: SandboxJobConfigurationRetrieveParams = SandboxJobConfigurationRetrieveParams.none(), @@ -71,7 +68,6 @@ interface ConfigurationServiceAsync { ): CompletableFuture>> /** @see [retrieve] */ - @MustBeClosed fun retrieve( params: SandboxJobConfigurationRetrieveParams = SandboxJobConfigurationRetrieveParams.none() @@ -79,7 +75,6 @@ interface ConfigurationServiceAsync { retrieve(params, RequestOptions.none()) /** @see [retrieve] */ - @MustBeClosed fun retrieve( requestOptions: RequestOptions ): CompletableFuture>> = @@ -89,14 +84,12 @@ interface ConfigurationServiceAsync { * Returns a raw HTTP response for `put /sandbox/jobs/configuration`, but is otherwise the * same as [ConfigurationServiceAsync.update]. */ - @MustBeClosed fun update( params: SandboxJobConfigurationUpdateParams ): CompletableFuture> = update(params, RequestOptions.none()) /** @see [update] */ - @MustBeClosed fun update( params: SandboxJobConfigurationUpdateParams, requestOptions: RequestOptions = RequestOptions.none(), From 1d74258cd7af29bab12fa98e22201fdd736ff70e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Jun 2025 15:51:18 +0000 Subject: [PATCH 10/26] fix(client): `hasNextPage` impl for some classes --- .../api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt | 2 +- .../HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt | 2 +- .../main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt | 2 +- .../kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt | 2 +- .../tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt | 2 +- .../api/models/HrisBenefitListSupportedBenefitsPageAsync.kt | 2 +- .../tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt | 2 +- .../api/models/HrisCompanyPayStatementItemListPageAsync.kt | 2 +- .../api/models/HrisCompanyPayStatementItemRuleListPage.kt | 2 +- .../api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt | 2 +- .../com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt | 2 +- .../tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt | 2 +- .../com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt | 2 +- .../tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt | 2 +- .../com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt | 2 +- .../api/models/HrisPayStatementRetrieveManyPageAsync.kt | 2 +- .../main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt | 2 +- .../kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt | 2 +- .../kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt | 2 +- .../com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt | 2 +- .../src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt | 2 +- .../kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt | 2 +- 22 files changed, 22 insertions(+), 22 deletions(-) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt index dfc47dd0..672d1d92 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPage.kt @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitIndividualRetrieveManyBenefitsParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt index 85f9ba74..22b85713 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualRetrieveManyBenefitsPageAsync.kt @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitIndividualRetrieveManyBenefitsParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt index fbcf2ff6..09ca0633 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPage.kt @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt index 9cd78291..884830d5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListPageAsync.kt @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt index 3409c4b3..e46538d6 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 @@ -18,7 +18,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitListSupportedBenefitsParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt index 3f3abf51..3e25be33 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 @@ -21,7 +21,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisBenefitListSupportedBenefitsParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt index 823bce21..38a27d53 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPage.kt @@ -28,7 +28,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisCompanyPayStatementItemListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageAsync.kt index a39ed6ef..9ad7c8d2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemListPageAsync.kt @@ -31,7 +31,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisCompanyPayStatementItemListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt index 580d9169..6e23fe25 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPage.kt @@ -28,7 +28,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisCompanyPayStatementItemRuleListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt index 1a083316..623b1a8a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisCompanyPayStatementItemRuleListPageAsync.kt @@ -31,7 +31,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisCompanyPayStatementItemRuleListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt index a4fb48cd..ac8306aa 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPage.kt @@ -27,7 +27,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisEmploymentRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt index 91ccab5d..f00e98c9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageAsync.kt @@ -30,7 +30,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisEmploymentRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt index ac6fca75..19d656c2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPage.kt @@ -27,7 +27,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisIndividualRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt index efacc397..c9a0aeb5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyPageAsync.kt @@ -30,7 +30,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisIndividualRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt index ce24980a..09c3d3b8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPage.kt @@ -27,7 +27,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisPayStatementRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt index ff0099a3..df55d75d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageAsync.kt @@ -30,7 +30,7 @@ private constructor( override fun items(): List = responses() - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisPayStatementRetrieveManyParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt index 9cf9d9a5..66eef149 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPage.kt @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisPaymentListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt index ee77147a..e5164328 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPaymentListPageAsync.kt @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): HrisPaymentListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt index 9287b371..7505d02a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPage.kt @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): PayrollPayGroupListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt index 9b790ca2..7c21fa21 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayrollPayGroupListPageAsync.kt @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): PayrollPayGroupListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt index e3c2524a..818565b9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPage.kt @@ -16,7 +16,7 @@ private constructor( private val items: List, ) : Page { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): ProviderListParams = throw IllegalStateException("Cannot construct next page params") diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt index c23a65e2..f6a62b91 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ProviderListPageAsync.kt @@ -19,7 +19,7 @@ private constructor( private val items: List, ) : PageAsync { - override fun hasNextPage(): Boolean = items().isNotEmpty() + override fun hasNextPage(): Boolean = false fun nextPageParams(): ProviderListParams = throw IllegalStateException("Cannot construct next page params") From 6e3128c15c5554728a0a1ab30f52458031d52f6c Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 15:30:17 +0000 Subject: [PATCH 11/26] fix(client): fix PayStatementResponse body --- .stats.yml | 2 +- .../com/tryfinch/api/models/PayStatement.kt | 4524 ++++++++++++ .../models/PayStatementDataSyncInProgress.kt | 754 ++ .../api/models/PayStatementResponse.kt | 536 +- .../api/models/PayStatementResponseBody.kt | 6363 +---------------- .../api/models/SandboxPaymentCreateParams.kt | 4586 ------------ ...ayStatementRetrieveManyPageResponseTest.kt | 331 +- .../PayStatementDataSyncInProgressTest.kt | 61 + .../models/PayStatementResponseBodyTest.kt | 562 +- .../api/models/PayStatementResponseTest.kt | 323 +- .../tryfinch/api/models/PayStatementTest.kt | 375 + .../models/SandboxPaymentCreateParamsTest.kt | 194 +- .../async/sandbox/PaymentServiceAsyncTest.kt | 74 +- .../blocking/sandbox/PaymentServiceTest.kt | 74 +- 14 files changed, 6921 insertions(+), 11838 deletions(-) create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt create mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgressTest.kt create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt diff --git a/.stats.yml b/.stats.yml index 0fe808d1..b21d83cd 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-1a82d3230c420c8562600b0ad45133d79ab68ffd21d524ab26eef11e163dba09.yml openapi_spec_hash: 7bd02ce73505e51c5fd78608fed55c62 -config_hash: 81eb5297df860cf29f8c5bdbf9f89608 +config_hash: bb896000dc7e790e5c9ddda2549fb7ac diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt new file mode 100644 index 00000000..a30617de --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt @@ -0,0 +1,4524 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.Enum +import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.toImmutable +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +class PayStatement +private constructor( + private val earnings: JsonField>, + private val employeeDeductions: JsonField>, + private val employerContributions: JsonField>, + private val grossPay: JsonField, + private val individualId: JsonField, + private val netPay: JsonField, + private val paymentMethod: JsonField, + private val taxes: JsonField>, + private val totalHours: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("earnings") + @ExcludeMissing + earnings: JsonField> = JsonMissing.of(), + @JsonProperty("employee_deductions") + @ExcludeMissing + employeeDeductions: JsonField> = JsonMissing.of(), + @JsonProperty("employer_contributions") + @ExcludeMissing + employerContributions: JsonField> = JsonMissing.of(), + @JsonProperty("gross_pay") @ExcludeMissing grossPay: JsonField = JsonMissing.of(), + @JsonProperty("individual_id") + @ExcludeMissing + individualId: JsonField = JsonMissing.of(), + @JsonProperty("net_pay") @ExcludeMissing netPay: JsonField = JsonMissing.of(), + @JsonProperty("payment_method") + @ExcludeMissing + paymentMethod: JsonField = JsonMissing.of(), + @JsonProperty("taxes") @ExcludeMissing taxes: JsonField> = JsonMissing.of(), + @JsonProperty("total_hours") + @ExcludeMissing + totalHours: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + earnings, + employeeDeductions, + employerContributions, + grossPay, + individualId, + netPay, + paymentMethod, + taxes, + totalHours, + type, + mutableMapOf(), + ) + + /** + * The array of earnings objects associated with this pay statement + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun earnings(): Optional> = earnings.getOptional("earnings") + + /** + * The array of deductions objects associated with this pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun employeeDeductions(): Optional> = + employeeDeductions.getOptional("employee_deductions") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun employerContributions(): Optional> = + employerContributions.getOptional("employer_contributions") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun grossPay(): Optional = grossPay.getOptional("gross_pay") + + /** + * A stable Finch `id` (UUID v4) for an individual in the company + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun individualId(): String = individualId.getRequired("individual_id") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun netPay(): Optional = netPay.getOptional("net_pay") + + /** + * The payment method. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentMethod(): Optional = paymentMethod.getOptional("payment_method") + + /** + * The array of taxes objects associated with this pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxes(): Optional> = taxes.getOptional("taxes") + + /** + * The number of hours worked for this pay period + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalHours(): Optional = totalHours.getOptional("total_hours") + + /** + * The type of the payment associated with the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [earnings]. + * + * Unlike [earnings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("earnings") @ExcludeMissing fun _earnings(): JsonField> = earnings + + /** + * Returns the raw JSON value of [employeeDeductions]. + * + * Unlike [employeeDeductions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("employee_deductions") + @ExcludeMissing + fun _employeeDeductions(): JsonField> = employeeDeductions + + /** + * Returns the raw JSON value of [employerContributions]. + * + * Unlike [employerContributions], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("employer_contributions") + @ExcludeMissing + fun _employerContributions(): JsonField> = employerContributions + + /** + * Returns the raw JSON value of [grossPay]. + * + * Unlike [grossPay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay + + /** + * Returns the raw JSON value of [individualId]. + * + * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId + + /** + * Returns the raw JSON value of [netPay]. + * + * Unlike [netPay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay + + /** + * Returns the raw JSON value of [paymentMethod]. + * + * Unlike [paymentMethod], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("payment_method") + @ExcludeMissing + fun _paymentMethod(): JsonField = paymentMethod + + /** + * Returns the raw JSON value of [taxes]. + * + * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes + + /** + * Returns the raw JSON value of [totalHours]. + * + * Unlike [totalHours], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_hours") @ExcludeMissing fun _totalHours(): JsonField = totalHours + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PayStatement]. + * + * The following fields are required: + * ```java + * .earnings() + * .employeeDeductions() + * .employerContributions() + * .grossPay() + * .individualId() + * .netPay() + * .paymentMethod() + * .taxes() + * .totalHours() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PayStatement]. */ + class Builder internal constructor() { + + private var earnings: JsonField>? = null + private var employeeDeductions: JsonField>? = null + private var employerContributions: JsonField>? = null + private var grossPay: JsonField? = null + private var individualId: JsonField? = null + private var netPay: JsonField? = null + private var paymentMethod: JsonField? = null + private var taxes: JsonField>? = null + private var totalHours: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(payStatement: PayStatement) = apply { + earnings = payStatement.earnings.map { it.toMutableList() } + employeeDeductions = payStatement.employeeDeductions.map { it.toMutableList() } + employerContributions = payStatement.employerContributions.map { it.toMutableList() } + grossPay = payStatement.grossPay + individualId = payStatement.individualId + netPay = payStatement.netPay + paymentMethod = payStatement.paymentMethod + taxes = payStatement.taxes.map { it.toMutableList() } + totalHours = payStatement.totalHours + type = payStatement.type + additionalProperties = payStatement.additionalProperties.toMutableMap() + } + + /** The array of earnings objects associated with this pay statement */ + fun earnings(earnings: List?) = earnings(JsonField.ofNullable(earnings)) + + /** Alias for calling [Builder.earnings] with `earnings.orElse(null)`. */ + fun earnings(earnings: Optional>) = earnings(earnings.getOrNull()) + + /** + * Sets [Builder.earnings] to an arbitrary JSON value. + * + * You should usually call [Builder.earnings] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun earnings(earnings: JsonField>) = apply { + this.earnings = earnings.map { it.toMutableList() } + } + + /** + * Adds a single [Earning] to [earnings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEarning(earning: Earning) = apply { + earnings = + (earnings ?: JsonField.of(mutableListOf())).also { + checkKnown("earnings", it).add(earning) + } + } + + /** The array of deductions objects associated with this pay statement. */ + fun employeeDeductions(employeeDeductions: List?) = + employeeDeductions(JsonField.ofNullable(employeeDeductions)) + + /** + * Alias for calling [Builder.employeeDeductions] with `employeeDeductions.orElse(null)`. + */ + fun employeeDeductions(employeeDeductions: Optional>) = + employeeDeductions(employeeDeductions.getOrNull()) + + /** + * Sets [Builder.employeeDeductions] to an arbitrary JSON value. + * + * You should usually call [Builder.employeeDeductions] with a well-typed + * `List` value instead. This method is primarily for setting the field + * to an undocumented or not yet supported value. + */ + fun employeeDeductions(employeeDeductions: JsonField>) = apply { + this.employeeDeductions = employeeDeductions.map { it.toMutableList() } + } + + /** + * Adds a single [EmployeeDeduction] to [employeeDeductions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { + employeeDeductions = + (employeeDeductions ?: JsonField.of(mutableListOf())).also { + checkKnown("employeeDeductions", it).add(employeeDeduction) + } + } + + fun employerContributions(employerContributions: List?) = + employerContributions(JsonField.ofNullable(employerContributions)) + + /** + * Alias for calling [Builder.employerContributions] with + * `employerContributions.orElse(null)`. + */ + fun employerContributions(employerContributions: Optional>) = + employerContributions(employerContributions.getOrNull()) + + /** + * Sets [Builder.employerContributions] to an arbitrary JSON value. + * + * You should usually call [Builder.employerContributions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun employerContributions(employerContributions: JsonField>) = + apply { + this.employerContributions = employerContributions.map { it.toMutableList() } + } + + /** + * Adds a single [EmployerContribution] to [employerContributions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmployerContribution(employerContribution: EmployerContribution) = apply { + employerContributions = + (employerContributions ?: JsonField.of(mutableListOf())).also { + checkKnown("employerContributions", it).add(employerContribution) + } + } + + fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) + + /** Alias for calling [Builder.grossPay] with `grossPay.orElse(null)`. */ + fun grossPay(grossPay: Optional) = grossPay(grossPay.getOrNull()) + + /** + * Sets [Builder.grossPay] to an arbitrary JSON value. + * + * You should usually call [Builder.grossPay] with a well-typed [Money] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } + + /** A stable Finch `id` (UUID v4) for an individual in the company */ + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** + * Sets [Builder.individualId] to an arbitrary JSON value. + * + * You should usually call [Builder.individualId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } + + fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) + + /** Alias for calling [Builder.netPay] with `netPay.orElse(null)`. */ + fun netPay(netPay: Optional) = netPay(netPay.getOrNull()) + + /** + * Sets [Builder.netPay] to an arbitrary JSON value. + * + * You should usually call [Builder.netPay] with a well-typed [Money] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun netPay(netPay: JsonField) = apply { this.netPay = netPay } + + /** The payment method. */ + fun paymentMethod(paymentMethod: PaymentMethod?) = + paymentMethod(JsonField.ofNullable(paymentMethod)) + + /** Alias for calling [Builder.paymentMethod] with `paymentMethod.orElse(null)`. */ + fun paymentMethod(paymentMethod: Optional) = + paymentMethod(paymentMethod.getOrNull()) + + /** + * Sets [Builder.paymentMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentMethod] with a well-typed [PaymentMethod] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun paymentMethod(paymentMethod: JsonField) = apply { + this.paymentMethod = paymentMethod + } + + /** The array of taxes objects associated with this pay statement. */ + fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) + + /** Alias for calling [Builder.taxes] with `taxes.orElse(null)`. */ + fun taxes(taxes: Optional>) = taxes(taxes.getOrNull()) + + /** + * Sets [Builder.taxes] to an arbitrary JSON value. + * + * You should usually call [Builder.taxes] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun taxes(taxes: JsonField>) = apply { + this.taxes = taxes.map { it.toMutableList() } + } + + /** + * Adds a single [Tax] to [taxes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTax(tax: Tax) = apply { + taxes = + (taxes ?: JsonField.of(mutableListOf())).also { checkKnown("taxes", it).add(tax) } + } + + /** The number of hours worked for this pay period */ + fun totalHours(totalHours: Double?) = totalHours(JsonField.ofNullable(totalHours)) + + /** + * Alias for [Builder.totalHours]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun totalHours(totalHours: Double) = totalHours(totalHours as Double?) + + /** Alias for calling [Builder.totalHours] with `totalHours.orElse(null)`. */ + fun totalHours(totalHours: Optional) = totalHours(totalHours.getOrNull()) + + /** + * Sets [Builder.totalHours] to an arbitrary JSON value. + * + * You should usually call [Builder.totalHours] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun totalHours(totalHours: JsonField) = apply { this.totalHours = totalHours } + + /** The type of the payment associated with the pay statement. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PayStatement]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .earnings() + * .employeeDeductions() + * .employerContributions() + * .grossPay() + * .individualId() + * .netPay() + * .paymentMethod() + * .taxes() + * .totalHours() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PayStatement = + PayStatement( + checkRequired("earnings", earnings).map { it.toImmutable() }, + checkRequired("employeeDeductions", employeeDeductions).map { it.toImmutable() }, + checkRequired("employerContributions", employerContributions).map { + it.toImmutable() + }, + checkRequired("grossPay", grossPay), + checkRequired("individualId", individualId), + checkRequired("netPay", netPay), + checkRequired("paymentMethod", paymentMethod), + checkRequired("taxes", taxes).map { it.toImmutable() }, + checkRequired("totalHours", totalHours), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PayStatement = apply { + if (validated) { + return@apply + } + + earnings().ifPresent { it.forEach { it?.validate() } } + employeeDeductions().ifPresent { it.forEach { it?.validate() } } + employerContributions().ifPresent { it.forEach { it?.validate() } } + grossPay().ifPresent { it.validate() } + individualId() + netPay().ifPresent { it.validate() } + paymentMethod().ifPresent { it.validate() } + taxes().ifPresent { it.forEach { it?.validate() } } + totalHours() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (earnings.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + + (employeeDeductions.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } + ?: 0) + + (employerContributions.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } + ?: 0) + + (grossPay.asKnown().getOrNull()?.validity() ?: 0) + + (if (individualId.asKnown().isPresent) 1 else 0) + + (netPay.asKnown().getOrNull()?.validity() ?: 0) + + (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + + (taxes.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + + (if (totalHours.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Earning + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val hours: JsonField, + private val name: JsonField, + private val type: JsonField, + private val attributes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("hours") @ExcludeMissing hours: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(amount, currency, hours, name, type, attributes, mutableMapOf()) + + /** + * The earnings amount in cents. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The earnings currency code. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * The number of hours associated with this earning. (For salaried employees, this could be + * hours per pay period, `0` or `null`, depending on the provider). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun hours(): Optional = hours.getOptional("hours") + + /** + * The exact name of the deduction from the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The type of earning. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [hours]. + * + * Unlike [hours], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField = hours + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Earning]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .hours() + * .name() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Earning]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var hours: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + private var attributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(earning: Earning) = apply { + amount = earning.amount + currency = earning.currency + hours = earning.hours + name = earning.name + type = earning.type + attributes = earning.attributes + additionalProperties = earning.additionalProperties.toMutableMap() + } + + /** The earnings amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The earnings currency code. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * The number of hours associated with this earning. (For salaried employees, this could + * be hours per pay period, `0` or `null`, depending on the provider). + */ + fun hours(hours: Double?) = hours(JsonField.ofNullable(hours)) + + /** + * Alias for [Builder.hours]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun hours(hours: Double) = hours(hours as Double?) + + /** Alias for calling [Builder.hours] with `hours.orElse(null)`. */ + fun hours(hours: Optional) = hours(hours.getOrNull()) + + /** + * Sets [Builder.hours] to an arbitrary JSON value. + * + * You should usually call [Builder.hours] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hours(hours: JsonField) = apply { this.hours = hours } + + /** The exact name of the deduction from the pay statement. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The type of earning. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Earning]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .hours() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Earning = + Earning( + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("hours", hours), + checkRequired("name", name), + checkRequired("type", type), + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Earning = apply { + if (validated) { + return@apply + } + + amount() + currency() + hours() + name() + type().ifPresent { it.validate() } + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (hours.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + /** The type of earning. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val SALARY = of("salary") + + @JvmField val WAGE = of("wage") + + @JvmField val REIMBURSEMENT = of("reimbursement") + + @JvmField val OVERTIME = of("overtime") + + @JvmField val SEVERANCE = of("severance") + + @JvmField val DOUBLE_OVERTIME = of("double_overtime") + + @JvmField val PTO = of("pto") + + @JvmField val SICK = of("sick") + + @JvmField val BONUS = of("bonus") + + @JvmField val COMMISSION = of("commission") + + @JvmField val TIPS = of("tips") + + @JvmField val _1099 = of("1099") + + @JvmField val OTHER = of("other") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + SALARY, + WAGE, + REIMBURSEMENT, + OVERTIME, + SEVERANCE, + DOUBLE_OVERTIME, + PTO, + SICK, + BONUS, + COMMISSION, + TIPS, + _1099, + OTHER, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + SALARY, + WAGE, + REIMBURSEMENT, + OVERTIME, + SEVERANCE, + DOUBLE_OVERTIME, + PTO, + SICK, + BONUS, + COMMISSION, + TIPS, + _1099, + OTHER, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + SALARY -> Value.SALARY + WAGE -> Value.WAGE + REIMBURSEMENT -> Value.REIMBURSEMENT + OVERTIME -> Value.OVERTIME + SEVERANCE -> Value.SEVERANCE + DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME + PTO -> Value.PTO + SICK -> Value.SICK + BONUS -> Value.BONUS + COMMISSION -> Value.COMMISSION + TIPS -> Value.TIPS + _1099 -> Value._1099 + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + SALARY -> Known.SALARY + WAGE -> Known.WAGE + REIMBURSEMENT -> Known.REIMBURSEMENT + OVERTIME -> Known.OVERTIME + SEVERANCE -> Known.SEVERANCE + DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME + PTO -> Known.PTO + SICK -> Known.SICK + BONUS -> Known.BONUS + COMMISSION -> Known.COMMISSION + TIPS -> Known.TIPS + _1099 -> Known._1099 + OTHER -> Known.OTHER + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): InnerMetadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + this.metadata = metadata.metadata + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, boolean, + * object, array, etc.). + */ + fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + */ + class InnerMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerMetadata: InnerMetadata) = apply { + additionalProperties = innerMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InnerMetadata = + InnerMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InnerMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerMetadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Earning && amount == other.amount && currency == other.currency && hours == other.hours && name == other.name && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, currency, hours, name, type, attributes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Earning{amount=$amount, currency=$currency, hours=$hours, name=$name, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" + } + + class EmployeeDeduction + private constructor( + private val amount: JsonField, + private val currency: JsonField, + private val name: JsonField, + private val preTax: JsonField, + private val type: JsonField, + private val attributes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("pre_tax") @ExcludeMissing preTax: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(amount, currency, name, preTax, type, attributes, mutableMapOf()) + + /** + * The deduction amount in cents. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * The deduction currency. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * The deduction name from the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Boolean indicating if the deduction is pre-tax. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun preTax(): Optional = preTax.getOptional("pre_tax") + + /** + * Type of benefit. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [preTax]. + * + * Unlike [preTax], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pre_tax") @ExcludeMissing fun _preTax(): JsonField = preTax + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EmployeeDeduction]. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .name() + * .preTax() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmployeeDeduction]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var currency: JsonField? = null + private var name: JsonField? = null + private var preTax: JsonField? = null + private var type: JsonField? = null + private var attributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(employeeDeduction: EmployeeDeduction) = apply { + amount = employeeDeduction.amount + currency = employeeDeduction.currency + name = employeeDeduction.name + preTax = employeeDeduction.preTax + type = employeeDeduction.type + attributes = employeeDeduction.attributes + additionalProperties = employeeDeduction.additionalProperties.toMutableMap() + } + + /** The deduction amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The deduction currency. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The deduction name from the pay statement. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Boolean indicating if the deduction is pre-tax. */ + fun preTax(preTax: Boolean?) = preTax(JsonField.ofNullable(preTax)) + + /** + * Alias for [Builder.preTax]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun preTax(preTax: Boolean) = preTax(preTax as Boolean?) + + /** Alias for calling [Builder.preTax] with `preTax.orElse(null)`. */ + fun preTax(preTax: Optional) = preTax(preTax.getOrNull()) + + /** + * Sets [Builder.preTax] to an arbitrary JSON value. + * + * You should usually call [Builder.preTax] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun preTax(preTax: JsonField) = apply { this.preTax = preTax } + + /** Type of benefit. */ + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BenefitType] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmployeeDeduction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .currency() + * .name() + * .preTax() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EmployeeDeduction = + EmployeeDeduction( + checkRequired("amount", amount), + checkRequired("currency", currency), + checkRequired("name", name), + checkRequired("preTax", preTax), + checkRequired("type", type), + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EmployeeDeduction = apply { + if (validated) { + return@apply + } + + amount() + currency() + name() + preTax() + type().ifPresent { it.validate() } + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (currency.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (preTax.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): InnerMetadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + this.metadata = metadata.metadata + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, boolean, + * object, array, etc.). + */ + fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + */ + class InnerMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerMetadata: InnerMetadata) = apply { + additionalProperties = innerMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InnerMetadata = + InnerMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InnerMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerMetadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, currency, name, preTax, type, attributes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmployeeDeduction{amount=$amount, currency=$currency, name=$name, preTax=$preTax, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" + } + + class EmployerContribution + private constructor( + private val currency: JsonField, + private val name: JsonField, + private val type: JsonField, + private val amount: JsonField, + private val attributes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(currency, name, type, amount, attributes, mutableMapOf()) + + /** + * The contribution currency. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * The contribution name from the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * Type of benefit. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * The contribution amount in cents. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EmployerContribution]. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmployerContribution]. */ + class Builder internal constructor() { + + private var currency: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var attributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(employerContribution: EmployerContribution) = apply { + currency = employerContribution.currency + name = employerContribution.name + type = employerContribution.type + amount = employerContribution.amount + attributes = employerContribution.attributes + additionalProperties = employerContribution.additionalProperties.toMutableMap() + } + + /** The contribution currency. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The contribution name from the pay statement. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** Type of benefit. */ + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [BenefitType] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The contribution amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + 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 [EmployerContribution]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .currency() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): EmployerContribution = + EmployerContribution( + checkRequired("currency", currency), + checkRequired("name", name), + checkRequired("type", type), + amount, + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EmployerContribution = apply { + if (validated) { + return@apply + } + + currency() + name() + type().ifPresent { it.validate() } + amount() + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): InnerMetadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + this.metadata = metadata.metadata + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, boolean, + * object, array, etc.). + */ + fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + */ + class InnerMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerMetadata: InnerMetadata) = apply { + additionalProperties = innerMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InnerMetadata = + InnerMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InnerMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerMetadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EmployerContribution && currency == other.currency && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(currency, name, type, amount, attributes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmployerContribution{currency=$currency, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" + } + + /** The payment method. */ + class PaymentMethod @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CHECK = of("check") + + @JvmField val DIRECT_DEPOSIT = of("direct_deposit") + + @JvmField val OTHER = of("other") + + @JvmStatic fun of(value: String) = PaymentMethod(JsonField.of(value)) + } + + /** An enum containing [PaymentMethod]'s known values. */ + enum class Known { + CHECK, + DIRECT_DEPOSIT, + OTHER, + } + + /** + * An enum containing [PaymentMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PaymentMethod] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHECK, + DIRECT_DEPOSIT, + OTHER, + /** + * An enum member indicating that [PaymentMethod] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHECK -> Value.CHECK + DIRECT_DEPOSIT -> Value.DIRECT_DEPOSIT + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + CHECK -> Known.CHECK + DIRECT_DEPOSIT -> Known.DIRECT_DEPOSIT + OTHER -> Known.OTHER + else -> throw FinchInvalidDataException("Unknown PaymentMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): PaymentMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentMethod && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Tax + private constructor( + private val currency: JsonField, + private val employer: JsonField, + private val name: JsonField, + private val type: JsonField, + private val amount: JsonField, + private val attributes: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("currency") + @ExcludeMissing + currency: JsonField = JsonMissing.of(), + @JsonProperty("employer") + @ExcludeMissing + employer: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("attributes") + @ExcludeMissing + attributes: JsonField = JsonMissing.of(), + ) : this(currency, employer, name, type, amount, attributes, mutableMapOf()) + + /** + * The currency code. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun currency(): Optional = currency.getOptional("currency") + + /** + * `true` if the amount is paid by the employers. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun employer(): Optional = employer.getOptional("employer") + + /** + * The exact name of tax from the pay statement. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * The type of taxes. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * The tax amount in cents. + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun attributes(): Optional = attributes.getOptional("attributes") + + /** + * Returns the raw JSON value of [currency]. + * + * Unlike [currency], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** + * Returns the raw JSON value of [employer]. + * + * Unlike [employer], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [attributes]. + * + * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("attributes") + @ExcludeMissing + fun _attributes(): JsonField = attributes + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Tax]. + * + * The following fields are required: + * ```java + * .currency() + * .employer() + * .name() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tax]. */ + class Builder internal constructor() { + + private var currency: JsonField? = null + private var employer: JsonField? = null + private var name: JsonField? = null + private var type: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var attributes: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tax: Tax) = apply { + currency = tax.currency + employer = tax.employer + name = tax.name + type = tax.type + amount = tax.amount + attributes = tax.attributes + additionalProperties = tax.additionalProperties.toMutableMap() + } + + /** The currency code. */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ + fun currency(currency: Optional) = currency(currency.getOrNull()) + + /** + * Sets [Builder.currency] to an arbitrary JSON value. + * + * You should usually call [Builder.currency] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** `true` if the amount is paid by the employers. */ + fun employer(employer: Boolean?) = employer(JsonField.ofNullable(employer)) + + /** + * Alias for [Builder.employer]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun employer(employer: Boolean) = employer(employer as Boolean?) + + /** Alias for calling [Builder.employer] with `employer.orElse(null)`. */ + fun employer(employer: Optional) = employer(employer.getOrNull()) + + /** + * Sets [Builder.employer] to an arbitrary JSON value. + * + * You should usually call [Builder.employer] with a well-typed [Boolean] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun employer(employer: JsonField) = apply { this.employer = employer } + + /** The exact name of tax from the pay statement. */ + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Alias for calling [Builder.name] with `name.orElse(null)`. */ + fun name(name: Optional) = name(name.getOrNull()) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The type of taxes. */ + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + /** The tax amount in cents. */ + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** + * Alias for [Builder.amount]. + * + * This unboxed primitive overload exists for backwards compatibility. + */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ + fun amount(amount: Optional) = amount(amount.getOrNull()) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun attributes(attributes: Attributes?) = attributes(JsonField.ofNullable(attributes)) + + /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ + fun attributes(attributes: Optional) = attributes(attributes.getOrNull()) + + /** + * Sets [Builder.attributes] to an arbitrary JSON value. + * + * You should usually call [Builder.attributes] with a well-typed [Attributes] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun attributes(attributes: JsonField) = apply { + this.attributes = attributes + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tax]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .currency() + * .employer() + * .name() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Tax = + Tax( + checkRequired("currency", currency), + checkRequired("employer", employer), + checkRequired("name", name), + checkRequired("type", type), + amount, + attributes, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Tax = apply { + if (validated) { + return@apply + } + + currency() + employer() + name() + type().ifPresent { it.validate() } + amount() + attributes().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (currency.asKnown().isPresent) 1 else 0) + + (if (employer.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (amount.asKnown().isPresent) 1 else 0) + + (attributes.asKnown().getOrNull()?.validity() ?: 0) + + /** The type of taxes. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val STATE = of("state") + + @JvmField val FEDERAL = of("federal") + + @JvmField val LOCAL = of("local") + + @JvmField val FICA = of("fica") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + STATE, + FEDERAL, + LOCAL, + FICA, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + STATE, + FEDERAL, + LOCAL, + FICA, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + STATE -> Value.STATE + FEDERAL -> Value.FEDERAL + LOCAL -> Value.LOCAL + FICA -> Value.FICA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + STATE -> Known.STATE + FEDERAL -> Known.FEDERAL + LOCAL -> Known.LOCAL + FICA -> Known.FICA + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Attributes + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): Metadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Attributes]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Attributes]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(attributes: Attributes) = apply { + metadata = attributes.metadata + additionalProperties = attributes.additionalProperties.toMutableMap() + } + + fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [Metadata] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Attributes]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Attributes = + Attributes( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Attributes = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + class Metadata + private constructor( + private val metadata: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("metadata") + @ExcludeMissing + metadata: JsonField = JsonMissing.of() + ) : this(metadata, mutableMapOf()) + + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun metadata(): InnerMetadata = metadata.getRequired("metadata") + + /** + * Returns the raw JSON value of [metadata]. + * + * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Metadata]. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Metadata]. */ + class Builder internal constructor() { + + private var metadata: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(metadata: Metadata) = apply { + this.metadata = metadata.metadata + additionalProperties = metadata.additionalProperties.toMutableMap() + } + + /** + * The metadata to be attached to the entity by existing rules. It is a + * key-value pairs where the values can be of any type (string, number, boolean, + * object, array, etc.). + */ + fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) + + /** + * Sets [Builder.metadata] to an arbitrary JSON value. + * + * You should usually call [Builder.metadata] with a well-typed [InnerMetadata] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun metadata(metadata: JsonField) = apply { + this.metadata = metadata + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Metadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .metadata() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Metadata = + Metadata( + checkRequired("metadata", metadata), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (validated) { + return@apply + } + + metadata().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) + + /** + * The metadata to be attached to the entity by existing rules. It is a key-value + * pairs where the values can be of any type (string, number, boolean, object, + * array, etc.). + */ + class InnerMetadata + @JsonCreator + private constructor( + @com.fasterxml.jackson.annotation.JsonValue + private val additionalProperties: Map + ) { + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [InnerMetadata]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [InnerMetadata]. */ + class Builder internal constructor() { + + private var additionalProperties: MutableMap = + mutableMapOf() + + @JvmSynthetic + internal fun from(innerMetadata: InnerMetadata) = apply { + additionalProperties = innerMetadata.additionalProperties.toMutableMap() + } + + fun additionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties( + additionalProperties: Map + ) = apply { this.additionalProperties.putAll(additionalProperties) } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [InnerMetadata]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): InnerMetadata = + InnerMetadata(additionalProperties.toImmutable()) + } + + private var validated: Boolean = false + + fun validate(): InnerMetadata = apply { + if (validated) { + return@apply + } + + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + additionalProperties.count { (_, value) -> + !value.isNull() && !value.isMissing() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "InnerMetadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tax && currency == other.currency && employer == other.employer && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(currency, employer, name, type, amount, attributes, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tax{currency=$currency, employer=$employer, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" + } + + /** The type of the payment associated with the pay statement. */ + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") + + @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") + + @JvmField val REGULAR_PAYROLL = of("regular_payroll") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + OFF_CYCLE_PAYROLL, + ONE_TIME_PAYMENT, + REGULAR_PAYROLL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OFF_CYCLE_PAYROLL, + ONE_TIME_PAYMENT, + REGULAR_PAYROLL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL + ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Value.REGULAR_PAYROLL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL + ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Known.REGULAR_PAYROLL + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PayStatement && earnings == other.earnings && employeeDeductions == other.employeeDeductions && employerContributions == other.employerContributions && grossPay == other.grossPay && individualId == other.individualId && netPay == other.netPay && paymentMethod == other.paymentMethod && taxes == other.taxes && totalHours == other.totalHours && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(earnings, employeeDeductions, employerContributions, grossPay, individualId, netPay, paymentMethod, taxes, totalHours, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PayStatement{earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, individualId=$individualId, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt new file mode 100644 index 00000000..e20da2e9 --- /dev/null +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgress.kt @@ -0,0 +1,754 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.Enum +import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing +import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.errors.FinchInvalidDataException +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class PayStatementDataSyncInProgress +private constructor( + private val code: JsonField, + private val finchCode: JsonField, + private val message: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("finch_code") + @ExcludeMissing + finchCode: JsonField = JsonMissing.of(), + @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(code, finchCode, message, name, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun code(): Code = code.getRequired("code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun finchCode(): FinchCode = finchCode.getRequired("finch_code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun message(): Message = message.getRequired("message") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun name(): Name = name.getRequired("name") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [finchCode]. + * + * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("finch_code") @ExcludeMissing fun _finchCode(): JsonField = finchCode + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [PayStatementDataSyncInProgress]. + * + * The following fields are required: + * ```java + * .code() + * .finchCode() + * .message() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PayStatementDataSyncInProgress]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var finchCode: JsonField? = null + private var message: JsonField? = null + private var name: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(payStatementDataSyncInProgress: PayStatementDataSyncInProgress) = apply { + code = payStatementDataSyncInProgress.code + finchCode = payStatementDataSyncInProgress.finchCode + message = payStatementDataSyncInProgress.message + name = payStatementDataSyncInProgress.name + additionalProperties = + payStatementDataSyncInProgress.additionalProperties.toMutableMap() + } + + fun code(code: Code) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Code] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun finchCode(finchCode: FinchCode) = finchCode(JsonField.of(finchCode)) + + /** + * Sets [Builder.finchCode] to an arbitrary JSON value. + * + * You should usually call [Builder.finchCode] with a well-typed [FinchCode] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } + + fun message(message: Message) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [Message] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun name(name: Name) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [Name] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PayStatementDataSyncInProgress]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .finchCode() + * .message() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PayStatementDataSyncInProgress = + PayStatementDataSyncInProgress( + checkRequired("code", code), + checkRequired("finchCode", finchCode), + checkRequired("message", message), + checkRequired("name", name), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PayStatementDataSyncInProgress = apply { + if (validated) { + return@apply + } + + code().validate() + finchCode().validate() + message().validate() + name().validate() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (code.asKnown().getOrNull()?.validity() ?: 0) + + (finchCode.asKnown().getOrNull()?.validity() ?: 0) + + (message.asKnown().getOrNull()?.validity() ?: 0) + + (name.asKnown().getOrNull()?.validity() ?: 0) + + class Code @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _202 = of(202.0) + + @JvmStatic fun of(value: Double) = Code(JsonField.of(value)) + } + + /** An enum containing [Code]'s known values. */ + enum class Known { + _202 + } + + /** + * An enum containing [Code]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Code] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _202, + /** An enum member indicating that [Code] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _202 -> Value._202 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + _202 -> Known._202 + else -> throw FinchInvalidDataException("Unknown Code: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asDouble(): Double = + _value().asNumber().getOrNull()?.toDouble() + ?: throw FinchInvalidDataException("Value is not a Double") + + private var validated: Boolean = false + + fun validate(): Code = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Code && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class FinchCode @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val DATA_SYNC_IN_PROGRESS = of("data_sync_in_progress") + + @JvmStatic fun of(value: String) = FinchCode(JsonField.of(value)) + } + + /** An enum containing [FinchCode]'s known values. */ + enum class Known { + DATA_SYNC_IN_PROGRESS + } + + /** + * An enum containing [FinchCode]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [FinchCode] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + DATA_SYNC_IN_PROGRESS, + /** + * An enum member indicating that [FinchCode] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + DATA_SYNC_IN_PROGRESS -> Value.DATA_SYNC_IN_PROGRESS + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + DATA_SYNC_IN_PROGRESS -> Known.DATA_SYNC_IN_PROGRESS + else -> throw FinchInvalidDataException("Unknown FinchCode: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): FinchCode = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is FinchCode && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Message @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField + val THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER = + of( + "The pay statements for this payment are being fetched. Please check back later." + ) + + @JvmStatic fun of(value: String) = Message(JsonField.of(value)) + } + + /** An enum containing [Message]'s known values. */ + enum class Known { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + } + + /** + * An enum containing [Message]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Message] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER, + /** An enum member indicating that [Message] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER -> + Value + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER -> + Known + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + else -> throw FinchInvalidDataException("Unknown Message: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Message = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Message && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Name @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val ACCEPTED = of("accepted") + + @JvmStatic fun of(value: String) = Name(JsonField.of(value)) + } + + /** An enum containing [Name]'s known values. */ + enum class Known { + ACCEPTED + } + + /** + * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Name] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + ACCEPTED, + /** An enum member indicating that [Name] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + ACCEPTED -> Value.ACCEPTED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known member. + */ + fun known(): Known = + when (this) { + ACCEPTED -> Known.ACCEPTED + else -> throw FinchInvalidDataException("Unknown Name: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } + + private var validated: Boolean = false + + fun validate(): Name = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Name && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PayStatementDataSyncInProgress && code == other.code && finchCode == other.finchCode && message == other.message && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, finchCode, message, name, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PayStatementDataSyncInProgress{code=$code, finchCode=$finchCode, message=$message, name=$name, additionalProperties=$additionalProperties}" +} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt index 58b6413f..04d0fa8a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponse.kt @@ -6,19 +6,31 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.BaseDeserializer +import com.tryfinch.api.core.BaseSerializer import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue +import com.tryfinch.api.core.allMaxBy import com.tryfinch.api.core.checkRequired +import com.tryfinch.api.core.getOrThrow import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects +import java.util.Optional import kotlin.jvm.optionals.getOrNull class PayStatementResponse private constructor( - private val body: JsonField, + private val body: JsonField, private val code: JsonField, private val paymentId: JsonField, private val additionalProperties: MutableMap, @@ -26,9 +38,7 @@ private constructor( @JsonCreator private constructor( - @JsonProperty("body") - @ExcludeMissing - body: JsonField = JsonMissing.of(), + @JsonProperty("body") @ExcludeMissing body: JsonField = JsonMissing.of(), @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), @JsonProperty("payment_id") @ExcludeMissing paymentId: JsonField = JsonMissing.of(), ) : this(body, code, paymentId, mutableMapOf()) @@ -37,7 +47,7 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly * missing or null (e.g. if the server responded with an unexpected value). */ - fun body(): PayStatementResponseBody = body.getRequired("body") + fun body(): Body = body.getRequired("body") /** * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly @@ -56,7 +66,7 @@ private constructor( * * Unlike [body], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body /** * Returns the raw JSON value of [code]. @@ -102,7 +112,7 @@ private constructor( /** A builder for [PayStatementResponse]. */ class Builder internal constructor() { - private var body: JsonField? = null + private var body: JsonField? = null private var code: JsonField? = null private var paymentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -115,32 +125,29 @@ private constructor( additionalProperties = payStatementResponse.additionalProperties.toMutableMap() } - fun body(body: PayStatementResponseBody) = body(JsonField.of(body)) + fun body(body: Body) = body(JsonField.of(body)) /** * Sets [Builder.body] to an arbitrary JSON value. * - * You should usually call [Builder.body] with a well-typed [PayStatementResponseBody] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. + * You should usually call [Builder.body] with a well-typed [Body] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. */ - fun body(body: JsonField) = apply { this.body = body } + fun body(body: JsonField) = apply { this.body = body } - /** - * Alias for calling [body] with `PayStatementResponseBody.ofUnionMember0(unionMember0)`. - */ - fun body(unionMember0: PayStatementResponseBody.UnionMember0) = - body(PayStatementResponseBody.ofUnionMember0(unionMember0)) + /** Alias for calling [body] with `Body.ofPayStatementResponse(payStatementResponse)`. */ + fun body(payStatementResponse: PayStatementResponseBody) = + body(Body.ofPayStatementResponse(payStatementResponse)) - /** Alias for calling [body] with `PayStatementResponseBody.ofBatchError(batchError)`. */ - fun body(batchError: PayStatementResponseBody.BatchError) = - body(PayStatementResponseBody.ofBatchError(batchError)) + /** Alias for calling [body] with `Body.ofBatchError(batchError)`. */ + fun body(batchError: Body.BatchError) = body(Body.ofBatchError(batchError)) /** - * Alias for calling [body] with `PayStatementResponseBody.ofUnionMember2(unionMember2)`. + * Alias for calling [body] with + * `Body.ofPayStatementDataSyncInProgress(payStatementDataSyncInProgress)`. */ - fun body(unionMember2: PayStatementResponseBody.UnionMember2) = - body(PayStatementResponseBody.ofUnionMember2(unionMember2)) + fun body(payStatementDataSyncInProgress: PayStatementDataSyncInProgress) = + body(Body.ofPayStatementDataSyncInProgress(payStatementDataSyncInProgress)) fun code(code: Long) = code(JsonField.of(code)) @@ -237,6 +244,489 @@ private constructor( (if (code.asKnown().isPresent) 1 else 0) + (if (paymentId.asKnown().isPresent) 1 else 0) + @JsonDeserialize(using = Body.Deserializer::class) + @JsonSerialize(using = Body.Serializer::class) + class Body + private constructor( + private val payStatementResponse: PayStatementResponseBody? = null, + private val batchError: BatchError? = null, + private val payStatementDataSyncInProgress: PayStatementDataSyncInProgress? = null, + private val _json: JsonValue? = null, + ) { + + fun payStatementResponse(): Optional = + Optional.ofNullable(payStatementResponse) + + fun batchError(): Optional = Optional.ofNullable(batchError) + + fun payStatementDataSyncInProgress(): Optional = + Optional.ofNullable(payStatementDataSyncInProgress) + + fun isPayStatementResponse(): Boolean = payStatementResponse != null + + fun isBatchError(): Boolean = batchError != null + + fun isPayStatementDataSyncInProgress(): Boolean = payStatementDataSyncInProgress != null + + fun asPayStatementResponse(): PayStatementResponseBody = + payStatementResponse.getOrThrow("payStatementResponse") + + fun asBatchError(): BatchError = batchError.getOrThrow("batchError") + + fun asPayStatementDataSyncInProgress(): PayStatementDataSyncInProgress = + payStatementDataSyncInProgress.getOrThrow("payStatementDataSyncInProgress") + + fun _json(): Optional = Optional.ofNullable(_json) + + fun accept(visitor: Visitor): T = + when { + payStatementResponse != null -> + visitor.visitPayStatementResponse(payStatementResponse) + batchError != null -> visitor.visitBatchError(batchError) + payStatementDataSyncInProgress != null -> + visitor.visitPayStatementDataSyncInProgress(payStatementDataSyncInProgress) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitPayStatementResponse( + payStatementResponse: PayStatementResponseBody + ) { + payStatementResponse.validate() + } + + override fun visitBatchError(batchError: BatchError) { + batchError.validate() + } + + override fun visitPayStatementDataSyncInProgress( + payStatementDataSyncInProgress: PayStatementDataSyncInProgress + ) { + payStatementDataSyncInProgress.validate() + } + } + ) + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + accept( + object : Visitor { + override fun visitPayStatementResponse( + payStatementResponse: PayStatementResponseBody + ) = payStatementResponse.validity() + + override fun visitBatchError(batchError: BatchError) = batchError.validity() + + override fun visitPayStatementDataSyncInProgress( + payStatementDataSyncInProgress: PayStatementDataSyncInProgress + ) = payStatementDataSyncInProgress.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Body && payStatementResponse == other.payStatementResponse && batchError == other.batchError && payStatementDataSyncInProgress == other.payStatementDataSyncInProgress /* spotless:on */ + } + + override fun hashCode(): Int = /* spotless:off */ Objects.hash(payStatementResponse, batchError, payStatementDataSyncInProgress) /* spotless:on */ + + override fun toString(): String = + when { + payStatementResponse != null -> "Body{payStatementResponse=$payStatementResponse}" + batchError != null -> "Body{batchError=$batchError}" + payStatementDataSyncInProgress != null -> + "Body{payStatementDataSyncInProgress=$payStatementDataSyncInProgress}" + _json != null -> "Body{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Body") + } + + companion object { + + @JvmStatic + fun ofPayStatementResponse(payStatementResponse: PayStatementResponseBody) = + Body(payStatementResponse = payStatementResponse) + + @JvmStatic fun ofBatchError(batchError: BatchError) = Body(batchError = batchError) + + @JvmStatic + fun ofPayStatementDataSyncInProgress( + payStatementDataSyncInProgress: PayStatementDataSyncInProgress + ) = Body(payStatementDataSyncInProgress = payStatementDataSyncInProgress) + } + + /** An interface that defines how to map each variant of [Body] to a value of type [T]. */ + interface Visitor { + + fun visitPayStatementResponse(payStatementResponse: PayStatementResponseBody): T + + fun visitBatchError(batchError: BatchError): T + + fun visitPayStatementDataSyncInProgress( + payStatementDataSyncInProgress: PayStatementDataSyncInProgress + ): T + + /** + * Maps an unknown variant of [Body] to a value of type [T]. + * + * An instance of [Body] can contain an unknown variant if it was deserialized from data + * that doesn't match any known variant. For example, if the SDK is on an older version + * than the API, then the API may respond with new variants that the SDK is unaware of. + * + * @throws FinchInvalidDataException in the default implementation. + */ + fun unknown(json: JsonValue?): T { + throw FinchInvalidDataException("Unknown Body: $json") + } + } + + internal class Deserializer : BaseDeserializer(Body::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Body { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Body(payStatementResponse = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Body(batchError = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef()) + ?.let { Body(payStatementDataSyncInProgress = it, _json = json) }, + ) + .filterNotNull() + .allMaxBy { it.validity() } + .toList() + return when (bestMatches.size) { + // This can happen if what we're deserializing is completely incompatible with + // all the possible variants (e.g. deserializing from boolean). + 0 -> Body(_json = json) + 1 -> bestMatches.single() + // If there's more than one match with the highest validity, then use the first + // completely valid match, or simply the first match if none are completely + // valid. + else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() + } + } + } + + internal class Serializer : BaseSerializer(Body::class) { + + override fun serialize( + value: Body, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.payStatementResponse != null -> + generator.writeObject(value.payStatementResponse) + value.batchError != null -> generator.writeObject(value.batchError) + value.payStatementDataSyncInProgress != null -> + generator.writeObject(value.payStatementDataSyncInProgress) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Body") + } + } + } + + class BatchError + private constructor( + private val code: JsonField, + private val message: JsonField, + private val name: JsonField, + private val finchCode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), + @JsonProperty("message") + @ExcludeMissing + message: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("finch_code") + @ExcludeMissing + finchCode: JsonField = JsonMissing.of(), + ) : this(code, message, name, finchCode, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun code(): Double = code.getRequired("code") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun message(): String = message.getRequired("message") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun name(): String = name.getRequired("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun finchCode(): Optional = finchCode.getOptional("finch_code") + + /** + * Returns the raw JSON value of [code]. + * + * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + /** + * Returns the raw JSON value of [message]. + * + * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [finchCode]. + * + * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("finch_code") + @ExcludeMissing + fun _finchCode(): JsonField = finchCode + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [BatchError]. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .name() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [BatchError]. */ + class Builder internal constructor() { + + private var code: JsonField? = null + private var message: JsonField? = null + private var name: JsonField? = null + private var finchCode: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(batchError: BatchError) = apply { + code = batchError.code + message = batchError.message + name = batchError.name + finchCode = batchError.finchCode + additionalProperties = batchError.additionalProperties.toMutableMap() + } + + fun code(code: Double) = code(JsonField.of(code)) + + /** + * Sets [Builder.code] to an arbitrary JSON value. + * + * You should usually call [Builder.code] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun code(code: JsonField) = apply { this.code = code } + + fun message(message: String) = message(JsonField.of(message)) + + /** + * Sets [Builder.message] to an arbitrary JSON value. + * + * You should usually call [Builder.message] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun message(message: JsonField) = apply { this.message = message } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun finchCode(finchCode: String) = finchCode(JsonField.of(finchCode)) + + /** + * Sets [Builder.finchCode] to an arbitrary JSON value. + * + * You should usually call [Builder.finchCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [BatchError]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .code() + * .message() + * .name() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): BatchError = + BatchError( + checkRequired("code", code), + checkRequired("message", message), + checkRequired("name", name), + finchCode, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): BatchError = apply { + if (validated) { + return@apply + } + + code() + message() + name() + finchCode() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (code.asKnown().isPresent) 1 else 0) + + (if (message.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (finchCode.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is BatchError && code == other.code && message == other.message && name == other.name && finchCode == other.finchCode && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(code, message, name, finchCode, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "BatchError{code=$code, message=$message, name=$name, finchCode=$finchCode, additionalProperties=$additionalProperties}" + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt index 8d6d15f8..712d6020 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementResponseBody.kt @@ -6,24 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.core.JsonGenerator -import com.fasterxml.jackson.core.ObjectCodec -import com.fasterxml.jackson.databind.JsonNode -import com.fasterxml.jackson.databind.SerializerProvider -import com.fasterxml.jackson.databind.annotation.JsonDeserialize -import com.fasterxml.jackson.databind.annotation.JsonSerialize -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.tryfinch.api.core.BaseDeserializer -import com.tryfinch.api.core.BaseSerializer -import com.tryfinch.api.core.Enum import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.core.allMaxBy import com.tryfinch.api.core.checkKnown import com.tryfinch.api.core.checkRequired -import com.tryfinch.api.core.getOrThrow import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections @@ -31,250 +19,237 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull -@JsonDeserialize(using = PayStatementResponseBody.Deserializer::class) -@JsonSerialize(using = PayStatementResponseBody.Serializer::class) class PayStatementResponseBody private constructor( - private val unionMember0: UnionMember0? = null, - private val batchError: BatchError? = null, - private val unionMember2: UnionMember2? = null, - private val _json: JsonValue? = null, + private val paging: JsonField, + private val payStatements: JsonField>, + private val additionalProperties: MutableMap, ) { - fun unionMember0(): Optional = Optional.ofNullable(unionMember0) + @JsonCreator + private constructor( + @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), + @JsonProperty("pay_statements") + @ExcludeMissing + payStatements: JsonField> = JsonMissing.of(), + ) : this(paging, payStatements, mutableMapOf()) - fun batchError(): Optional = Optional.ofNullable(batchError) + /** + * @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") - fun unionMember2(): Optional = Optional.ofNullable(unionMember2) + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type or is unexpectedly + * missing or null (e.g. if the server responded with an unexpected value). + */ + fun payStatements(): List = payStatements.getRequired("pay_statements") - fun isUnionMember0(): Boolean = unionMember0 != null + /** + * 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 - fun isBatchError(): Boolean = batchError != null + /** + * Returns the raw JSON value of [payStatements]. + * + * Unlike [payStatements], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pay_statements") + @ExcludeMissing + fun _payStatements(): JsonField> = payStatements - fun isUnionMember2(): Boolean = unionMember2 != null + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } - fun asUnionMember0(): UnionMember0 = unionMember0.getOrThrow("unionMember0") + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) - fun asBatchError(): BatchError = batchError.getOrThrow("batchError") + fun toBuilder() = Builder().from(this) - fun asUnionMember2(): UnionMember2 = unionMember2.getOrThrow("unionMember2") + companion object { - fun _json(): Optional = Optional.ofNullable(_json) + /** + * Returns a mutable builder for constructing an instance of [PayStatementResponseBody]. + * + * The following fields are required: + * ```java + * .paging() + * .payStatements() + * ``` + */ + @JvmStatic fun builder() = Builder() + } - fun accept(visitor: Visitor): T = - when { - unionMember0 != null -> visitor.visitUnionMember0(unionMember0) - batchError != null -> visitor.visitBatchError(batchError) - unionMember2 != null -> visitor.visitUnionMember2(unionMember2) - else -> visitor.unknown(_json) - } + /** A builder for [PayStatementResponseBody]. */ + class Builder internal constructor() { - private var validated: Boolean = false + private var paging: JsonField? = null + private var payStatements: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() - fun validate(): PayStatementResponseBody = apply { - if (validated) { - return@apply + @JvmSynthetic + internal fun from(payStatementResponseBody: PayStatementResponseBody) = apply { + paging = payStatementResponseBody.paging + payStatements = payStatementResponseBody.payStatements.map { it.toMutableList() } + additionalProperties = payStatementResponseBody.additionalProperties.toMutableMap() } - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) { - unionMember0.validate() - } + fun paging(paging: Paging) = paging(JsonField.of(paging)) - override fun visitBatchError(batchError: BatchError) { - batchError.validate() - } + /** + * 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 } - override fun visitUnionMember2(unionMember2: UnionMember2) { - unionMember2.validate() - } - } - ) - validated = true - } + fun payStatements(payStatements: List) = + payStatements(JsonField.of(payStatements)) - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false + /** + * Sets [Builder.payStatements] to an arbitrary JSON value. + * + * You should usually call [Builder.payStatements] with a well-typed `List` + * value instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun payStatements(payStatements: JsonField>) = apply { + this.payStatements = payStatements.map { it.toMutableList() } } - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - accept( - object : Visitor { - override fun visitUnionMember0(unionMember0: UnionMember0) = unionMember0.validity() - - override fun visitBatchError(batchError: BatchError) = batchError.validity() - - override fun visitUnionMember2(unionMember2: UnionMember2) = unionMember2.validity() - - override fun unknown(json: JsonValue?) = 0 - } - ) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true + /** + * Adds a single [PayStatement] to [payStatements]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addPayStatement(payStatement: PayStatement) = apply { + payStatements = + (payStatements ?: JsonField.of(mutableListOf())).also { + checkKnown("payStatements", it).add(payStatement) + } } - return /* spotless:off */ other is PayStatementResponseBody && unionMember0 == other.unionMember0 && batchError == other.batchError && unionMember2 == other.unionMember2 /* spotless:on */ - } - - override fun hashCode(): Int = /* spotless:off */ Objects.hash(unionMember0, batchError, unionMember2) /* spotless:on */ - - override fun toString(): String = - when { - unionMember0 != null -> "PayStatementResponseBody{unionMember0=$unionMember0}" - batchError != null -> "PayStatementResponseBody{batchError=$batchError}" - unionMember2 != null -> "PayStatementResponseBody{unionMember2=$unionMember2}" - _json != null -> "PayStatementResponseBody{_unknown=$_json}" - else -> throw IllegalStateException("Invalid PayStatementResponseBody") + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) } - companion object { - - @JvmStatic - fun ofUnionMember0(unionMember0: UnionMember0) = - PayStatementResponseBody(unionMember0 = unionMember0) - - @JvmStatic - fun ofBatchError(batchError: BatchError) = PayStatementResponseBody(batchError = batchError) - - @JvmStatic - fun ofUnionMember2(unionMember2: UnionMember2) = - PayStatementResponseBody(unionMember2 = unionMember2) - } - - /** - * An interface that defines how to map each variant of [PayStatementResponseBody] to a value of - * type [T]. - */ - interface Visitor { + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } - fun visitUnionMember0(unionMember0: UnionMember0): T + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } - fun visitBatchError(batchError: BatchError): T + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - fun visitUnionMember2(unionMember2: UnionMember2): T + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } /** - * Maps an unknown variant of [PayStatementResponseBody] to a value of type [T]. + * Returns an immutable instance of [PayStatementResponseBody]. + * + * Further updates to this [Builder] will not mutate the returned instance. * - * An instance of [PayStatementResponseBody] can contain an unknown variant if it was - * deserialized from data that doesn't match any known variant. For example, if the SDK is - * on an older version than the API, then the API may respond with new variants that the SDK - * is unaware of. + * The following fields are required: + * ```java + * .paging() + * .payStatements() + * ``` * - * @throws FinchInvalidDataException in the default implementation. + * @throws IllegalStateException if any required field is unset. */ - fun unknown(json: JsonValue?): T { - throw FinchInvalidDataException("Unknown PayStatementResponseBody: $json") - } + fun build(): PayStatementResponseBody = + PayStatementResponseBody( + checkRequired("paging", paging), + checkRequired("payStatements", payStatements).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) } - internal class Deserializer : - BaseDeserializer(PayStatementResponseBody::class) { - - override fun ObjectCodec.deserialize(node: JsonNode): PayStatementResponseBody { - val json = JsonValue.fromJsonNode(node) + private var validated: Boolean = false - val bestMatches = - sequenceOf( - tryDeserialize(node, jacksonTypeRef())?.let { - PayStatementResponseBody(unionMember0 = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - PayStatementResponseBody(batchError = it, _json = json) - }, - tryDeserialize(node, jacksonTypeRef())?.let { - PayStatementResponseBody(unionMember2 = it, _json = json) - }, - ) - .filterNotNull() - .allMaxBy { it.validity() } - .toList() - return when (bestMatches.size) { - // This can happen if what we're deserializing is completely incompatible with all - // the possible variants (e.g. deserializing from boolean). - 0 -> PayStatementResponseBody(_json = json) - 1 -> bestMatches.single() - // If there's more than one match with the highest validity, then use the first - // completely valid match, or simply the first match if none are completely valid. - else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first() - } + fun validate(): PayStatementResponseBody = apply { + if (validated) { + return@apply } - } - internal class Serializer : - BaseSerializer(PayStatementResponseBody::class) { + paging().validate() + payStatements().forEach { it.validate() } + validated = true + } - override fun serialize( - value: PayStatementResponseBody, - generator: JsonGenerator, - provider: SerializerProvider, - ) { - when { - value.unionMember0 != null -> generator.writeObject(value.unionMember0) - value.batchError != null -> generator.writeObject(value.batchError) - value.unionMember2 != null -> generator.writeObject(value.unionMember2) - value._json != null -> generator.writeObject(value._json) - else -> throw IllegalStateException("Invalid PayStatementResponseBody") - } + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false } - } - class UnionMember0 + /** + * 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 = + (paging.asKnown().getOrNull()?.validity() ?: 0) + + (payStatements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Paging private constructor( - private val paging: JsonField, - private val payStatements: JsonField>, + private val offset: JsonField, + private val count: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("paging") @ExcludeMissing paging: JsonField = JsonMissing.of(), - @JsonProperty("pay_statements") - @ExcludeMissing - payStatements: JsonField> = JsonMissing.of(), - ) : this(paging, payStatements, mutableMapOf()) + @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), + @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), + ) : this(offset, count, mutableMapOf()) /** + * The current start index of the returned list of elements + * * @throws FinchInvalidDataException if the JSON field has an unexpected type or is * unexpectedly missing or null (e.g. if the server responded with an unexpected value). */ - fun paging(): Paging = paging.getRequired("paging") + fun offset(): Long = offset.getRequired("offset") /** - * @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). + * The total number of elements for the entire query (not just the given page) + * + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). */ - fun payStatements(): List = payStatements.getRequired("pay_statements") + fun count(): Optional = count.getOptional("count") /** - * Returns the raw JSON value of [paging]. + * Returns the raw JSON value of [offset]. * - * Unlike [paging], this method doesn't throw if the JSON field has an unexpected type. + * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset /** - * Returns the raw JSON value of [payStatements]. + * Returns the raw JSON value of [count]. * - * Unlike [payStatements], this method doesn't throw if the JSON field has an unexpected - * type. + * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("pay_statements") - @ExcludeMissing - fun _payStatements(): JsonField> = payStatements + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -291,67 +266,53 @@ private constructor( companion object { /** - * Returns a mutable builder for constructing an instance of [UnionMember0]. + * Returns a mutable builder for constructing an instance of [Paging]. * * The following fields are required: * ```java - * .paging() - * .payStatements() + * .offset() * ``` */ @JvmStatic fun builder() = Builder() } - /** A builder for [UnionMember0]. */ + /** A builder for [Paging]. */ class Builder internal constructor() { - private var paging: JsonField? = null - private var payStatements: JsonField>? = null + private var offset: JsonField? = null + private var count: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(unionMember0: UnionMember0) = apply { - paging = unionMember0.paging - payStatements = unionMember0.payStatements.map { it.toMutableList() } - additionalProperties = unionMember0.additionalProperties.toMutableMap() + internal fun from(paging: Paging) = apply { + offset = paging.offset + count = paging.count + additionalProperties = paging.additionalProperties.toMutableMap() } - fun paging(paging: Paging) = paging(JsonField.of(paging)) + /** The current start index of the returned list of elements */ + fun offset(offset: Long) = offset(JsonField.of(offset)) /** - * Sets [Builder.paging] to an arbitrary JSON value. + * Sets [Builder.offset] 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. + * You should usually call [Builder.offset] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun paging(paging: JsonField) = apply { this.paging = paging } - - fun payStatements(payStatements: List) = - payStatements(JsonField.of(payStatements)) + fun offset(offset: JsonField) = apply { this.offset = offset } - /** - * Sets [Builder.payStatements] to an arbitrary JSON value. - * - * You should usually call [Builder.payStatements] with a well-typed - * `List` value instead. This method is primarily for setting the field to - * an undocumented or not yet supported value. - */ - fun payStatements(payStatements: JsonField>) = apply { - this.payStatements = payStatements.map { it.toMutableList() } - } + /** The total number of elements for the entire query (not just the given page) */ + fun count(count: Long) = count(JsonField.of(count)) /** - * Adds a single [PayStatement] to [payStatements]. + * Sets [Builder.count] to an arbitrary JSON value. * - * @throws IllegalStateException if the field was previously set to a non-list. + * You should usually call [Builder.count] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun addPayStatement(payStatement: PayStatement) = apply { - payStatements = - (payStatements ?: JsonField.of(mutableListOf())).also { - checkKnown("payStatements", it).add(payStatement) - } - } + fun count(count: JsonField) = apply { this.count = count } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -373,35 +334,30 @@ private constructor( } /** - * Returns an immutable instance of [UnionMember0]. + * Returns an immutable instance of [Paging]. * * Further updates to this [Builder] will not mutate the returned instance. * * The following fields are required: * ```java - * .paging() - * .payStatements() + * .offset() * ``` * * @throws IllegalStateException if any required field is unset. */ - fun build(): UnionMember0 = - UnionMember0( - checkRequired("paging", paging), - checkRequired("payStatements", payStatements).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) + fun build(): Paging = + Paging(checkRequired("offset", offset), count, additionalProperties.toMutableMap()) } private var validated: Boolean = false - fun validate(): UnionMember0 = apply { + fun validate(): Paging = apply { if (validated) { return@apply } - paging().validate() - payStatements().forEach { it.validate() } + offset() + count() validated = true } @@ -421,5919 +377,40 @@ private constructor( */ @JvmSynthetic internal fun validity(): Int = - (paging.asKnown().getOrNull()?.validity() ?: 0) + - (payStatements.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) - - class Paging - private constructor( - private val offset: JsonField, - private val count: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("offset") @ExcludeMissing offset: JsonField = JsonMissing.of(), - @JsonProperty("count") @ExcludeMissing count: JsonField = JsonMissing.of(), - ) : this(offset, count, mutableMapOf()) - - /** - * The current start index of the returned list of elements - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun offset(): Long = offset.getRequired("offset") - - /** - * The total number of elements for the entire query (not just the given page) - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun count(): Optional = count.getOptional("count") - - /** - * Returns the raw JSON value of [offset]. - * - * Unlike [offset], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset - - /** - * Returns the raw JSON value of [count]. - * - * Unlike [count], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Paging]. - * - * The following fields are required: - * ```java - * .offset() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Paging]. */ - class Builder internal constructor() { - - private var offset: JsonField? = null - private var count: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(paging: Paging) = apply { - offset = paging.offset - count = paging.count - additionalProperties = paging.additionalProperties.toMutableMap() - } - - /** The current start index of the returned list of elements */ - fun offset(offset: Long) = offset(JsonField.of(offset)) - - /** - * Sets [Builder.offset] to an arbitrary JSON value. - * - * You should usually call [Builder.offset] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun offset(offset: JsonField) = apply { this.offset = offset } - - /** The total number of elements for the entire query (not just the given page) */ - fun count(count: Long) = count(JsonField.of(count)) - - /** - * Sets [Builder.count] to an arbitrary JSON value. - * - * You should usually call [Builder.count] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun count(count: JsonField) = apply { this.count = count } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } + (if (offset.asKnown().isPresent) 1 else 0) + (if (count.asKnown().isPresent) 1 else 0) - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Paging]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .offset() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Paging = - Paging( - checkRequired("offset", offset), - count, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Paging = apply { - if (validated) { - return@apply - } - - offset() - count() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (offset.asKnown().isPresent) 1 else 0) + - (if (count.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Paging && offset == other.offset && count == other.count && additionalProperties == other.additionalProperties /* spotless:on */ + override fun equals(other: Any?): Boolean { + if (this === other) { + return true } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(offset, count, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Paging{offset=$offset, count=$count, additionalProperties=$additionalProperties}" + return /* spotless:off */ other is Paging && offset == other.offset && count == other.count && additionalProperties == other.additionalProperties /* spotless:on */ } - class PayStatement - private constructor( - private val earnings: JsonField>, - private val employeeDeductions: JsonField>, - private val employerContributions: JsonField>, - private val grossPay: JsonField, - private val individualId: JsonField, - private val netPay: JsonField, - private val paymentMethod: JsonField, - private val taxes: JsonField>, - private val totalHours: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("earnings") - @ExcludeMissing - earnings: JsonField> = JsonMissing.of(), - @JsonProperty("employee_deductions") - @ExcludeMissing - employeeDeductions: JsonField> = JsonMissing.of(), - @JsonProperty("employer_contributions") - @ExcludeMissing - employerContributions: JsonField> = JsonMissing.of(), - @JsonProperty("gross_pay") - @ExcludeMissing - grossPay: JsonField = JsonMissing.of(), - @JsonProperty("individual_id") - @ExcludeMissing - individualId: JsonField = JsonMissing.of(), - @JsonProperty("net_pay") - @ExcludeMissing - netPay: JsonField = JsonMissing.of(), - @JsonProperty("payment_method") - @ExcludeMissing - paymentMethod: JsonField = JsonMissing.of(), - @JsonProperty("taxes") - @ExcludeMissing - taxes: JsonField> = JsonMissing.of(), - @JsonProperty("total_hours") - @ExcludeMissing - totalHours: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this( - earnings, - employeeDeductions, - employerContributions, - grossPay, - individualId, - netPay, - paymentMethod, - taxes, - totalHours, - type, - mutableMapOf(), - ) - - /** - * The array of earnings objects associated with this pay statement - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun earnings(): Optional> = earnings.getOptional("earnings") - - /** - * The array of deductions objects associated with this pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun employeeDeductions(): Optional> = - employeeDeductions.getOptional("employee_deductions") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun employerContributions(): Optional> = - employerContributions.getOptional("employer_contributions") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun grossPay(): Optional = grossPay.getOptional("gross_pay") - - /** - * A stable Finch `id` (UUID v4) for an individual in the company - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun individualId(): String = individualId.getRequired("individual_id") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun netPay(): Optional = netPay.getOptional("net_pay") - - /** - * The payment method. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun paymentMethod(): Optional = - paymentMethod.getOptional("payment_method") - - /** - * The array of taxes objects associated with this pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun taxes(): Optional> = taxes.getOptional("taxes") - - /** - * The number of hours worked for this pay period - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun totalHours(): Optional = totalHours.getOptional("total_hours") - - /** - * The type of the payment associated with the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(offset, count, additionalProperties) } + /* spotless:on */ - /** - * Returns the raw JSON value of [earnings]. - * - * Unlike [earnings], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("earnings") - @ExcludeMissing - fun _earnings(): JsonField> = earnings + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [employeeDeductions]. - * - * Unlike [employeeDeductions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("employee_deductions") - @ExcludeMissing - fun _employeeDeductions(): JsonField> = employeeDeductions + override fun toString() = + "Paging{offset=$offset, count=$count, additionalProperties=$additionalProperties}" + } - /** - * Returns the raw JSON value of [employerContributions]. - * - * Unlike [employerContributions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("employer_contributions") - @ExcludeMissing - fun _employerContributions(): JsonField> = - employerContributions + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } - /** - * Returns the raw JSON value of [grossPay]. - * - * Unlike [grossPay], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay + return /* spotless:off */ other is PayStatementResponseBody && paging == other.paging && payStatements == other.payStatements && additionalProperties == other.additionalProperties /* spotless:on */ + } - /** - * Returns the raw JSON value of [individualId]. - * - * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("individual_id") - @ExcludeMissing - fun _individualId(): JsonField = individualId + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(paging, payStatements, additionalProperties) } + /* spotless:on */ - /** - * Returns the raw JSON value of [netPay]. - * - * Unlike [netPay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay + override fun hashCode(): Int = hashCode - /** - * Returns the raw JSON value of [paymentMethod]. - * - * Unlike [paymentMethod], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("payment_method") - @ExcludeMissing - fun _paymentMethod(): JsonField = paymentMethod - - /** - * Returns the raw JSON value of [taxes]. - * - * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes - - /** - * Returns the raw JSON value of [totalHours]. - * - * Unlike [totalHours], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("total_hours") - @ExcludeMissing - fun _totalHours(): JsonField = totalHours - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [PayStatement]. - * - * The following fields are required: - * ```java - * .earnings() - * .employeeDeductions() - * .employerContributions() - * .grossPay() - * .individualId() - * .netPay() - * .paymentMethod() - * .taxes() - * .totalHours() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PayStatement]. */ - class Builder internal constructor() { - - private var earnings: JsonField>? = null - private var employeeDeductions: JsonField>? = null - private var employerContributions: JsonField>? = - null - private var grossPay: JsonField? = null - private var individualId: JsonField? = null - private var netPay: JsonField? = null - private var paymentMethod: JsonField? = null - private var taxes: JsonField>? = null - private var totalHours: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(payStatement: PayStatement) = apply { - earnings = payStatement.earnings.map { it.toMutableList() } - employeeDeductions = payStatement.employeeDeductions.map { it.toMutableList() } - employerContributions = - payStatement.employerContributions.map { it.toMutableList() } - grossPay = payStatement.grossPay - individualId = payStatement.individualId - netPay = payStatement.netPay - paymentMethod = payStatement.paymentMethod - taxes = payStatement.taxes.map { it.toMutableList() } - totalHours = payStatement.totalHours - type = payStatement.type - additionalProperties = payStatement.additionalProperties.toMutableMap() - } - - /** The array of earnings objects associated with this pay statement */ - fun earnings(earnings: List?) = earnings(JsonField.ofNullable(earnings)) - - /** Alias for calling [Builder.earnings] with `earnings.orElse(null)`. */ - fun earnings(earnings: Optional>) = earnings(earnings.getOrNull()) - - /** - * Sets [Builder.earnings] to an arbitrary JSON value. - * - * You should usually call [Builder.earnings] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun earnings(earnings: JsonField>) = apply { - this.earnings = earnings.map { it.toMutableList() } - } - - /** - * Adds a single [Earning] to [earnings]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEarning(earning: Earning) = apply { - earnings = - (earnings ?: JsonField.of(mutableListOf())).also { - checkKnown("earnings", it).add(earning) - } - } - - /** The array of deductions objects associated with this pay statement. */ - fun employeeDeductions(employeeDeductions: List?) = - employeeDeductions(JsonField.ofNullable(employeeDeductions)) - - /** - * Alias for calling [Builder.employeeDeductions] with - * `employeeDeductions.orElse(null)`. - */ - fun employeeDeductions(employeeDeductions: Optional>) = - employeeDeductions(employeeDeductions.getOrNull()) - - /** - * Sets [Builder.employeeDeductions] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeDeductions] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun employeeDeductions(employeeDeductions: JsonField>) = - apply { - this.employeeDeductions = employeeDeductions.map { it.toMutableList() } - } - - /** - * Adds a single [EmployeeDeduction] to [employeeDeductions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { - employeeDeductions = - (employeeDeductions ?: JsonField.of(mutableListOf())).also { - checkKnown("employeeDeductions", it).add(employeeDeduction) - } - } - - fun employerContributions(employerContributions: List?) = - employerContributions(JsonField.ofNullable(employerContributions)) - - /** - * Alias for calling [Builder.employerContributions] with - * `employerContributions.orElse(null)`. - */ - fun employerContributions( - employerContributions: Optional> - ) = employerContributions(employerContributions.getOrNull()) - - /** - * Sets [Builder.employerContributions] to an arbitrary JSON value. - * - * You should usually call [Builder.employerContributions] with a well-typed - * `List` value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun employerContributions( - employerContributions: JsonField> - ) = apply { - this.employerContributions = employerContributions.map { it.toMutableList() } - } - - /** - * Adds a single [EmployerContribution] to [employerContributions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployerContribution(employerContribution: EmployerContribution) = apply { - employerContributions = - (employerContributions ?: JsonField.of(mutableListOf())).also { - checkKnown("employerContributions", it).add(employerContribution) - } - } - - fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) - - /** Alias for calling [Builder.grossPay] with `grossPay.orElse(null)`. */ - fun grossPay(grossPay: Optional) = grossPay(grossPay.getOrNull()) - - /** - * Sets [Builder.grossPay] to an arbitrary JSON value. - * - * You should usually call [Builder.grossPay] with a well-typed [Money] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } - - /** A stable Finch `id` (UUID v4) for an individual in the company */ - fun individualId(individualId: String) = individualId(JsonField.of(individualId)) - - /** - * Sets [Builder.individualId] to an arbitrary JSON value. - * - * You should usually call [Builder.individualId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun individualId(individualId: JsonField) = apply { - this.individualId = individualId - } - - fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) - - /** Alias for calling [Builder.netPay] with `netPay.orElse(null)`. */ - fun netPay(netPay: Optional) = netPay(netPay.getOrNull()) - - /** - * Sets [Builder.netPay] to an arbitrary JSON value. - * - * You should usually call [Builder.netPay] with a well-typed [Money] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun netPay(netPay: JsonField) = apply { this.netPay = netPay } - - /** The payment method. */ - fun paymentMethod(paymentMethod: PaymentMethod?) = - paymentMethod(JsonField.ofNullable(paymentMethod)) - - /** Alias for calling [Builder.paymentMethod] with `paymentMethod.orElse(null)`. */ - fun paymentMethod(paymentMethod: Optional) = - paymentMethod(paymentMethod.getOrNull()) - - /** - * Sets [Builder.paymentMethod] to an arbitrary JSON value. - * - * You should usually call [Builder.paymentMethod] with a well-typed [PaymentMethod] - * value instead. This method is primarily for setting the field to an undocumented - * or not yet supported value. - */ - fun paymentMethod(paymentMethod: JsonField) = apply { - this.paymentMethod = paymentMethod - } - - /** The array of taxes objects associated with this pay statement. */ - fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) - - /** Alias for calling [Builder.taxes] with `taxes.orElse(null)`. */ - fun taxes(taxes: Optional>) = taxes(taxes.getOrNull()) - - /** - * Sets [Builder.taxes] to an arbitrary JSON value. - * - * You should usually call [Builder.taxes] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun taxes(taxes: JsonField>) = apply { - this.taxes = taxes.map { it.toMutableList() } - } - - /** - * Adds a single [Tax] to [taxes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTax(tax: Tax) = apply { - taxes = - (taxes ?: JsonField.of(mutableListOf())).also { - checkKnown("taxes", it).add(tax) - } - } - - /** The number of hours worked for this pay period */ - fun totalHours(totalHours: Double?) = totalHours(JsonField.ofNullable(totalHours)) - - /** - * Alias for [Builder.totalHours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun totalHours(totalHours: Double) = totalHours(totalHours as Double?) - - /** Alias for calling [Builder.totalHours] with `totalHours.orElse(null)`. */ - fun totalHours(totalHours: Optional) = totalHours(totalHours.getOrNull()) - - /** - * Sets [Builder.totalHours] to an arbitrary JSON value. - * - * You should usually call [Builder.totalHours] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun totalHours(totalHours: JsonField) = apply { - this.totalHours = totalHours - } - - /** The type of the payment associated with the pay statement. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PayStatement]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .earnings() - * .employeeDeductions() - * .employerContributions() - * .grossPay() - * .individualId() - * .netPay() - * .paymentMethod() - * .taxes() - * .totalHours() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PayStatement = - PayStatement( - checkRequired("earnings", earnings).map { it.toImmutable() }, - checkRequired("employeeDeductions", employeeDeductions).map { - it.toImmutable() - }, - checkRequired("employerContributions", employerContributions).map { - it.toImmutable() - }, - checkRequired("grossPay", grossPay), - checkRequired("individualId", individualId), - checkRequired("netPay", netPay), - checkRequired("paymentMethod", paymentMethod), - checkRequired("taxes", taxes).map { it.toImmutable() }, - checkRequired("totalHours", totalHours), - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PayStatement = apply { - if (validated) { - return@apply - } - - earnings().ifPresent { it.forEach { it?.validate() } } - employeeDeductions().ifPresent { it.forEach { it?.validate() } } - employerContributions().ifPresent { it.forEach { it?.validate() } } - grossPay().ifPresent { it.validate() } - individualId() - netPay().ifPresent { it.validate() } - paymentMethod().ifPresent { it.validate() } - taxes().ifPresent { it.forEach { it?.validate() } } - totalHours() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (earnings.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (employeeDeductions.asKnown().getOrNull()?.sumOf { - (it?.validity() ?: 0).toInt() - } ?: 0) + - (employerContributions.asKnown().getOrNull()?.sumOf { - (it?.validity() ?: 0).toInt() - } ?: 0) + - (grossPay.asKnown().getOrNull()?.validity() ?: 0) + - (if (individualId.asKnown().isPresent) 1 else 0) + - (netPay.asKnown().getOrNull()?.validity() ?: 0) + - (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + - (taxes.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (if (totalHours.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Earning - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val hours: JsonField, - private val name: JsonField, - private val type: JsonField, - private val attributes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("hours") - @ExcludeMissing - hours: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - ) : this(amount, currency, hours, name, type, attributes, mutableMapOf()) - - /** - * The earnings amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * The earnings currency code. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The number of hours associated with this earning. (For salaried employees, this - * could be hours per pay period, `0` or `null`, depending on the provider). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun hours(): Optional = hours.getOptional("hours") - - /** - * The exact name of the deduction from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The type of earning. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [hours]. - * - * Unlike [hours], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField = hours - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Earning]. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * .hours() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Earning]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var currency: JsonField? = null - private var hours: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var attributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(earning: Earning) = apply { - amount = earning.amount - currency = earning.currency - hours = earning.hours - name = earning.name - type = earning.type - attributes = earning.attributes - additionalProperties = earning.additionalProperties.toMutableMap() - } - - /** The earnings amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The earnings currency code. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * The number of hours associated with this earning. (For salaried employees, - * this could be hours per pay period, `0` or `null`, depending on the - * provider). - */ - fun hours(hours: Double?) = hours(JsonField.ofNullable(hours)) - - /** - * Alias for [Builder.hours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hours(hours: Double) = hours(hours as Double?) - - /** Alias for calling [Builder.hours] with `hours.orElse(null)`. */ - fun hours(hours: Optional) = hours(hours.getOrNull()) - - /** - * Sets [Builder.hours] to an arbitrary JSON value. - * - * You should usually call [Builder.hours] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun hours(hours: JsonField) = apply { this.hours = hours } - - /** The exact name of the deduction from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The type of earning. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Earning]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * .hours() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Earning = - Earning( - checkRequired("amount", amount), - checkRequired("currency", currency), - checkRequired("hours", hours), - checkRequired("name", name), - checkRequired("type", type), - attributes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Earning = apply { - if (validated) { - return@apply - } - - amount() - currency() - hours() - name() - type().ifPresent { it.validate() } - attributes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (hours.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) - - /** The type of earning. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val SALARY = of("salary") - - @JvmField val WAGE = of("wage") - - @JvmField val REIMBURSEMENT = of("reimbursement") - - @JvmField val OVERTIME = of("overtime") - - @JvmField val SEVERANCE = of("severance") - - @JvmField val DOUBLE_OVERTIME = of("double_overtime") - - @JvmField val PTO = of("pto") - - @JvmField val SICK = of("sick") - - @JvmField val BONUS = of("bonus") - - @JvmField val COMMISSION = of("commission") - - @JvmField val TIPS = of("tips") - - @JvmField val _1099 = of("1099") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - OTHER, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - OTHER, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SALARY -> Value.SALARY - WAGE -> Value.WAGE - REIMBURSEMENT -> Value.REIMBURSEMENT - OVERTIME -> Value.OVERTIME - SEVERANCE -> Value.SEVERANCE - DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME - PTO -> Value.PTO - SICK -> Value.SICK - BONUS -> Value.BONUS - COMMISSION -> Value.COMMISSION - TIPS -> Value.TIPS - _1099 -> Value._1099 - OTHER -> Value.OTHER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - SALARY -> Known.SALARY - WAGE -> Known.WAGE - REIMBURSEMENT -> Known.REIMBURSEMENT - OVERTIME -> Known.OVERTIME - SEVERANCE -> Known.SEVERANCE - DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME - PTO -> Known.PTO - SICK -> Known.SICK - BONUS -> Known.BONUS - COMMISSION -> Known.COMMISSION - TIPS -> Known.TIPS - _1099 -> Known._1099 - OTHER -> Known.OTHER - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Attributes]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Attributes = - Attributes( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Earning && amount == other.amount && currency == other.currency && hours == other.hours && name == other.name && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, currency, hours, name, type, attributes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Earning{amount=$amount, currency=$currency, hours=$hours, name=$name, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" - } - - class EmployeeDeduction - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val name: JsonField, - private val preTax: JsonField, - private val type: JsonField, - private val attributes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("pre_tax") - @ExcludeMissing - preTax: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - ) : this(amount, currency, name, preTax, type, attributes, mutableMapOf()) - - /** - * The deduction amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * The deduction currency. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The deduction name from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Boolean indicating if the deduction is pre-tax. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun preTax(): Optional = preTax.getOptional("pre_tax") - - /** - * Type of benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [preTax]. - * - * Unlike [preTax], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("pre_tax") @ExcludeMissing fun _preTax(): JsonField = preTax - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [EmployeeDeduction]. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * .name() - * .preTax() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmployeeDeduction]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var currency: JsonField? = null - private var name: JsonField? = null - private var preTax: JsonField? = null - private var type: JsonField? = null - private var attributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employeeDeduction: EmployeeDeduction) = apply { - amount = employeeDeduction.amount - currency = employeeDeduction.currency - name = employeeDeduction.name - preTax = employeeDeduction.preTax - type = employeeDeduction.type - attributes = employeeDeduction.attributes - additionalProperties = employeeDeduction.additionalProperties.toMutableMap() - } - - /** The deduction amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The deduction currency. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The deduction name from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Boolean indicating if the deduction is pre-tax. */ - fun preTax(preTax: Boolean?) = preTax(JsonField.ofNullable(preTax)) - - /** - * Alias for [Builder.preTax]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preTax(preTax: Boolean) = preTax(preTax as Boolean?) - - /** Alias for calling [Builder.preTax] with `preTax.orElse(null)`. */ - fun preTax(preTax: Optional) = preTax(preTax.getOrNull()) - - /** - * Sets [Builder.preTax] to an arbitrary JSON value. - * - * You should usually call [Builder.preTax] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun preTax(preTax: JsonField) = apply { this.preTax = preTax } - - /** Type of benefit. */ - fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [BenefitType] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EmployeeDeduction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * .name() - * .preTax() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EmployeeDeduction = - EmployeeDeduction( - checkRequired("amount", amount), - checkRequired("currency", currency), - checkRequired("name", name), - checkRequired("preTax", preTax), - checkRequired("type", type), - attributes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmployeeDeduction = apply { - if (validated) { - return@apply - } - - amount() - currency() - name() - preTax() - type().ifPresent { it.validate() } - attributes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (preTax.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Attributes]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Attributes = - Attributes( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, currency, name, preTax, type, attributes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmployeeDeduction{amount=$amount, currency=$currency, name=$name, preTax=$preTax, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" - } - - class EmployerContribution - private constructor( - private val currency: JsonField, - private val name: JsonField, - private val type: JsonField, - private val amount: JsonField, - private val attributes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - ) : this(currency, name, type, amount, attributes, mutableMapOf()) - - /** - * The contribution currency. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The contribution name from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Type of benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * The contribution amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [EmployerContribution]. - * - * The following fields are required: - * ```java - * .currency() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmployerContribution]. */ - class Builder internal constructor() { - - private var currency: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employerContribution: EmployerContribution) = apply { - currency = employerContribution.currency - name = employerContribution.name - type = employerContribution.type - amount = employerContribution.amount - attributes = employerContribution.attributes - additionalProperties = - employerContribution.additionalProperties.toMutableMap() - } - - /** The contribution currency. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The contribution name from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Type of benefit. */ - fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [BenefitType] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** The contribution amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - 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 [EmployerContribution]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .currency() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EmployerContribution = - EmployerContribution( - checkRequired("currency", currency), - checkRequired("name", name), - checkRequired("type", type), - amount, - attributes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmployerContribution = apply { - if (validated) { - return@apply - } - - currency() - name() - type().ifPresent { it.validate() } - amount() - attributes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Attributes]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Attributes = - Attributes( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployerContribution && currency == other.currency && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, name, type, amount, attributes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmployerContribution{currency=$currency, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" - } - - /** The payment method. */ - class PaymentMethod - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CHECK = of("check") - - @JvmField val DIRECT_DEPOSIT = of("direct_deposit") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = PaymentMethod(JsonField.of(value)) - } - - /** An enum containing [PaymentMethod]'s known values. */ - enum class Known { - CHECK, - DIRECT_DEPOSIT, - OTHER, - } - - /** - * An enum containing [PaymentMethod]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [PaymentMethod] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CHECK, - DIRECT_DEPOSIT, - OTHER, - /** - * An enum member indicating that [PaymentMethod] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CHECK -> Value.CHECK - DIRECT_DEPOSIT -> Value.DIRECT_DEPOSIT - OTHER -> Value.OTHER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CHECK -> Known.CHECK - DIRECT_DEPOSIT -> Known.DIRECT_DEPOSIT - OTHER -> Known.OTHER - else -> throw FinchInvalidDataException("Unknown PaymentMethod: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): PaymentMethod = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentMethod && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Tax - private constructor( - private val currency: JsonField, - private val employer: JsonField, - private val name: JsonField, - private val type: JsonField, - private val amount: JsonField, - private val attributes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("employer") - @ExcludeMissing - employer: JsonField = JsonMissing.of(), - @JsonProperty("name") - @ExcludeMissing - name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("amount") - @ExcludeMissing - amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - ) : this(currency, employer, name, type, amount, attributes, mutableMapOf()) - - /** - * The currency code. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * `true` if the amount is paid by the employers. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun employer(): Optional = employer.getOptional("employer") - - /** - * The exact name of tax from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The type of taxes. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * The tax amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. - * if the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") - @ExcludeMissing - fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [employer]. - * - * Unlike [employer], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employer") - @ExcludeMissing - fun _employer(): JsonField = employer - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tax]. - * - * The following fields are required: - * ```java - * .currency() - * .employer() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tax]. */ - class Builder internal constructor() { - - private var currency: JsonField? = null - private var employer: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tax: Tax) = apply { - currency = tax.currency - employer = tax.employer - name = tax.name - type = tax.type - amount = tax.amount - attributes = tax.attributes - additionalProperties = tax.additionalProperties.toMutableMap() - } - - /** The currency code. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** `true` if the amount is paid by the employers. */ - fun employer(employer: Boolean?) = employer(JsonField.ofNullable(employer)) - - /** - * Alias for [Builder.employer]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun employer(employer: Boolean) = employer(employer as Boolean?) - - /** Alias for calling [Builder.employer] with `employer.orElse(null)`. */ - fun employer(employer: Optional) = employer(employer.getOrNull()) - - /** - * Sets [Builder.employer] to an arbitrary JSON value. - * - * You should usually call [Builder.employer] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun employer(employer: JsonField) = apply { this.employer = employer } - - /** The exact name of tax from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The type of taxes. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** The tax amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tax]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .currency() - * .employer() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tax = - Tax( - checkRequired("currency", currency), - checkRequired("employer", employer), - checkRequired("name", name), - checkRequired("type", type), - amount, - attributes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tax = apply { - if (validated) { - return@apply - } - - currency() - employer() - name() - type().ifPresent { it.validate() } - amount() - attributes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (currency.asKnown().isPresent) 1 else 0) + - (if (employer.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) - - /** The type of taxes. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue - fun _value(): JsonField = value - - companion object { - - @JvmField val STATE = of("state") - - @JvmField val FEDERAL = of("federal") - - @JvmField val LOCAL = of("local") - - @JvmField val FICA = of("fica") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - STATE, - FEDERAL, - LOCAL, - FICA, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For - * example, if the SDK is on an older version than the API, then the API may - * respond with new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - STATE, - FEDERAL, - LOCAL, - FICA, - /** - * An enum member indicating that [Type] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or - * if you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - STATE -> Value.STATE - FEDERAL -> Value.FEDERAL - LOCAL -> Value.LOCAL - FICA -> Value.FICA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known - * and don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a - * known member. - */ - fun known(): Known = - when (this) { - STATE -> Known.STATE - FEDERAL -> Known.FEDERAL - LOCAL -> Known.LOCAL - FICA -> Known.FICA - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not - * have the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Attributes]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] - * value instead. This method is primarily for setting the field to an - * undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Attributes = - Attributes( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected - * type or is unexpectedly missing or null (e.g. if the server responded - * with an unexpected value). - */ - fun metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting - * the field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties( - additionalProperties: Map - ) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in - * this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tax && currency == other.currency && employer == other.employer && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, employer, name, type, amount, attributes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tax{currency=$currency, employer=$employer, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" - } - - /** The type of the payment associated with the pay statement. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") - - @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") - - @JvmField val REGULAR_PAYROLL = of("regular_payroll") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - OFF_CYCLE_PAYROLL, - ONE_TIME_PAYMENT, - REGULAR_PAYROLL, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - OFF_CYCLE_PAYROLL, - ONE_TIME_PAYMENT, - REGULAR_PAYROLL, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL - ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT - REGULAR_PAYROLL -> Value.REGULAR_PAYROLL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL - ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT - REGULAR_PAYROLL -> Known.REGULAR_PAYROLL - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PayStatement && earnings == other.earnings && employeeDeductions == other.employeeDeductions && employerContributions == other.employerContributions && grossPay == other.grossPay && individualId == other.individualId && netPay == other.netPay && paymentMethod == other.paymentMethod && taxes == other.taxes && totalHours == other.totalHours && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(earnings, employeeDeductions, employerContributions, grossPay, individualId, netPay, paymentMethod, taxes, totalHours, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PayStatement{earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, individualId=$individualId, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnionMember0 && paging == other.paging && payStatements == other.payStatements && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(paging, payStatements, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember0{paging=$paging, payStatements=$payStatements, additionalProperties=$additionalProperties}" - } - - class BatchError - private constructor( - private val code: JsonField, - private val message: JsonField, - private val name: JsonField, - private val finchCode: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("finch_code") - @ExcludeMissing - finchCode: JsonField = JsonMissing.of(), - ) : this(code, message, name, finchCode, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun code(): Double = code.getRequired("code") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun message(): String = message.getRequired("message") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): String = name.getRequired("name") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun finchCode(): Optional = finchCode.getOptional("finch_code") - - /** - * Returns the raw JSON value of [code]. - * - * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [finchCode]. - * - * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("finch_code") @ExcludeMissing fun _finchCode(): JsonField = finchCode - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [BatchError]. - * - * The following fields are required: - * ```java - * .code() - * .message() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BatchError]. */ - class Builder internal constructor() { - - private var code: JsonField? = null - private var message: JsonField? = null - private var name: JsonField? = null - private var finchCode: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(batchError: BatchError) = apply { - code = batchError.code - message = batchError.message - name = batchError.name - finchCode = batchError.finchCode - additionalProperties = batchError.additionalProperties.toMutableMap() - } - - fun code(code: Double) = code(JsonField.of(code)) - - /** - * Sets [Builder.code] to an arbitrary JSON value. - * - * You should usually call [Builder.code] with a well-typed [Double] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun code(code: JsonField) = apply { this.code = code } - - fun message(message: String) = message(JsonField.of(message)) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - fun name(name: String) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun finchCode(finchCode: String) = finchCode(JsonField.of(finchCode)) - - /** - * Sets [Builder.finchCode] to an arbitrary JSON value. - * - * You should usually call [Builder.finchCode] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BatchError]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .code() - * .message() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): BatchError = - BatchError( - checkRequired("code", code), - checkRequired("message", message), - checkRequired("name", name), - finchCode, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BatchError = apply { - if (validated) { - return@apply - } - - code() - message() - name() - finchCode() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (code.asKnown().isPresent) 1 else 0) + - (if (message.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (finchCode.asKnown().isPresent) 1 else 0) - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BatchError && code == other.code && message == other.message && name == other.name && finchCode == other.finchCode && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, message, name, finchCode, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BatchError{code=$code, message=$message, name=$name, finchCode=$finchCode, additionalProperties=$additionalProperties}" - } - - class UnionMember2 - private constructor( - private val code: JsonField, - private val finchCode: JsonField, - private val message: JsonField, - private val name: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("code") @ExcludeMissing code: JsonField = JsonMissing.of(), - @JsonProperty("finch_code") - @ExcludeMissing - finchCode: JsonField = JsonMissing.of(), - @JsonProperty("message") @ExcludeMissing message: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - ) : this(code, finchCode, message, name, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun code(): Code = code.getRequired("code") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun finchCode(): FinchCode = finchCode.getRequired("finch_code") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun message(): Message = message.getRequired("message") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun name(): Name = name.getRequired("name") - - /** - * Returns the raw JSON value of [code]. - * - * Unlike [code], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - - /** - * Returns the raw JSON value of [finchCode]. - * - * Unlike [finchCode], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("finch_code") - @ExcludeMissing - fun _finchCode(): JsonField = finchCode - - /** - * Returns the raw JSON value of [message]. - * - * Unlike [message], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [UnionMember2]. - * - * The following fields are required: - * ```java - * .code() - * .finchCode() - * .message() - * .name() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [UnionMember2]. */ - class Builder internal constructor() { - - private var code: JsonField? = null - private var finchCode: JsonField? = null - private var message: JsonField? = null - private var name: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(unionMember2: UnionMember2) = apply { - code = unionMember2.code - finchCode = unionMember2.finchCode - message = unionMember2.message - name = unionMember2.name - additionalProperties = unionMember2.additionalProperties.toMutableMap() - } - - fun code(code: Code) = code(JsonField.of(code)) - - /** - * Sets [Builder.code] to an arbitrary JSON value. - * - * You should usually call [Builder.code] with a well-typed [Code] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun code(code: JsonField) = apply { this.code = code } - - fun finchCode(finchCode: FinchCode) = finchCode(JsonField.of(finchCode)) - - /** - * Sets [Builder.finchCode] to an arbitrary JSON value. - * - * You should usually call [Builder.finchCode] with a well-typed [FinchCode] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } - - fun message(message: Message) = message(JsonField.of(message)) - - /** - * Sets [Builder.message] to an arbitrary JSON value. - * - * You should usually call [Builder.message] with a well-typed [Message] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun message(message: JsonField) = apply { this.message = message } - - fun name(name: Name) = name(JsonField.of(name)) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [Name] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun name(name: JsonField) = apply { this.name = name } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [UnionMember2]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .code() - * .finchCode() - * .message() - * .name() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): UnionMember2 = - UnionMember2( - checkRequired("code", code), - checkRequired("finchCode", finchCode), - checkRequired("message", message), - checkRequired("name", name), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): UnionMember2 = apply { - if (validated) { - return@apply - } - - code().validate() - finchCode().validate() - message().validate() - name().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (code.asKnown().getOrNull()?.validity() ?: 0) + - (finchCode.asKnown().getOrNull()?.validity() ?: 0) + - (message.asKnown().getOrNull()?.validity() ?: 0) + - (name.asKnown().getOrNull()?.validity() ?: 0) - - class Code @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val _202 = of(202.0) - - @JvmStatic fun of(value: Double) = Code(JsonField.of(value)) - } - - /** An enum containing [Code]'s known values. */ - enum class Known { - _202 - } - - /** - * An enum containing [Code]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Code] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - _202, - /** An enum member indicating that [Code] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - _202 -> Value._202 - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - _202 -> Known._202 - else -> throw FinchInvalidDataException("Unknown Code: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asDouble(): Double = - _value().asNumber().getOrNull()?.toDouble() - ?: throw FinchInvalidDataException("Value is not a Double") - - private var validated: Boolean = false - - fun validate(): Code = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Code && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class FinchCode @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val DATA_SYNC_IN_PROGRESS = of("data_sync_in_progress") - - @JvmStatic fun of(value: String) = FinchCode(JsonField.of(value)) - } - - /** An enum containing [FinchCode]'s known values. */ - enum class Known { - DATA_SYNC_IN_PROGRESS - } - - /** - * An enum containing [FinchCode]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [FinchCode] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - DATA_SYNC_IN_PROGRESS, - /** - * An enum member indicating that [FinchCode] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - DATA_SYNC_IN_PROGRESS -> Value.DATA_SYNC_IN_PROGRESS - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - DATA_SYNC_IN_PROGRESS -> Known.DATA_SYNC_IN_PROGRESS - else -> throw FinchInvalidDataException("Unknown FinchCode: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): FinchCode = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is FinchCode && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Message @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField - val THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER = - of( - "The pay statements for this payment are being fetched. Please check back later." - ) - - @JvmStatic fun of(value: String) = Message(JsonField.of(value)) - } - - /** An enum containing [Message]'s known values. */ - enum class Known { - THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER - } - - /** - * An enum containing [Message]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Message] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER, - /** - * An enum member indicating that [Message] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER -> - Value - .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER -> - Known - .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER - else -> throw FinchInvalidDataException("Unknown Message: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Message = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Message && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Name @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val ACCEPTED = of("accepted") - - @JvmStatic fun of(value: String) = Name(JsonField.of(value)) - } - - /** An enum containing [Name]'s known values. */ - enum class Known { - ACCEPTED - } - - /** - * An enum containing [Name]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Name] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - ACCEPTED, - /** An enum member indicating that [Name] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - ACCEPTED -> Value.ACCEPTED - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - ACCEPTED -> Known.ACCEPTED - else -> throw FinchInvalidDataException("Unknown Name: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Name = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Name && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is UnionMember2 && code == other.code && finchCode == other.finchCode && message == other.message && name == other.name && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(code, finchCode, message, name, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "UnionMember2{code=$code, finchCode=$finchCode, message=$message, name=$name, additionalProperties=$additionalProperties}" - } + override fun toString() = + "PayStatementResponseBody{paging=$paging, payStatements=$payStatements, additionalProperties=$additionalProperties}" } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt index 93cbfe99..0c4073f4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt @@ -6,14 +6,12 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.tryfinch.api.core.Enum import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.Params import com.tryfinch.api.core.checkKnown -import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.toImmutable @@ -526,4590 +524,6 @@ private constructor( "Body{endDate=$endDate, payStatements=$payStatements, startDate=$startDate, additionalProperties=$additionalProperties}" } - class PayStatement - private constructor( - private val earnings: JsonField>, - private val employeeDeductions: JsonField>, - private val employerContributions: JsonField>, - private val grossPay: JsonField, - private val individualId: JsonField, - private val netPay: JsonField, - private val paymentMethod: JsonField, - private val taxes: JsonField>, - private val totalHours: JsonField, - private val type: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("earnings") - @ExcludeMissing - earnings: JsonField> = JsonMissing.of(), - @JsonProperty("employee_deductions") - @ExcludeMissing - employeeDeductions: JsonField> = JsonMissing.of(), - @JsonProperty("employer_contributions") - @ExcludeMissing - employerContributions: JsonField> = JsonMissing.of(), - @JsonProperty("gross_pay") - @ExcludeMissing - grossPay: JsonField = JsonMissing.of(), - @JsonProperty("individual_id") - @ExcludeMissing - individualId: JsonField = JsonMissing.of(), - @JsonProperty("net_pay") @ExcludeMissing netPay: JsonField = JsonMissing.of(), - @JsonProperty("payment_method") - @ExcludeMissing - paymentMethod: JsonField = JsonMissing.of(), - @JsonProperty("taxes") @ExcludeMissing taxes: JsonField> = JsonMissing.of(), - @JsonProperty("total_hours") - @ExcludeMissing - totalHours: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - ) : this( - earnings, - employeeDeductions, - employerContributions, - grossPay, - individualId, - netPay, - paymentMethod, - taxes, - totalHours, - type, - mutableMapOf(), - ) - - /** - * The array of earnings objects associated with this pay statement - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun earnings(): Optional> = earnings.getOptional("earnings") - - /** - * The array of deductions objects associated with this pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employeeDeductions(): Optional> = - employeeDeductions.getOptional("employee_deductions") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employerContributions(): Optional> = - employerContributions.getOptional("employer_contributions") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun grossPay(): Optional = grossPay.getOptional("gross_pay") - - /** - * A stable Finch `id` (UUID v4) for an individual in the company - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected value). - */ - fun individualId(): String = individualId.getRequired("individual_id") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun netPay(): Optional = netPay.getOptional("net_pay") - - /** - * The payment method. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun paymentMethod(): Optional = paymentMethod.getOptional("payment_method") - - /** - * The array of taxes objects associated with this pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun taxes(): Optional> = taxes.getOptional("taxes") - - /** - * The number of hours worked for this pay period - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun totalHours(): Optional = totalHours.getOptional("total_hours") - - /** - * The type of the payment associated with the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * Returns the raw JSON value of [earnings]. - * - * Unlike [earnings], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("earnings") - @ExcludeMissing - fun _earnings(): JsonField> = earnings - - /** - * Returns the raw JSON value of [employeeDeductions]. - * - * Unlike [employeeDeductions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("employee_deductions") - @ExcludeMissing - fun _employeeDeductions(): JsonField> = employeeDeductions - - /** - * Returns the raw JSON value of [employerContributions]. - * - * Unlike [employerContributions], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("employer_contributions") - @ExcludeMissing - fun _employerContributions(): JsonField> = employerContributions - - /** - * Returns the raw JSON value of [grossPay]. - * - * Unlike [grossPay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay - - /** - * Returns the raw JSON value of [individualId]. - * - * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("individual_id") - @ExcludeMissing - fun _individualId(): JsonField = individualId - - /** - * Returns the raw JSON value of [netPay]. - * - * Unlike [netPay], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay - - /** - * Returns the raw JSON value of [paymentMethod]. - * - * Unlike [paymentMethod], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("payment_method") - @ExcludeMissing - fun _paymentMethod(): JsonField = paymentMethod - - /** - * Returns the raw JSON value of [taxes]. - * - * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes - - /** - * Returns the raw JSON value of [totalHours]. - * - * Unlike [totalHours], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("total_hours") - @ExcludeMissing - fun _totalHours(): JsonField = totalHours - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [PayStatement]. - * - * The following fields are required: - * ```java - * .earnings() - * .employeeDeductions() - * .employerContributions() - * .grossPay() - * .individualId() - * .netPay() - * .paymentMethod() - * .taxes() - * .totalHours() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [PayStatement]. */ - class Builder internal constructor() { - - private var earnings: JsonField>? = null - private var employeeDeductions: JsonField>? = null - private var employerContributions: JsonField>? = null - private var grossPay: JsonField? = null - private var individualId: JsonField? = null - private var netPay: JsonField? = null - private var paymentMethod: JsonField? = null - private var taxes: JsonField>? = null - private var totalHours: JsonField? = null - private var type: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(payStatement: PayStatement) = apply { - earnings = payStatement.earnings.map { it.toMutableList() } - employeeDeductions = payStatement.employeeDeductions.map { it.toMutableList() } - employerContributions = - payStatement.employerContributions.map { it.toMutableList() } - grossPay = payStatement.grossPay - individualId = payStatement.individualId - netPay = payStatement.netPay - paymentMethod = payStatement.paymentMethod - taxes = payStatement.taxes.map { it.toMutableList() } - totalHours = payStatement.totalHours - type = payStatement.type - additionalProperties = payStatement.additionalProperties.toMutableMap() - } - - /** The array of earnings objects associated with this pay statement */ - fun earnings(earnings: List?) = earnings(JsonField.ofNullable(earnings)) - - /** Alias for calling [Builder.earnings] with `earnings.orElse(null)`. */ - fun earnings(earnings: Optional>) = earnings(earnings.getOrNull()) - - /** - * Sets [Builder.earnings] to an arbitrary JSON value. - * - * You should usually call [Builder.earnings] with a well-typed `List` value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun earnings(earnings: JsonField>) = apply { - this.earnings = earnings.map { it.toMutableList() } - } - - /** - * Adds a single [Earning] to [earnings]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEarning(earning: Earning) = apply { - earnings = - (earnings ?: JsonField.of(mutableListOf())).also { - checkKnown("earnings", it).add(earning) - } - } - - /** The array of deductions objects associated with this pay statement. */ - fun employeeDeductions(employeeDeductions: List?) = - employeeDeductions(JsonField.ofNullable(employeeDeductions)) - - /** - * Alias for calling [Builder.employeeDeductions] with - * `employeeDeductions.orElse(null)`. - */ - fun employeeDeductions(employeeDeductions: Optional>) = - employeeDeductions(employeeDeductions.getOrNull()) - - /** - * Sets [Builder.employeeDeductions] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeDeductions] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun employeeDeductions(employeeDeductions: JsonField>) = - apply { - this.employeeDeductions = employeeDeductions.map { it.toMutableList() } - } - - /** - * Adds a single [EmployeeDeduction] to [employeeDeductions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { - employeeDeductions = - (employeeDeductions ?: JsonField.of(mutableListOf())).also { - checkKnown("employeeDeductions", it).add(employeeDeduction) - } - } - - fun employerContributions(employerContributions: List?) = - employerContributions(JsonField.ofNullable(employerContributions)) - - /** - * Alias for calling [Builder.employerContributions] with - * `employerContributions.orElse(null)`. - */ - fun employerContributions( - employerContributions: Optional> - ) = employerContributions(employerContributions.getOrNull()) - - /** - * Sets [Builder.employerContributions] to an arbitrary JSON value. - * - * You should usually call [Builder.employerContributions] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun employerContributions( - employerContributions: JsonField> - ) = apply { - this.employerContributions = employerContributions.map { it.toMutableList() } - } - - /** - * Adds a single [EmployerContribution] to [employerContributions]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployerContribution(employerContribution: EmployerContribution) = apply { - employerContributions = - (employerContributions ?: JsonField.of(mutableListOf())).also { - checkKnown("employerContributions", it).add(employerContribution) - } - } - - fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) - - /** Alias for calling [Builder.grossPay] with `grossPay.orElse(null)`. */ - fun grossPay(grossPay: Optional) = grossPay(grossPay.getOrNull()) - - /** - * Sets [Builder.grossPay] to an arbitrary JSON value. - * - * You should usually call [Builder.grossPay] with a well-typed [Money] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } - - /** A stable Finch `id` (UUID v4) for an individual in the company */ - fun individualId(individualId: String) = individualId(JsonField.of(individualId)) - - /** - * Sets [Builder.individualId] to an arbitrary JSON value. - * - * You should usually call [Builder.individualId] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun individualId(individualId: JsonField) = apply { - this.individualId = individualId - } - - fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) - - /** Alias for calling [Builder.netPay] with `netPay.orElse(null)`. */ - fun netPay(netPay: Optional) = netPay(netPay.getOrNull()) - - /** - * Sets [Builder.netPay] to an arbitrary JSON value. - * - * You should usually call [Builder.netPay] with a well-typed [Money] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun netPay(netPay: JsonField) = apply { this.netPay = netPay } - - /** The payment method. */ - fun paymentMethod(paymentMethod: PaymentMethod?) = - paymentMethod(JsonField.ofNullable(paymentMethod)) - - /** Alias for calling [Builder.paymentMethod] with `paymentMethod.orElse(null)`. */ - fun paymentMethod(paymentMethod: Optional) = - paymentMethod(paymentMethod.getOrNull()) - - /** - * Sets [Builder.paymentMethod] to an arbitrary JSON value. - * - * You should usually call [Builder.paymentMethod] with a well-typed [PaymentMethod] - * value instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun paymentMethod(paymentMethod: JsonField) = apply { - this.paymentMethod = paymentMethod - } - - /** The array of taxes objects associated with this pay statement. */ - fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) - - /** Alias for calling [Builder.taxes] with `taxes.orElse(null)`. */ - fun taxes(taxes: Optional>) = taxes(taxes.getOrNull()) - - /** - * Sets [Builder.taxes] to an arbitrary JSON value. - * - * You should usually call [Builder.taxes] with a well-typed `List` value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun taxes(taxes: JsonField>) = apply { - this.taxes = taxes.map { it.toMutableList() } - } - - /** - * Adds a single [Tax] to [taxes]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addTax(tax: Tax) = apply { - taxes = - (taxes ?: JsonField.of(mutableListOf())).also { - checkKnown("taxes", it).add(tax) - } - } - - /** The number of hours worked for this pay period */ - fun totalHours(totalHours: Double?) = totalHours(JsonField.ofNullable(totalHours)) - - /** - * Alias for [Builder.totalHours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun totalHours(totalHours: Double) = totalHours(totalHours as Double?) - - /** Alias for calling [Builder.totalHours] with `totalHours.orElse(null)`. */ - fun totalHours(totalHours: Optional) = totalHours(totalHours.getOrNull()) - - /** - * Sets [Builder.totalHours] to an arbitrary JSON value. - * - * You should usually call [Builder.totalHours] with a well-typed [Double] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun totalHours(totalHours: JsonField) = apply { this.totalHours = totalHours } - - /** The type of the payment associated with the pay statement. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [PayStatement]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .earnings() - * .employeeDeductions() - * .employerContributions() - * .grossPay() - * .individualId() - * .netPay() - * .paymentMethod() - * .taxes() - * .totalHours() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): PayStatement = - PayStatement( - checkRequired("earnings", earnings).map { it.toImmutable() }, - checkRequired("employeeDeductions", employeeDeductions).map { - it.toImmutable() - }, - checkRequired("employerContributions", employerContributions).map { - it.toImmutable() - }, - checkRequired("grossPay", grossPay), - checkRequired("individualId", individualId), - checkRequired("netPay", netPay), - checkRequired("paymentMethod", paymentMethod), - checkRequired("taxes", taxes).map { it.toImmutable() }, - checkRequired("totalHours", totalHours), - checkRequired("type", type), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): PayStatement = apply { - if (validated) { - return@apply - } - - earnings().ifPresent { it.forEach { it?.validate() } } - employeeDeductions().ifPresent { it.forEach { it?.validate() } } - employerContributions().ifPresent { it.forEach { it?.validate() } } - grossPay().ifPresent { it.validate() } - individualId() - netPay().ifPresent { it.validate() } - paymentMethod().ifPresent { it.validate() } - taxes().ifPresent { it.forEach { it?.validate() } } - totalHours() - type().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (earnings.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (employeeDeductions.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (employerContributions.asKnown().getOrNull()?.sumOf { - (it?.validity() ?: 0).toInt() - } ?: 0) + - (grossPay.asKnown().getOrNull()?.validity() ?: 0) + - (if (individualId.asKnown().isPresent) 1 else 0) + - (netPay.asKnown().getOrNull()?.validity() ?: 0) + - (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + - (taxes.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (if (totalHours.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) - - class Earning - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val hours: JsonField, - private val name: JsonField, - private val type: JsonField, - private val attributes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("hours") @ExcludeMissing hours: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - ) : this(amount, currency, hours, name, type, attributes, mutableMapOf()) - - /** - * The earnings amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * The earnings currency code. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The number of hours associated with this earning. (For salaried employees, this could - * be hours per pay period, `0` or `null`, depending on the provider). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun hours(): Optional = hours.getOptional("hours") - - /** - * The exact name of the deduction from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The type of earning. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [hours]. - * - * Unlike [hours], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField = hours - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Earning]. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * .hours() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Earning]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var currency: JsonField? = null - private var hours: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var attributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(earning: Earning) = apply { - amount = earning.amount - currency = earning.currency - hours = earning.hours - name = earning.name - type = earning.type - attributes = earning.attributes - additionalProperties = earning.additionalProperties.toMutableMap() - } - - /** The earnings amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The earnings currency code. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** - * The number of hours associated with this earning. (For salaried employees, this - * could be hours per pay period, `0` or `null`, depending on the provider). - */ - fun hours(hours: Double?) = hours(JsonField.ofNullable(hours)) - - /** - * Alias for [Builder.hours]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun hours(hours: Double) = hours(hours as Double?) - - /** Alias for calling [Builder.hours] with `hours.orElse(null)`. */ - fun hours(hours: Optional) = hours(hours.getOrNull()) - - /** - * Sets [Builder.hours] to an arbitrary JSON value. - * - * You should usually call [Builder.hours] with a well-typed [Double] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun hours(hours: JsonField) = apply { this.hours = hours } - - /** The exact name of the deduction from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The type of earning. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Earning]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * .hours() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Earning = - Earning( - checkRequired("amount", amount), - checkRequired("currency", currency), - checkRequired("hours", hours), - checkRequired("name", name), - checkRequired("type", type), - attributes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Earning = apply { - if (validated) { - return@apply - } - - amount() - currency() - hours() - name() - type().ifPresent { it.validate() } - attributes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (hours.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) - - /** The type of earning. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val SALARY = of("salary") - - @JvmField val WAGE = of("wage") - - @JvmField val REIMBURSEMENT = of("reimbursement") - - @JvmField val OVERTIME = of("overtime") - - @JvmField val SEVERANCE = of("severance") - - @JvmField val DOUBLE_OVERTIME = of("double_overtime") - - @JvmField val PTO = of("pto") - - @JvmField val SICK = of("sick") - - @JvmField val BONUS = of("bonus") - - @JvmField val COMMISSION = of("commission") - - @JvmField val TIPS = of("tips") - - @JvmField val _1099 = of("1099") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - OTHER, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - SALARY, - WAGE, - REIMBURSEMENT, - OVERTIME, - SEVERANCE, - DOUBLE_OVERTIME, - PTO, - SICK, - BONUS, - COMMISSION, - TIPS, - _1099, - OTHER, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - SALARY -> Value.SALARY - WAGE -> Value.WAGE - REIMBURSEMENT -> Value.REIMBURSEMENT - OVERTIME -> Value.OVERTIME - SEVERANCE -> Value.SEVERANCE - DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME - PTO -> Value.PTO - SICK -> Value.SICK - BONUS -> Value.BONUS - COMMISSION -> Value.COMMISSION - TIPS -> Value.TIPS - _1099 -> Value._1099 - OTHER -> Value.OTHER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - SALARY -> Known.SALARY - WAGE -> Known.WAGE - REIMBURSEMENT -> Known.REIMBURSEMENT - OVERTIME -> Known.OVERTIME - SEVERANCE -> Known.SEVERANCE - DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME - PTO -> Known.PTO - SICK -> Known.SICK - BONUS -> Known.BONUS - COMMISSION -> Known.COMMISSION - TIPS -> Known.TIPS - _1099 -> Known._1099 - OTHER -> Known.OTHER - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Attributes]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Attributes = - Attributes( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Earning && amount == other.amount && currency == other.currency && hours == other.hours && name == other.name && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, currency, hours, name, type, attributes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Earning{amount=$amount, currency=$currency, hours=$hours, name=$name, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" - } - - class EmployeeDeduction - private constructor( - private val amount: JsonField, - private val currency: JsonField, - private val name: JsonField, - private val preTax: JsonField, - private val type: JsonField, - private val attributes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("pre_tax") - @ExcludeMissing - preTax: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - ) : this(amount, currency, name, preTax, type, attributes, mutableMapOf()) - - /** - * The deduction amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * The deduction currency. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The deduction name from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Boolean indicating if the deduction is pre-tax. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun preTax(): Optional = preTax.getOptional("pre_tax") - - /** - * Type of benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [preTax]. - * - * Unlike [preTax], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("pre_tax") @ExcludeMissing fun _preTax(): JsonField = preTax - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [EmployeeDeduction]. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * .name() - * .preTax() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmployeeDeduction]. */ - class Builder internal constructor() { - - private var amount: JsonField? = null - private var currency: JsonField? = null - private var name: JsonField? = null - private var preTax: JsonField? = null - private var type: JsonField? = null - private var attributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employeeDeduction: EmployeeDeduction) = apply { - amount = employeeDeduction.amount - currency = employeeDeduction.currency - name = employeeDeduction.name - preTax = employeeDeduction.preTax - type = employeeDeduction.type - attributes = employeeDeduction.attributes - additionalProperties = employeeDeduction.additionalProperties.toMutableMap() - } - - /** The deduction amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - /** The deduction currency. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The deduction name from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Boolean indicating if the deduction is pre-tax. */ - fun preTax(preTax: Boolean?) = preTax(JsonField.ofNullable(preTax)) - - /** - * Alias for [Builder.preTax]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun preTax(preTax: Boolean) = preTax(preTax as Boolean?) - - /** Alias for calling [Builder.preTax] with `preTax.orElse(null)`. */ - fun preTax(preTax: Optional) = preTax(preTax.getOrNull()) - - /** - * Sets [Builder.preTax] to an arbitrary JSON value. - * - * You should usually call [Builder.preTax] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun preTax(preTax: JsonField) = apply { this.preTax = preTax } - - /** Type of benefit. */ - fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [BenefitType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [EmployeeDeduction]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .amount() - * .currency() - * .name() - * .preTax() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EmployeeDeduction = - EmployeeDeduction( - checkRequired("amount", amount), - checkRequired("currency", currency), - checkRequired("name", name), - checkRequired("preTax", preTax), - checkRequired("type", type), - attributes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmployeeDeduction = apply { - if (validated) { - return@apply - } - - amount() - currency() - name() - preTax() - type().ifPresent { it.validate() } - attributes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (amount.asKnown().isPresent) 1 else 0) + - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (if (preTax.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Attributes]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Attributes = - Attributes( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && currency == other.currency && name == other.name && preTax == other.preTax && type == other.type && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(amount, currency, name, preTax, type, attributes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmployeeDeduction{amount=$amount, currency=$currency, name=$name, preTax=$preTax, type=$type, attributes=$attributes, additionalProperties=$additionalProperties}" - } - - class EmployerContribution - private constructor( - private val currency: JsonField, - private val name: JsonField, - private val type: JsonField, - private val amount: JsonField, - private val attributes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") - @ExcludeMissing - type: JsonField = JsonMissing.of(), - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - ) : this(currency, name, type, amount, attributes, mutableMapOf()) - - /** - * The contribution currency. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * The contribution name from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * Type of benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * The contribution amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [EmployerContribution]. - * - * The following fields are required: - * ```java - * .currency() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [EmployerContribution]. */ - class Builder internal constructor() { - - private var currency: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(employerContribution: EmployerContribution) = apply { - currency = employerContribution.currency - name = employerContribution.name - type = employerContribution.type - amount = employerContribution.amount - attributes = employerContribution.attributes - additionalProperties = employerContribution.additionalProperties.toMutableMap() - } - - /** The contribution currency. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** The contribution name from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** Type of benefit. */ - fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [BenefitType] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** The contribution amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - 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 [EmployerContribution]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .currency() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): EmployerContribution = - EmployerContribution( - checkRequired("currency", currency), - checkRequired("name", name), - checkRequired("type", type), - amount, - attributes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): EmployerContribution = apply { - if (validated) { - return@apply - } - - currency() - name() - type().ifPresent { it.validate() } - amount() - attributes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (currency.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Attributes]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Attributes = - Attributes( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployerContribution && currency == other.currency && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, name, type, amount, attributes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "EmployerContribution{currency=$currency, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" - } - - /** The payment method. */ - class PaymentMethod @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val CHECK = of("check") - - @JvmField val DIRECT_DEPOSIT = of("direct_deposit") - - @JvmField val OTHER = of("other") - - @JvmStatic fun of(value: String) = PaymentMethod(JsonField.of(value)) - } - - /** An enum containing [PaymentMethod]'s known values. */ - enum class Known { - CHECK, - DIRECT_DEPOSIT, - OTHER, - } - - /** - * An enum containing [PaymentMethod]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [PaymentMethod] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - CHECK, - DIRECT_DEPOSIT, - OTHER, - /** - * An enum member indicating that [PaymentMethod] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - CHECK -> Value.CHECK - DIRECT_DEPOSIT -> Value.DIRECT_DEPOSIT - OTHER -> Value.OTHER - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - CHECK -> Known.CHECK - DIRECT_DEPOSIT -> Known.DIRECT_DEPOSIT - OTHER -> Known.OTHER - else -> throw FinchInvalidDataException("Unknown PaymentMethod: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): PaymentMethod = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PaymentMethod && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Tax - private constructor( - private val currency: JsonField, - private val employer: JsonField, - private val name: JsonField, - private val type: JsonField, - private val amount: JsonField, - private val attributes: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("currency") - @ExcludeMissing - currency: JsonField = JsonMissing.of(), - @JsonProperty("employer") - @ExcludeMissing - employer: JsonField = JsonMissing.of(), - @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), - @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), - @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), - @JsonProperty("attributes") - @ExcludeMissing - attributes: JsonField = JsonMissing.of(), - ) : this(currency, employer, name, type, amount, attributes, mutableMapOf()) - - /** - * The currency code. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun currency(): Optional = currency.getOptional("currency") - - /** - * `true` if the amount is paid by the employers. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun employer(): Optional = employer.getOptional("employer") - - /** - * The exact name of tax from the pay statement. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun name(): Optional = name.getOptional("name") - - /** - * The type of taxes. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun type(): Optional = type.getOptional("type") - - /** - * The tax amount in cents. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun amount(): Optional = amount.getOptional("amount") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if - * the server responded with an unexpected value). - */ - fun attributes(): Optional = attributes.getOptional("attributes") - - /** - * Returns the raw JSON value of [currency]. - * - * Unlike [currency], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - - /** - * Returns the raw JSON value of [employer]. - * - * Unlike [employer], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer - - /** - * Returns the raw JSON value of [name]. - * - * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - - /** - * Returns the raw JSON value of [type]. - * - * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - - /** - * Returns the raw JSON value of [amount]. - * - * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - - /** - * Returns the raw JSON value of [attributes]. - * - * Unlike [attributes], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("attributes") - @ExcludeMissing - fun _attributes(): JsonField = attributes - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Tax]. - * - * The following fields are required: - * ```java - * .currency() - * .employer() - * .name() - * .type() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Tax]. */ - class Builder internal constructor() { - - private var currency: JsonField? = null - private var employer: JsonField? = null - private var name: JsonField? = null - private var type: JsonField? = null - private var amount: JsonField = JsonMissing.of() - private var attributes: JsonField = JsonMissing.of() - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(tax: Tax) = apply { - currency = tax.currency - employer = tax.employer - name = tax.name - type = tax.type - amount = tax.amount - attributes = tax.attributes - additionalProperties = tax.additionalProperties.toMutableMap() - } - - /** The currency code. */ - fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) - - /** Alias for calling [Builder.currency] with `currency.orElse(null)`. */ - fun currency(currency: Optional) = currency(currency.getOrNull()) - - /** - * Sets [Builder.currency] to an arbitrary JSON value. - * - * You should usually call [Builder.currency] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun currency(currency: JsonField) = apply { this.currency = currency } - - /** `true` if the amount is paid by the employers. */ - fun employer(employer: Boolean?) = employer(JsonField.ofNullable(employer)) - - /** - * Alias for [Builder.employer]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun employer(employer: Boolean) = employer(employer as Boolean?) - - /** Alias for calling [Builder.employer] with `employer.orElse(null)`. */ - fun employer(employer: Optional) = employer(employer.getOrNull()) - - /** - * Sets [Builder.employer] to an arbitrary JSON value. - * - * You should usually call [Builder.employer] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun employer(employer: JsonField) = apply { this.employer = employer } - - /** The exact name of tax from the pay statement. */ - fun name(name: String?) = name(JsonField.ofNullable(name)) - - /** Alias for calling [Builder.name] with `name.orElse(null)`. */ - fun name(name: Optional) = name(name.getOrNull()) - - /** - * Sets [Builder.name] to an arbitrary JSON value. - * - * You should usually call [Builder.name] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun name(name: JsonField) = apply { this.name = name } - - /** The type of taxes. */ - fun type(type: Type?) = type(JsonField.ofNullable(type)) - - /** Alias for calling [Builder.type] with `type.orElse(null)`. */ - fun type(type: Optional) = type(type.getOrNull()) - - /** - * Sets [Builder.type] to an arbitrary JSON value. - * - * You should usually call [Builder.type] with a well-typed [Type] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun type(type: JsonField) = apply { this.type = type } - - /** The tax amount in cents. */ - fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) - - /** - * Alias for [Builder.amount]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun amount(amount: Long) = amount(amount as Long?) - - /** Alias for calling [Builder.amount] with `amount.orElse(null)`. */ - fun amount(amount: Optional) = amount(amount.getOrNull()) - - /** - * Sets [Builder.amount] to an arbitrary JSON value. - * - * You should usually call [Builder.amount] with a well-typed [Long] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun amount(amount: JsonField) = apply { this.amount = amount } - - fun attributes(attributes: Attributes?) = - attributes(JsonField.ofNullable(attributes)) - - /** Alias for calling [Builder.attributes] with `attributes.orElse(null)`. */ - fun attributes(attributes: Optional) = - attributes(attributes.getOrNull()) - - /** - * Sets [Builder.attributes] to an arbitrary JSON value. - * - * You should usually call [Builder.attributes] with a well-typed [Attributes] value - * instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun attributes(attributes: JsonField) = apply { - this.attributes = attributes - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Tax]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .currency() - * .employer() - * .name() - * .type() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Tax = - Tax( - checkRequired("currency", currency), - checkRequired("employer", employer), - checkRequired("name", name), - checkRequired("type", type), - amount, - attributes, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Tax = apply { - if (validated) { - return@apply - } - - currency() - employer() - name() - type().ifPresent { it.validate() } - amount() - attributes().ifPresent { it.validate() } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (currency.asKnown().isPresent) 1 else 0) + - (if (employer.asKnown().isPresent) 1 else 0) + - (if (name.asKnown().isPresent) 1 else 0) + - (type.asKnown().getOrNull()?.validity() ?: 0) + - (if (amount.asKnown().isPresent) 1 else 0) + - (attributes.asKnown().getOrNull()?.validity() ?: 0) - - /** The type of taxes. */ - class Type @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that - * doesn't match any known member, and you want to know that value. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val STATE = of("state") - - @JvmField val FEDERAL = of("federal") - - @JvmField val LOCAL = of("local") - - @JvmField val FICA = of("fica") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - STATE, - FEDERAL, - LOCAL, - FICA, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, - * if the SDK is on an older version than the API, then the API may respond with - * new members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - STATE, - FEDERAL, - LOCAL, - FICA, - /** - * An enum member indicating that [Type] was instantiated with an unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if - * you want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - STATE -> Value.STATE - FEDERAL -> Value.FEDERAL - LOCAL -> Value.LOCAL - FICA -> Value.FICA - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - STATE -> Known.STATE - FEDERAL -> Known.FEDERAL - LOCAL -> Known.LOCAL - FICA -> Known.FICA - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have - * the expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class Attributes - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type or is - * unexpectedly missing or null (e.g. if the server responded with an unexpected - * value). - */ - fun metadata(): Metadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Attributes]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Attributes]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(attributes: Attributes) = apply { - metadata = attributes.metadata - additionalProperties = attributes.additionalProperties.toMutableMap() - } - - fun metadata(metadata: Metadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed [Metadata] value - * instead. This method is primarily for setting the field to an undocumented or - * not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Attributes]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Attributes = - Attributes( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Attributes = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - class Metadata - private constructor( - private val metadata: JsonField, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("metadata") - @ExcludeMissing - metadata: JsonField = JsonMissing.of() - ) : this(metadata, mutableMapOf()) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type or - * is unexpectedly missing or null (e.g. if the server responded with an - * unexpected value). - */ - fun metadata(): InnerMetadata = metadata.getRequired("metadata") - - /** - * Returns the raw JSON value of [metadata]. - * - * Unlike [metadata], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("metadata") - @ExcludeMissing - fun _metadata(): JsonField = metadata - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of [Metadata]. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [Metadata]. */ - class Builder internal constructor() { - - private var metadata: JsonField? = null - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(metadata: Metadata) = apply { - this.metadata = metadata.metadata - additionalProperties = metadata.additionalProperties.toMutableMap() - } - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, - * boolean, object, array, etc.). - */ - fun metadata(metadata: InnerMetadata) = metadata(JsonField.of(metadata)) - - /** - * Sets [Builder.metadata] to an arbitrary JSON value. - * - * You should usually call [Builder.metadata] with a well-typed - * [InnerMetadata] value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun metadata(metadata: JsonField) = apply { - this.metadata = metadata - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [Metadata]. - * - * Further updates to this [Builder] will not mutate the returned instance. - * - * The following fields are required: - * ```java - * .metadata() - * ``` - * - * @throws IllegalStateException if any required field is unset. - */ - fun build(): Metadata = - Metadata( - checkRequired("metadata", metadata), - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): Metadata = apply { - if (validated) { - return@apply - } - - metadata().validate() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = (metadata.asKnown().getOrNull()?.validity() ?: 0) - - /** - * The metadata to be attached to the entity by existing rules. It is a - * key-value pairs where the values can be of any type (string, number, boolean, - * object, array, etc.). - */ - class InnerMetadata - @JsonCreator - private constructor( - @com.fasterxml.jackson.annotation.JsonValue - private val additionalProperties: Map - ) { - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [InnerMetadata]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [InnerMetadata]. */ - class Builder internal constructor() { - - private var additionalProperties: MutableMap = - mutableMapOf() - - @JvmSynthetic - internal fun from(innerMetadata: InnerMetadata) = apply { - additionalProperties = - innerMetadata.additionalProperties.toMutableMap() - } - - fun additionalProperties(additionalProperties: Map) = - apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties( - additionalProperties: Map - ) = apply { this.additionalProperties.putAll(additionalProperties) } - - fun removeAdditionalProperty(key: String) = apply { - additionalProperties.remove(key) - } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [InnerMetadata]. - * - * Further updates to this [Builder] will not mutate the returned - * instance. - */ - fun build(): InnerMetadata = - InnerMetadata(additionalProperties.toImmutable()) - } - - private var validated: Boolean = false - - fun validate(): InnerMetadata = apply { - if (validated) { - return@apply - } - - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this - * object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - additionalProperties.count { (_, value) -> - !value.isNull() && !value.isMissing() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is InnerMetadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "InnerMetadata{additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Metadata && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Metadata{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Attributes && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(metadata, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Attributes{metadata=$metadata, additionalProperties=$additionalProperties}" - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Tax && currency == other.currency && employer == other.employer && name == other.name && type == other.type && amount == other.amount && attributes == other.attributes && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(currency, employer, name, type, amount, attributes, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "Tax{currency=$currency, employer=$employer, name=$name, type=$type, amount=$amount, attributes=$attributes, additionalProperties=$additionalProperties}" - } - - /** The type of the payment associated with the pay statement. */ - class Type @JsonCreator private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") - - @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") - - @JvmField val REGULAR_PAYROLL = of("regular_payroll") - - @JvmStatic fun of(value: String) = Type(JsonField.of(value)) - } - - /** An enum containing [Type]'s known values. */ - enum class Known { - OFF_CYCLE_PAYROLL, - ONE_TIME_PAYMENT, - REGULAR_PAYROLL, - } - - /** - * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [Type] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - OFF_CYCLE_PAYROLL, - ONE_TIME_PAYMENT, - REGULAR_PAYROLL, - /** An enum member indicating that [Type] was instantiated with an unknown value. */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL - ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT - REGULAR_PAYROLL -> Value.REGULAR_PAYROLL - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL - ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT - REGULAR_PAYROLL -> Known.REGULAR_PAYROLL - else -> throw FinchInvalidDataException("Unknown Type: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): Type = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is Type && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is PayStatement && earnings == other.earnings && employeeDeductions == other.employeeDeductions && employerContributions == other.employerContributions && grossPay == other.grossPay && individualId == other.individualId && netPay == other.netPay && paymentMethod == other.paymentMethod && taxes == other.taxes && totalHours == other.totalHours && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(earnings, employeeDeductions, employerContributions, grossPay, individualId, netPay, paymentMethod, taxes, totalHours, type, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "PayStatement{earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, individualId=$individualId, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt index 7f6f032d..7f376d05 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyPageResponseTest.kt @@ -17,49 +17,29 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .addResponse( PayStatementResponse.builder() .body( - PayStatementResponseBody.UnionMember0.builder() + PayStatementResponseBody.builder() .paging( - PayStatementResponseBody.UnionMember0.Paging.builder() + PayStatementResponseBody.Paging.builder() .offset(0L) .count(0L) .build() ) .addPayStatement( - PayStatementResponseBody.UnionMember0.PayStatement.builder() + PayStatement.builder() .addEarning( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Type - .SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .Earning - .Attributes + PayStatement.Earning.Attributes .Metadata .InnerMetadata .builder() @@ -78,32 +58,22 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .addEmployeeDeduction( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction + PayStatement.EmployeeDeduction .Attributes .Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .EmployeeDeduction + PayStatement.EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -123,30 +93,21 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .addEmployerContribution( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution + PayStatement.EmployerContribution .Attributes .Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement + PayStatement .EmployerContribution .Attributes .Metadata @@ -173,44 +134,21 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .netPay( Money.builder().amount(0L).currency("currency").build() ) - .paymentMethod( - PayStatementResponseBody.UnionMember0.PayStatement - .PaymentMethod - .CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Type - .STATE - ) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .Tax - .Attributes + PayStatement.Tax.Attributes .Metadata .InnerMetadata .builder() @@ -229,10 +167,7 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .totalHours(0.0) - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Type - .OFF_CYCLE_PAYROLL - ) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() @@ -247,46 +182,29 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .containsExactly( PayStatementResponse.builder() .body( - PayStatementResponseBody.UnionMember0.builder() + PayStatementResponseBody.builder() .paging( - PayStatementResponseBody.UnionMember0.Paging.builder() + PayStatementResponseBody.Paging.builder() .offset(0L) .count(0L) .build() ) .addPayStatement( - PayStatementResponseBody.UnionMember0.PayStatement.builder() + PayStatement.builder() .addEarning( - PayStatementResponseBody.UnionMember0.PayStatement.Earning - .builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Type - .SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .Earning - .Attributes + PayStatement.Earning.Attributes .Metadata .InnerMetadata .builder() @@ -305,31 +223,20 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .addEmployeeDeduction( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .EmployeeDeduction + PayStatement.EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -349,30 +256,20 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .addEmployerContribution( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .EmployerContribution + PayStatement.EmployerContribution .Attributes .Metadata .InnerMetadata @@ -396,43 +293,21 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { ) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - PayStatementResponseBody.UnionMember0.PayStatement - .PaymentMethod - .CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement - .Tax - .Type - .STATE - ) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .Tax - .Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -450,10 +325,7 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .totalHours(0.0) - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Type - .OFF_CYCLE_PAYROLL - ) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() @@ -472,49 +344,29 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .addResponse( PayStatementResponse.builder() .body( - PayStatementResponseBody.UnionMember0.builder() + PayStatementResponseBody.builder() .paging( - PayStatementResponseBody.UnionMember0.Paging.builder() + PayStatementResponseBody.Paging.builder() .offset(0L) .count(0L) .build() ) .addPayStatement( - PayStatementResponseBody.UnionMember0.PayStatement.builder() + PayStatement.builder() .addEarning( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Type - .SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .Earning - .Attributes + PayStatement.Earning.Attributes .Metadata .InnerMetadata .builder() @@ -533,32 +385,22 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .addEmployeeDeduction( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction + PayStatement.EmployeeDeduction .Attributes .Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .EmployeeDeduction + PayStatement.EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -578,30 +420,21 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .addEmployerContribution( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution + PayStatement.EmployerContribution .Attributes .Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement + PayStatement .EmployerContribution .Attributes .Metadata @@ -628,44 +461,21 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .netPay( Money.builder().amount(0L).currency("currency").build() ) - .paymentMethod( - PayStatementResponseBody.UnionMember0.PayStatement - .PaymentMethod - .CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Type - .STATE - ) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody - .UnionMember0 - .PayStatement - .Tax - .Attributes + PayStatement.Tax.Attributes .Metadata .InnerMetadata .builder() @@ -684,10 +494,7 @@ internal class HrisPayStatementRetrieveManyPageResponseTest { .build() ) .totalHours(0.0) - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Type - .OFF_CYCLE_PAYROLL - ) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgressTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgressTest.kt new file mode 100644 index 00000000..4bc588bf --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementDataSyncInProgressTest.kt @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.tryfinch.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PayStatementDataSyncInProgressTest { + + @Test + fun create() { + val payStatementDataSyncInProgress = + PayStatementDataSyncInProgress.builder() + .code(PayStatementDataSyncInProgress.Code._202) + .finchCode(PayStatementDataSyncInProgress.FinchCode.DATA_SYNC_IN_PROGRESS) + .message( + PayStatementDataSyncInProgress.Message + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + ) + .name(PayStatementDataSyncInProgress.Name.ACCEPTED) + .build() + + assertThat(payStatementDataSyncInProgress.code()) + .isEqualTo(PayStatementDataSyncInProgress.Code._202) + assertThat(payStatementDataSyncInProgress.finchCode()) + .isEqualTo(PayStatementDataSyncInProgress.FinchCode.DATA_SYNC_IN_PROGRESS) + assertThat(payStatementDataSyncInProgress.message()) + .isEqualTo( + PayStatementDataSyncInProgress.Message + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + ) + assertThat(payStatementDataSyncInProgress.name()) + .isEqualTo(PayStatementDataSyncInProgress.Name.ACCEPTED) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val payStatementDataSyncInProgress = + PayStatementDataSyncInProgress.builder() + .code(PayStatementDataSyncInProgress.Code._202) + .finchCode(PayStatementDataSyncInProgress.FinchCode.DATA_SYNC_IN_PROGRESS) + .message( + PayStatementDataSyncInProgress.Message + .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + ) + .name(PayStatementDataSyncInProgress.Name.ACCEPTED) + .build() + + val roundtrippedPayStatementDataSyncInProgress = + jsonMapper.readValue( + jsonMapper.writeValueAsString(payStatementDataSyncInProgress), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPayStatementDataSyncInProgress) + .isEqualTo(payStatementDataSyncInProgress) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt index 44cb939a..9ea719d0 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseBodyTest.kt @@ -5,53 +5,31 @@ 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 com.tryfinch.api.errors.FinchInvalidDataException import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test -import org.junit.jupiter.api.assertThrows -import org.junit.jupiter.params.ParameterizedTest -import org.junit.jupiter.params.provider.EnumSource internal class PayStatementResponseBodyTest { @Test - fun ofUnionMember0() { - val unionMember0 = - PayStatementResponseBody.UnionMember0.builder() - .paging( - PayStatementResponseBody.UnionMember0.Paging.builder() - .offset(0L) - .count(0L) - .build() - ) + fun create() { + val payStatementResponseBody = + PayStatementResponseBody.builder() + .paging(PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build()) .addPayStatement( - PayStatementResponseBody.UnionMember0.PayStatement.builder() + PayStatement.builder() .addEarning( - PayStatementResponseBody.UnionMember0.PayStatement.Earning.builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Earning.Type - .SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement.Earning - .Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Attributes - .Metadata - .builder() + PayStatement.Earning.Attributes.Metadata.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -67,29 +45,19 @@ internal class PayStatementResponseBodyTest { .build() ) .addEmployeeDeduction( - PayStatementResponseBody.UnionMember0.PayStatement.EmployeeDeduction - .builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .Attributes - .Metadata + PayStatement.EmployeeDeduction.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .Metadata .InnerMetadata .builder() @@ -106,28 +74,18 @@ internal class PayStatementResponseBodyTest { .build() ) .addEmployerContribution( - PayStatementResponseBody.UnionMember0.PayStatement.EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .Attributes - .Metadata + PayStatement.EmployerContribution.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .InnerMetadata .builder() @@ -146,34 +104,20 @@ internal class PayStatementResponseBodyTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod.CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Tax.Type - .STATE - ) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -189,69 +133,34 @@ internal class PayStatementResponseBodyTest { .build() ) .totalHours(0.0) - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Type - .OFF_CYCLE_PAYROLL - ) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() - val payStatementResponseBody = PayStatementResponseBody.ofUnionMember0(unionMember0) - - assertThat(payStatementResponseBody.unionMember0()).contains(unionMember0) - assertThat(payStatementResponseBody.batchError()).isEmpty - assertThat(payStatementResponseBody.unionMember2()).isEmpty - } - - @Test - fun ofUnionMember0Roundtrip() { - val jsonMapper = jsonMapper() - val payStatementResponseBody = - PayStatementResponseBody.ofUnionMember0( - PayStatementResponseBody.UnionMember0.builder() - .paging( - PayStatementResponseBody.UnionMember0.Paging.builder() - .offset(0L) - .count(0L) - .build() - ) - .addPayStatement( - PayStatementResponseBody.UnionMember0.PayStatement.builder() - .addEarning( - PayStatementResponseBody.UnionMember0.PayStatement.Earning.builder() - .amount(0L) - .currency("currency") - .hours(0.0) - .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Earning - .Type - .SALARY - ) - .attributes( - PayStatementResponseBody.UnionMember0.PayStatement.Earning - .Attributes - .builder() + assertThat(payStatementResponseBody.paging()) + .isEqualTo(PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build()) + assertThat(payStatementResponseBody.payStatements()) + .containsExactly( + PayStatement.builder() + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .attributes( + PayStatement.Earning.Attributes.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata.builder() .metadata( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata + .InnerMetadata .builder() - .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -259,38 +168,26 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .addEmployeeDeduction( - PayStatementResponseBody.UnionMember0.PayStatement.EmployeeDeduction - .builder() - .amount(0L) - .currency("currency") - .name("name") - .preTax(true) - .type(BenefitType._457) - .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .Attributes - .builder() + .build() + ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) + .attributes( + PayStatement.EmployeeDeduction.Attributes.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes.Metadata.builder() .metadata( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .Attributes - .Metadata + PayStatement.EmployeeDeduction.Attributes.Metadata + .InnerMetadata .builder() - .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -298,38 +195,27 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .addEmployerContribution( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .builder() - .currency("currency") - .name("name") - .type(BenefitType._457) - .amount(0L) - .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .Attributes + .build() + ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) + .amount(0L) + .attributes( + PayStatement.EmployerContribution.Attributes.builder() + .metadata( + PayStatement.EmployerContribution.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata + .InnerMetadata .builder() - .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -337,46 +223,29 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod - .CHECK - ) - .addTax( - PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() - .currency("currency") - .employer(true) - .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Tax.Type - .STATE - ) - .amount(0L) - .attributes( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Attributes - .builder() + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod(PayStatement.PaymentMethod.CHECK) + .addTax( + PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .amount(0L) + .attributes( + PayStatement.Tax.Attributes.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - PayStatementResponseBody.UnionMember0.PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata.InnerMetadata .builder() - .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), ) .build() ) @@ -384,102 +253,143 @@ internal class PayStatementResponseBodyTest { ) .build() ) - .totalHours(0.0) - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Type - .OFF_CYCLE_PAYROLL - ) .build() ) + .totalHours(0.0) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - - val roundtrippedPayStatementResponseBody = - jsonMapper.readValue( - jsonMapper.writeValueAsString(payStatementResponseBody), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPayStatementResponseBody).isEqualTo(payStatementResponseBody) } @Test - fun ofBatchError() { - val batchError = - PayStatementResponseBody.BatchError.builder() - .code(0.0) - .message("message") - .name("name") - .finchCode("finch_code") - .build() - - val payStatementResponseBody = PayStatementResponseBody.ofBatchError(batchError) - - assertThat(payStatementResponseBody.unionMember0()).isEmpty - assertThat(payStatementResponseBody.batchError()).contains(batchError) - assertThat(payStatementResponseBody.unionMember2()).isEmpty - } - - @Test - fun ofBatchErrorRoundtrip() { + fun roundtrip() { val jsonMapper = jsonMapper() val payStatementResponseBody = - PayStatementResponseBody.ofBatchError( - PayStatementResponseBody.BatchError.builder() - .code(0.0) - .message("message") - .name("name") - .finchCode("finch_code") - .build() - ) - - val roundtrippedPayStatementResponseBody = - jsonMapper.readValue( - jsonMapper.writeValueAsString(payStatementResponseBody), - jacksonTypeRef(), - ) - - assertThat(roundtrippedPayStatementResponseBody).isEqualTo(payStatementResponseBody) - } - - @Test - fun ofUnionMember2() { - val unionMember2 = - PayStatementResponseBody.UnionMember2.builder() - .code(PayStatementResponseBody.UnionMember2.Code._202) - .finchCode(PayStatementResponseBody.UnionMember2.FinchCode.DATA_SYNC_IN_PROGRESS) - .message( - PayStatementResponseBody.UnionMember2.Message - .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER + PayStatementResponseBody.builder() + .paging(PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build()) + .addPayStatement( + PayStatement.builder() + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .attributes( + PayStatement.Earning.Attributes.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) + .attributes( + PayStatement.EmployeeDeduction.Attributes.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes.Metadata + .builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) + .amount(0L) + .attributes( + PayStatement.EmployerContribution.Attributes.builder() + .metadata( + PayStatement.EmployerContribution.Attributes.Metadata + .builder() + .metadata( + PayStatement.EmployerContribution.Attributes + .Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod(PayStatement.PaymentMethod.CHECK) + .addTax( + PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .amount(0L) + .attributes( + PayStatement.Tax.Attributes.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .totalHours(0.0) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .build() ) - .name(PayStatementResponseBody.UnionMember2.Name.ACCEPTED) .build() - val payStatementResponseBody = PayStatementResponseBody.ofUnionMember2(unionMember2) - - assertThat(payStatementResponseBody.unionMember0()).isEmpty - assertThat(payStatementResponseBody.batchError()).isEmpty - assertThat(payStatementResponseBody.unionMember2()).contains(unionMember2) - } - - @Test - fun ofUnionMember2Roundtrip() { - val jsonMapper = jsonMapper() - val payStatementResponseBody = - PayStatementResponseBody.ofUnionMember2( - PayStatementResponseBody.UnionMember2.builder() - .code(PayStatementResponseBody.UnionMember2.Code._202) - .finchCode( - PayStatementResponseBody.UnionMember2.FinchCode.DATA_SYNC_IN_PROGRESS - ) - .message( - PayStatementResponseBody.UnionMember2.Message - .THE_PAY_STATEMENTS_FOR_THIS_PAYMENT_ARE_BEING_FETCHED_PLEASE_CHECK_BACK_LATER - ) - .name(PayStatementResponseBody.UnionMember2.Name.ACCEPTED) - .build() - ) - val roundtrippedPayStatementResponseBody = jsonMapper.readValue( jsonMapper.writeValueAsString(payStatementResponseBody), @@ -488,22 +398,4 @@ internal class PayStatementResponseBodyTest { assertThat(roundtrippedPayStatementResponseBody).isEqualTo(payStatementResponseBody) } - - enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { - BOOLEAN(JsonValue.from(false)), - STRING(JsonValue.from("invalid")), - INTEGER(JsonValue.from(-1)), - FLOAT(JsonValue.from(3.14)), - ARRAY(JsonValue.from(listOf("invalid", "array"))), - } - - @ParameterizedTest - @EnumSource - fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { - val payStatementResponseBody = - jsonMapper().convertValue(testCase.value, jacksonTypeRef()) - - val e = assertThrows { payStatementResponseBody.validate() } - assertThat(e).hasMessageStartingWith("Unknown ") - } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt index 0812b768..32b97305 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementResponseTest.kt @@ -15,46 +15,26 @@ internal class PayStatementResponseTest { val payStatementResponse = PayStatementResponse.builder() .body( - PayStatementResponseBody.UnionMember0.builder() + PayStatementResponseBody.builder() .paging( - PayStatementResponseBody.UnionMember0.Paging.builder() - .offset(0L) - .count(0L) - .build() + PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build() ) .addPayStatement( - PayStatementResponseBody.UnionMember0.PayStatement.builder() + PayStatement.builder() .addEarning( - PayStatementResponseBody.UnionMember0.PayStatement.Earning - .builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Type - .SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -72,30 +52,20 @@ internal class PayStatementResponseTest { .build() ) .addEmployeeDeduction( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction + PayStatement.EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -115,29 +85,19 @@ internal class PayStatementResponseTest { .build() ) .addEmployerContribution( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution + PayStatement.EmployerContribution .Attributes .Metadata .InnerMetadata @@ -159,38 +119,20 @@ internal class PayStatementResponseTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod - .CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Type - .STATE - ) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -208,10 +150,7 @@ internal class PayStatementResponseTest { .build() ) .totalHours(0.0) - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Type - .OFF_CYCLE_PAYROLL - ) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() @@ -222,47 +161,27 @@ internal class PayStatementResponseTest { assertThat(payStatementResponse.body()) .isEqualTo( - PayStatementResponseBody.ofUnionMember0( - PayStatementResponseBody.UnionMember0.builder() + PayStatementResponse.Body.ofPayStatementResponse( + PayStatementResponseBody.builder() .paging( - PayStatementResponseBody.UnionMember0.Paging.builder() - .offset(0L) - .count(0L) - .build() + PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build() ) .addPayStatement( - PayStatementResponseBody.UnionMember0.PayStatement.builder() + PayStatement.builder() .addEarning( - PayStatementResponseBody.UnionMember0.PayStatement.Earning - .builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Type - .SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -280,30 +199,20 @@ internal class PayStatementResponseTest { .build() ) .addEmployeeDeduction( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction + PayStatement.EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -323,29 +232,19 @@ internal class PayStatementResponseTest { .build() ) .addEmployerContribution( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution + PayStatement.EmployerContribution .Attributes .Metadata .InnerMetadata @@ -367,38 +266,20 @@ internal class PayStatementResponseTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod - .CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Type - .STATE - ) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -416,10 +297,7 @@ internal class PayStatementResponseTest { .build() ) .totalHours(0.0) - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Type - .OFF_CYCLE_PAYROLL - ) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() @@ -435,46 +313,26 @@ internal class PayStatementResponseTest { val payStatementResponse = PayStatementResponse.builder() .body( - PayStatementResponseBody.UnionMember0.builder() + PayStatementResponseBody.builder() .paging( - PayStatementResponseBody.UnionMember0.Paging.builder() - .offset(0L) - .count(0L) - .build() + PayStatementResponseBody.Paging.builder().offset(0L).count(0L).build() ) .addPayStatement( - PayStatementResponseBody.UnionMember0.PayStatement.builder() + PayStatement.builder() .addEarning( - PayStatementResponseBody.UnionMember0.PayStatement.Earning - .builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Type - .SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .Earning - .Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -492,30 +350,20 @@ internal class PayStatementResponseTest { .build() ) .addEmployeeDeduction( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployeeDeduction - .Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployeeDeduction + PayStatement.EmployeeDeduction .Attributes .Metadata .InnerMetadata @@ -535,29 +383,19 @@ internal class PayStatementResponseTest { .build() ) .addEmployerContribution( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement - .EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .EmployerContribution + PayStatement.EmployerContribution .Attributes .Metadata .InnerMetadata @@ -579,38 +417,20 @@ internal class PayStatementResponseTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - PayStatementResponseBody.UnionMember0.PayStatement.PaymentMethod - .CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - PayStatementResponseBody.UnionMember0.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Type - .STATE - ) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - PayStatementResponseBody.UnionMember0.PayStatement.Tax - .Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - PayStatementResponseBody.UnionMember0 - .PayStatement - .Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -628,10 +448,7 @@ internal class PayStatementResponseTest { .build() ) .totalHours(0.0) - .type( - PayStatementResponseBody.UnionMember0.PayStatement.Type - .OFF_CYCLE_PAYROLL - ) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt new file mode 100644 index 00000000..abd69775 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/PayStatementTest.kt @@ -0,0 +1,375 @@ +// 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 kotlin.jvm.optionals.getOrNull +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class PayStatementTest { + + @Test + fun create() { + val payStatement = + PayStatement.builder() + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .attributes( + PayStatement.Earning.Attributes.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata.InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) + .attributes( + PayStatement.EmployeeDeduction.Attributes.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes.Metadata.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) + .amount(0L) + .attributes( + PayStatement.EmployerContribution.Attributes.builder() + .metadata( + PayStatement.EmployerContribution.Attributes.Metadata.builder() + .metadata( + PayStatement.EmployerContribution.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod(PayStatement.PaymentMethod.CHECK) + .addTax( + PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .amount(0L) + .attributes( + PayStatement.Tax.Attributes.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .totalHours(0.0) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .build() + + assertThat(payStatement.earnings().getOrNull()) + .containsExactly( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .attributes( + PayStatement.Earning.Attributes.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata.InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(payStatement.employeeDeductions().getOrNull()) + .containsExactly( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) + .attributes( + PayStatement.EmployeeDeduction.Attributes.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes.Metadata.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(payStatement.employerContributions().getOrNull()) + .containsExactly( + PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) + .amount(0L) + .attributes( + PayStatement.EmployerContribution.Attributes.builder() + .metadata( + PayStatement.EmployerContribution.Attributes.Metadata.builder() + .metadata( + PayStatement.EmployerContribution.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(payStatement.grossPay()) + .contains(Money.builder().amount(0L).currency("currency").build()) + assertThat(payStatement.individualId()).isEqualTo("individual_id") + assertThat(payStatement.netPay()) + .contains(Money.builder().amount(0L).currency("currency").build()) + assertThat(payStatement.paymentMethod()).contains(PayStatement.PaymentMethod.CHECK) + assertThat(payStatement.taxes().getOrNull()) + .containsExactly( + PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .amount(0L) + .attributes( + PayStatement.Tax.Attributes.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.InnerMetadata.builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + assertThat(payStatement.totalHours()).contains(0.0) + assertThat(payStatement.type()).contains(PayStatement.Type.OFF_CYCLE_PAYROLL) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val payStatement = + PayStatement.builder() + .addEarning( + PayStatement.Earning.builder() + .amount(0L) + .currency("currency") + .hours(0.0) + .name("name") + .type(PayStatement.Earning.Type.SALARY) + .attributes( + PayStatement.Earning.Attributes.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata.builder() + .metadata( + PayStatement.Earning.Attributes.Metadata.InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployeeDeduction( + PayStatement.EmployeeDeduction.builder() + .amount(0L) + .currency("currency") + .name("name") + .preTax(true) + .type(BenefitType._457) + .attributes( + PayStatement.EmployeeDeduction.Attributes.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes.Metadata.builder() + .metadata( + PayStatement.EmployeeDeduction.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .addEmployerContribution( + PayStatement.EmployerContribution.builder() + .currency("currency") + .name("name") + .type(BenefitType._457) + .amount(0L) + .attributes( + PayStatement.EmployerContribution.Attributes.builder() + .metadata( + PayStatement.EmployerContribution.Attributes.Metadata.builder() + .metadata( + PayStatement.EmployerContribution.Attributes.Metadata + .InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .grossPay(Money.builder().amount(0L).currency("currency").build()) + .individualId("individual_id") + .netPay(Money.builder().amount(0L).currency("currency").build()) + .paymentMethod(PayStatement.PaymentMethod.CHECK) + .addTax( + PayStatement.Tax.builder() + .currency("currency") + .employer(true) + .name("name") + .type(PayStatement.Tax.Type.STATE) + .amount(0L) + .attributes( + PayStatement.Tax.Attributes.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.builder() + .metadata( + PayStatement.Tax.Attributes.Metadata.InnerMetadata + .builder() + .putAdditionalProperty( + "foo", + JsonValue.from(mapOf()), + ) + .build() + ) + .build() + ) + .build() + ) + .build() + ) + .totalHours(0.0) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .build() + + val roundtrippedPayStatement = + jsonMapper.readValue( + jsonMapper.writeValueAsString(payStatement), + jacksonTypeRef(), + ) + + assertThat(roundtrippedPayStatement).isEqualTo(payStatement) + } +} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt index 688d6937..a85a97ac 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt @@ -14,24 +14,20 @@ internal class SandboxPaymentCreateParamsTest { SandboxPaymentCreateParams.builder() .endDate("end_date") .addPayStatement( - SandboxPaymentCreateParams.PayStatement.builder() + PayStatement.builder() .addEarning( - SandboxPaymentCreateParams.PayStatement.Earning.builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .type(PayStatement.Earning.Type.SALARY) .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes.builder() + PayStatement.Earning.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .Metadata - .builder() + PayStatement.Earning.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -47,25 +43,18 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .addEmployeeDeduction( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .Metadata - .builder() + PayStatement.EmployeeDeduction.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata + PayStatement.EmployeeDeduction.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -81,24 +70,18 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .addEmployerContribution( - SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .Metadata + PayStatement.EmployerContribution.Attributes.Metadata .builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .InnerMetadata .builder() @@ -117,25 +100,20 @@ internal class SandboxPaymentCreateParamsTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - SandboxPaymentCreateParams.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() + PayStatement.Tax.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .InnerMetadata + PayStatement.Tax.Attributes.Metadata.InnerMetadata .builder() .putAdditionalProperty( "foo", @@ -150,7 +128,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .startDate("start_date") @@ -163,26 +141,20 @@ internal class SandboxPaymentCreateParamsTest { SandboxPaymentCreateParams.builder() .endDate("end_date") .addPayStatement( - SandboxPaymentCreateParams.PayStatement.builder() + PayStatement.builder() .addEarning( - SandboxPaymentCreateParams.PayStatement.Earning.builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .type(PayStatement.Earning.Type.SALARY) .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .builder() + PayStatement.Earning.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -198,26 +170,19 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .addEmployeeDeduction( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata + PayStatement.EmployeeDeduction.Attributes.Metadata .builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .Metadata .InnerMetadata .builder() @@ -234,25 +199,18 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .addEmployerContribution( - SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes - .Metadata + PayStatement.EmployerContribution.Attributes.Metadata .builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .InnerMetadata .builder() @@ -271,24 +229,20 @@ internal class SandboxPaymentCreateParamsTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - SandboxPaymentCreateParams.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() + PayStatement.Tax.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -304,7 +258,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .startDate("start_date") @@ -315,24 +269,20 @@ internal class SandboxPaymentCreateParamsTest { assertThat(body.endDate()).contains("end_date") assertThat(body.payStatements().getOrNull()) .containsExactly( - SandboxPaymentCreateParams.PayStatement.builder() + PayStatement.builder() .addEarning( - SandboxPaymentCreateParams.PayStatement.Earning.builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY) + .type(PayStatement.Earning.Type.SALARY) .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes.builder() + PayStatement.Earning.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .Metadata - .builder() + PayStatement.Earning.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -348,25 +298,18 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .addEmployeeDeduction( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .Metadata - .builder() + PayStatement.EmployeeDeduction.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata + PayStatement.EmployeeDeduction.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -382,24 +325,18 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .addEmployerContribution( - SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .Metadata + PayStatement.EmployerContribution.Attributes.Metadata .builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .InnerMetadata .builder() @@ -418,25 +355,20 @@ internal class SandboxPaymentCreateParamsTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - SandboxPaymentCreateParams.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes.builder() + PayStatement.Tax.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .InnerMetadata + PayStatement.Tax.Attributes.Metadata.InnerMetadata .builder() .putAdditionalProperty( "foo", @@ -451,7 +383,7 @@ internal class SandboxPaymentCreateParamsTest { .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) assertThat(body.startDate()).contains("start_date") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt index ef9568d4..1ad649b2 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.BenefitType import com.tryfinch.api.models.Money +import com.tryfinch.api.models.PayStatement import com.tryfinch.api.models.SandboxPaymentCreateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -28,29 +29,20 @@ internal class PaymentServiceAsyncTest { SandboxPaymentCreateParams.builder() .endDate("end_date") .addPayStatement( - SandboxPaymentCreateParams.PayStatement.builder() + PayStatement.builder() .addEarning( - SandboxPaymentCreateParams.PayStatement.Earning.builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .builder() + PayStatement.Earning.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -66,26 +58,19 @@ internal class PaymentServiceAsyncTest { .build() ) .addEmployeeDeduction( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata + PayStatement.EmployeeDeduction.Attributes.Metadata .builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .Metadata .InnerMetadata .builder() @@ -102,26 +87,19 @@ internal class PaymentServiceAsyncTest { .build() ) .addEmployerContribution( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .InnerMetadata .builder() @@ -140,28 +118,20 @@ internal class PaymentServiceAsyncTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - SandboxPaymentCreateParams.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -177,7 +147,7 @@ internal class PaymentServiceAsyncTest { .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .startDate("start_date") diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt index f95640aa..51cadf5a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt @@ -7,6 +7,7 @@ import com.tryfinch.api.client.okhttp.FinchOkHttpClient import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.BenefitType import com.tryfinch.api.models.Money +import com.tryfinch.api.models.PayStatement import com.tryfinch.api.models.SandboxPaymentCreateParams import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -28,29 +29,20 @@ internal class PaymentServiceTest { SandboxPaymentCreateParams.builder() .endDate("end_date") .addPayStatement( - SandboxPaymentCreateParams.PayStatement.builder() + PayStatement.builder() .addEarning( - SandboxPaymentCreateParams.PayStatement.Earning.builder() + PayStatement.Earning.builder() .amount(0L) .currency("currency") .hours(0.0) .name("name") - .type( - SandboxPaymentCreateParams.PayStatement.Earning.Type.SALARY - ) + .type(PayStatement.Earning.Type.SALARY) .attributes( - SandboxPaymentCreateParams.PayStatement.Earning.Attributes - .builder() + PayStatement.Earning.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Earning - .Attributes - .Metadata - .builder() + PayStatement.Earning.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .Earning - .Attributes - .Metadata + PayStatement.Earning.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -66,26 +58,19 @@ internal class PaymentServiceTest { .build() ) .addEmployeeDeduction( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() + PayStatement.EmployeeDeduction.builder() .amount(0L) .currency("currency") .name("name") .preTax(true) .type(BenefitType._457) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployeeDeduction - .Attributes - .builder() + PayStatement.EmployeeDeduction.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes - .Metadata + PayStatement.EmployeeDeduction.Attributes.Metadata .builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployeeDeduction - .Attributes + PayStatement.EmployeeDeduction.Attributes .Metadata .InnerMetadata .builder() @@ -102,26 +87,19 @@ internal class PaymentServiceTest { .build() ) .addEmployerContribution( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .builder() + PayStatement.EmployerContribution.builder() .currency("currency") .name("name") .type(BenefitType._457) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.EmployerContribution - .Attributes - .builder() + PayStatement.EmployerContribution.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .builder() .metadata( - SandboxPaymentCreateParams.PayStatement - .EmployerContribution - .Attributes + PayStatement.EmployerContribution.Attributes .Metadata .InnerMetadata .builder() @@ -140,28 +118,20 @@ internal class PaymentServiceTest { .grossPay(Money.builder().amount(0L).currency("currency").build()) .individualId("individual_id") .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod( - SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK - ) + .paymentMethod(PayStatement.PaymentMethod.CHECK) .addTax( - SandboxPaymentCreateParams.PayStatement.Tax.builder() + PayStatement.Tax.builder() .currency("currency") .employer(true) .name("name") - .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.STATE) + .type(PayStatement.Tax.Type.STATE) .amount(0L) .attributes( - SandboxPaymentCreateParams.PayStatement.Tax.Attributes - .builder() + PayStatement.Tax.Attributes.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata - .builder() + PayStatement.Tax.Attributes.Metadata.builder() .metadata( - SandboxPaymentCreateParams.PayStatement.Tax - .Attributes - .Metadata + PayStatement.Tax.Attributes.Metadata .InnerMetadata .builder() .putAdditionalProperty( @@ -177,7 +147,7 @@ internal class PaymentServiceTest { .build() ) .totalHours(0.0) - .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) + .type(PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) .startDate("start_date") From d6b79edb8319349a9b1141eb686f1e72b45929aa Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 15:43:41 +0000 Subject: [PATCH 12/26] fix(client): update pagination --- .stats.yml | 2 +- .../models/BenefitFeaturesAndOperations.kt | 936 +----------------- .../BenefitListSupportedBenefitsResponse.kt | 918 ----------------- .../HrisBenefitListSupportedBenefitsPage.kt | 14 +- ...isBenefitListSupportedBenefitsPageAsync.kt | 14 +- .../async/hris/BenefitServiceAsyncImpl.kt | 9 +- .../blocking/hris/BenefitServiceImpl.kt | 9 +- .../api/models/AccountUpdateEventTest.kt | 552 +++-------- .../BenefitFeaturesAndOperationsTest.kt | 44 +- ...enefitListSupportedBenefitsResponseTest.kt | 70 -- .../api/models/BenefitsSupportTest.kt | 528 +++------- .../com/tryfinch/api/models/ProviderTest.kt | 504 +++------- .../tryfinch/api/models/WebhookEventTest.kt | 360 ++----- 13 files changed, 567 insertions(+), 3393 deletions(-) delete mode 100644 finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt delete mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt diff --git a/.stats.yml b/.stats.yml index b21d83cd..774f2cc2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-1a82d3230c420c8562600b0ad45133d79ab68ffd21d524ab26eef11e163dba09.yml openapi_spec_hash: 7bd02ce73505e51c5fd78608fed55c62 -config_hash: bb896000dc7e790e5c9ddda2549fb7ac +config_hash: 9c795d6cb8440ac8e7e760997a486fc4 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperations.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperations.kt index 2d9f9c47..b7429b6f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperations.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperations.kt @@ -6,13 +6,10 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty -import com.tryfinch.api.core.Enum import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.core.checkKnown -import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException import java.util.Collections import java.util.Objects @@ -21,7 +18,7 @@ import kotlin.jvm.optionals.getOrNull class BenefitFeaturesAndOperations private constructor( - private val supportedFeatures: JsonField, + private val supportedFeatures: JsonField, private val supportedOperations: JsonField, private val additionalProperties: MutableMap, ) { @@ -30,7 +27,7 @@ private constructor( private constructor( @JsonProperty("supported_features") @ExcludeMissing - supportedFeatures: JsonField = JsonMissing.of(), + supportedFeatures: JsonField = JsonMissing.of(), @JsonProperty("supported_operations") @ExcludeMissing supportedOperations: JsonField = JsonMissing.of(), @@ -40,7 +37,7 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun supportedFeatures(): Optional = + fun supportedFeatures(): Optional = supportedFeatures.getOptional("supported_features") /** @@ -58,7 +55,7 @@ private constructor( */ @JsonProperty("supported_features") @ExcludeMissing - fun _supportedFeatures(): JsonField = supportedFeatures + fun _supportedFeatures(): JsonField = supportedFeatures /** * Returns the raw JSON value of [supportedOperations]. @@ -93,7 +90,7 @@ private constructor( /** A builder for [BenefitFeaturesAndOperations]. */ class Builder internal constructor() { - private var supportedFeatures: JsonField = JsonMissing.of() + private var supportedFeatures: JsonField = JsonMissing.of() private var supportedOperations: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -104,17 +101,17 @@ private constructor( additionalProperties = benefitFeaturesAndOperations.additionalProperties.toMutableMap() } - fun supportedFeatures(supportedFeatures: BenefitFeature) = + fun supportedFeatures(supportedFeatures: SupportedBenefit) = supportedFeatures(JsonField.of(supportedFeatures)) /** * Sets [Builder.supportedFeatures] to an arbitrary JSON value. * - * You should usually call [Builder.supportedFeatures] with a well-typed [BenefitFeature] + * You should usually call [Builder.supportedFeatures] with a well-typed [SupportedBenefit] * value instead. This method is primarily for setting the field to an undocumented or not * yet supported value. */ - fun supportedFeatures(supportedFeatures: JsonField) = apply { + fun supportedFeatures(supportedFeatures: JsonField) = apply { this.supportedFeatures = supportedFeatures } @@ -194,923 +191,6 @@ private constructor( (supportedFeatures.asKnown().getOrNull()?.validity() ?: 0) + (supportedOperations.asKnown().getOrNull()?.validity() ?: 0) - class BenefitFeature - private constructor( - private val annualMaximum: JsonField, - private val catchUp: JsonField, - private val companyContribution: JsonField>, - private val description: JsonField, - private val employeeDeduction: JsonField>, - private val frequencies: JsonField>, - private val hsaContributionLimit: JsonField>, - private val additionalProperties: MutableMap, - ) { - - @JsonCreator - private constructor( - @JsonProperty("annual_maximum") - @ExcludeMissing - annualMaximum: JsonField = JsonMissing.of(), - @JsonProperty("catch_up") - @ExcludeMissing - catchUp: JsonField = JsonMissing.of(), - @JsonProperty("company_contribution") - @ExcludeMissing - companyContribution: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("employee_deduction") - @ExcludeMissing - employeeDeduction: JsonField> = JsonMissing.of(), - @JsonProperty("frequencies") - @ExcludeMissing - frequencies: JsonField> = JsonMissing.of(), - @JsonProperty("hsa_contribution_limit") - @ExcludeMissing - hsaContributionLimit: JsonField> = JsonMissing.of(), - ) : this( - annualMaximum, - catchUp, - companyContribution, - description, - employeeDeduction, - frequencies, - hsaContributionLimit, - mutableMapOf(), - ) - - /** - * Whether the provider supports an annual maximum for this benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun annualMaximum(): Optional = annualMaximum.getOptional("annual_maximum") - - /** - * Whether the provider supports catch up for this benefit. This field will only be true for - * retirement benefits. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun catchUp(): Optional = catchUp.getOptional("catch_up") - - /** - * Supported contribution types. An empty array indicates contributions are not supported. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun companyContribution(): Optional> = - companyContribution.getOptional("company_contribution") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Supported deduction types. An empty array indicates deductions are not supported. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employeeDeduction(): Optional> = - employeeDeduction.getOptional("employee_deduction") - - /** - * The list of frequencies supported by the provider for this benefit - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun frequencies(): Optional> = - frequencies.getOptional("frequencies") - - /** - * Whether the provider supports HSA contribution limits. Empty if this feature is not - * supported for the benefit. This array only has values for HSA benefits. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hsaContributionLimit(): Optional> = - hsaContributionLimit.getOptional("hsa_contribution_limit") - - /** - * Returns the raw JSON value of [annualMaximum]. - * - * Unlike [annualMaximum], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("annual_maximum") - @ExcludeMissing - fun _annualMaximum(): JsonField = annualMaximum - - /** - * Returns the raw JSON value of [catchUp]. - * - * Unlike [catchUp], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("catch_up") @ExcludeMissing fun _catchUp(): JsonField = catchUp - - /** - * Returns the raw JSON value of [companyContribution]. - * - * Unlike [companyContribution], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("company_contribution") - @ExcludeMissing - fun _companyContribution(): JsonField> = companyContribution - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") - @ExcludeMissing - fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [employeeDeduction]. - * - * Unlike [employeeDeduction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employee_deduction") - @ExcludeMissing - fun _employeeDeduction(): JsonField> = employeeDeduction - - /** - * Returns the raw JSON value of [frequencies]. - * - * Unlike [frequencies], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("frequencies") - @ExcludeMissing - fun _frequencies(): JsonField> = frequencies - - /** - * Returns the raw JSON value of [hsaContributionLimit]. - * - * Unlike [hsaContributionLimit], this method doesn't throw if the JSON field has an - * unexpected type. - */ - @JsonProperty("hsa_contribution_limit") - @ExcludeMissing - fun _hsaContributionLimit(): JsonField> = hsaContributionLimit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** Returns a mutable builder for constructing an instance of [BenefitFeature]. */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BenefitFeature]. */ - class Builder internal constructor() { - - private var annualMaximum: JsonField = JsonMissing.of() - private var catchUp: JsonField = JsonMissing.of() - private var companyContribution: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var employeeDeduction: JsonField>? = null - private var frequencies: JsonField>? = null - private var hsaContributionLimit: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from(benefitFeature: BenefitFeature) = apply { - annualMaximum = benefitFeature.annualMaximum - catchUp = benefitFeature.catchUp - companyContribution = benefitFeature.companyContribution.map { it.toMutableList() } - description = benefitFeature.description - employeeDeduction = benefitFeature.employeeDeduction.map { it.toMutableList() } - frequencies = benefitFeature.frequencies.map { it.toMutableList() } - hsaContributionLimit = - benefitFeature.hsaContributionLimit.map { it.toMutableList() } - additionalProperties = benefitFeature.additionalProperties.toMutableMap() - } - - /** Whether the provider supports an annual maximum for this benefit. */ - fun annualMaximum(annualMaximum: Boolean?) = - annualMaximum(JsonField.ofNullable(annualMaximum)) - - /** - * Alias for [Builder.annualMaximum]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun annualMaximum(annualMaximum: Boolean) = annualMaximum(annualMaximum as Boolean?) - - /** Alias for calling [Builder.annualMaximum] with `annualMaximum.orElse(null)`. */ - fun annualMaximum(annualMaximum: Optional) = - annualMaximum(annualMaximum.getOrNull()) - - /** - * Sets [Builder.annualMaximum] to an arbitrary JSON value. - * - * You should usually call [Builder.annualMaximum] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun annualMaximum(annualMaximum: JsonField) = apply { - this.annualMaximum = annualMaximum - } - - /** - * Whether the provider supports catch up for this benefit. This field will only be true - * for retirement benefits. - */ - fun catchUp(catchUp: Boolean?) = catchUp(JsonField.ofNullable(catchUp)) - - /** - * Alias for [Builder.catchUp]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun catchUp(catchUp: Boolean) = catchUp(catchUp as Boolean?) - - /** Alias for calling [Builder.catchUp] with `catchUp.orElse(null)`. */ - fun catchUp(catchUp: Optional) = catchUp(catchUp.getOrNull()) - - /** - * Sets [Builder.catchUp] to an arbitrary JSON value. - * - * You should usually call [Builder.catchUp] with a well-typed [Boolean] value instead. - * This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun catchUp(catchUp: JsonField) = apply { this.catchUp = catchUp } - - /** - * Supported contribution types. An empty array indicates contributions are not - * supported. - */ - fun companyContribution(companyContribution: List?) = - companyContribution(JsonField.ofNullable(companyContribution)) - - /** - * Alias for calling [Builder.companyContribution] with - * `companyContribution.orElse(null)`. - */ - fun companyContribution(companyContribution: Optional>) = - companyContribution(companyContribution.getOrNull()) - - /** - * Sets [Builder.companyContribution] to an arbitrary JSON value. - * - * You should usually call [Builder.companyContribution] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun companyContribution(companyContribution: JsonField>) = - apply { - this.companyContribution = companyContribution.map { it.toMutableList() } - } - - /** - * Adds a single [CompanyContribution] to [Builder.companyContribution]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCompanyContribution(companyContribution: CompanyContribution) = apply { - this.companyContribution = - (this.companyContribution ?: JsonField.of(mutableListOf())).also { - checkKnown("companyContribution", it).add(companyContribution) - } - } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun description(description: JsonField) = apply { - this.description = description - } - - /** Supported deduction types. An empty array indicates deductions are not supported. */ - fun employeeDeduction(employeeDeduction: List?) = - employeeDeduction(JsonField.ofNullable(employeeDeduction)) - - /** - * Alias for calling [Builder.employeeDeduction] with `employeeDeduction.orElse(null)`. - */ - fun employeeDeduction(employeeDeduction: Optional>) = - employeeDeduction(employeeDeduction.getOrNull()) - - /** - * Sets [Builder.employeeDeduction] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeDeduction] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun employeeDeduction(employeeDeduction: JsonField>) = apply { - this.employeeDeduction = employeeDeduction.map { it.toMutableList() } - } - - /** - * Adds a single [EmployeeDeduction] to [Builder.employeeDeduction]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { - this.employeeDeduction = - (this.employeeDeduction ?: JsonField.of(mutableListOf())).also { - checkKnown("employeeDeduction", it).add(employeeDeduction) - } - } - - /** The list of frequencies supported by the provider for this benefit */ - fun frequencies(frequencies: List) = - frequencies(JsonField.of(frequencies)) - - /** - * Sets [Builder.frequencies] to an arbitrary JSON value. - * - * You should usually call [Builder.frequencies] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun frequencies(frequencies: JsonField>) = apply { - this.frequencies = frequencies.map { it.toMutableList() } - } - - /** - * Adds a single [BenefitFrequency] to [frequencies]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFrequency(frequency: BenefitFrequency) = apply { - frequencies = - (frequencies ?: JsonField.of(mutableListOf())).also { - checkKnown("frequencies", it).add(frequency) - } - } - - /** - * Whether the provider supports HSA contribution limits. Empty if this feature is not - * supported for the benefit. This array only has values for HSA benefits. - */ - fun hsaContributionLimit(hsaContributionLimit: List?) = - hsaContributionLimit(JsonField.ofNullable(hsaContributionLimit)) - - /** - * Alias for calling [Builder.hsaContributionLimit] with - * `hsaContributionLimit.orElse(null)`. - */ - fun hsaContributionLimit(hsaContributionLimit: Optional>) = - hsaContributionLimit(hsaContributionLimit.getOrNull()) - - /** - * Sets [Builder.hsaContributionLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.hsaContributionLimit] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun hsaContributionLimit(hsaContributionLimit: JsonField>) = - apply { - this.hsaContributionLimit = hsaContributionLimit.map { it.toMutableList() } - } - - /** - * Adds a single [HsaContributionLimit] to [Builder.hsaContributionLimit]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addHsaContributionLimit(hsaContributionLimit: HsaContributionLimit) = apply { - this.hsaContributionLimit = - (this.hsaContributionLimit ?: JsonField.of(mutableListOf())).also { - checkKnown("hsaContributionLimit", it).add(hsaContributionLimit) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BenefitFeature]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BenefitFeature = - BenefitFeature( - annualMaximum, - catchUp, - (companyContribution ?: JsonMissing.of()).map { it.toImmutable() }, - description, - (employeeDeduction ?: JsonMissing.of()).map { it.toImmutable() }, - (frequencies ?: JsonMissing.of()).map { it.toImmutable() }, - (hsaContributionLimit ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BenefitFeature = apply { - if (validated) { - return@apply - } - - annualMaximum() - catchUp() - companyContribution().ifPresent { it.forEach { it?.validate() } } - description() - employeeDeduction().ifPresent { it.forEach { it?.validate() } } - frequencies().ifPresent { it.forEach { it?.validate() } } - hsaContributionLimit().ifPresent { it.forEach { it?.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (annualMaximum.asKnown().isPresent) 1 else 0) + - (if (catchUp.asKnown().isPresent) 1 else 0) + - (companyContribution.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (employeeDeduction.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (frequencies.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (hsaContributionLimit.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) - - class CompanyContribution - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIXED = of("fixed") - - @JvmField val PERCENT = of("percent") - - @JvmStatic fun of(value: String) = CompanyContribution(JsonField.of(value)) - } - - /** An enum containing [CompanyContribution]'s known values. */ - enum class Known { - FIXED, - PERCENT, - } - - /** - * An enum containing [CompanyContribution]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [CompanyContribution] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - FIXED, - PERCENT, - /** - * An enum member indicating that [CompanyContribution] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - FIXED -> Value.FIXED - PERCENT -> Value.PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - FIXED -> Known.FIXED - PERCENT -> Known.PERCENT - else -> throw FinchInvalidDataException("Unknown CompanyContribution: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): CompanyContribution = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CompanyContribution && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EmployeeDeduction - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIXED = of("fixed") - - @JvmField val PERCENT = of("percent") - - @JvmStatic fun of(value: String) = EmployeeDeduction(JsonField.of(value)) - } - - /** An enum containing [EmployeeDeduction]'s known values. */ - enum class Known { - FIXED, - PERCENT, - } - - /** - * An enum containing [EmployeeDeduction]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [EmployeeDeduction] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - FIXED, - PERCENT, - /** - * An enum member indicating that [EmployeeDeduction] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - FIXED -> Value.FIXED - PERCENT -> Value.PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - FIXED -> Known.FIXED - PERCENT -> Known.PERCENT - else -> throw FinchInvalidDataException("Unknown EmployeeDeduction: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): EmployeeDeduction = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployeeDeduction && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class HsaContributionLimit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is - * on an older version than the API, then the API may respond with new members that the - * SDK is unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INDIVIDUAL = of("individual") - - @JvmField val FAMILY = of("family") - - @JvmStatic fun of(value: String) = HsaContributionLimit(JsonField.of(value)) - } - - /** An enum containing [HsaContributionLimit]'s known values. */ - enum class Known { - INDIVIDUAL, - FAMILY, - } - - /** - * An enum containing [HsaContributionLimit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [HsaContributionLimit] can contain an unknown value in a couple of - * cases: - * - It was deserialized from data that doesn't match any known member. For example, if - * the SDK is on an older version than the API, then the API may respond with new - * members that the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INDIVIDUAL, - FAMILY, - /** - * An enum member indicating that [HsaContributionLimit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or - * [Value._UNKNOWN] if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you - * want to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INDIVIDUAL -> Value.INDIVIDUAL - FAMILY -> Value.FAMILY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and - * don't want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known - * member. - */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - FAMILY -> Known.FAMILY - else -> throw FinchInvalidDataException("Unknown HsaContributionLimit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for - * debugging and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { - FinchInvalidDataException("Value is not a String") - } - - private var validated: Boolean = false - - fun validate(): HsaContributionLimit = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HsaContributionLimit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BenefitFeature && annualMaximum == other.annualMaximum && catchUp == other.catchUp && companyContribution == other.companyContribution && description == other.description && employeeDeduction == other.employeeDeduction && frequencies == other.frequencies && hsaContributionLimit == other.hsaContributionLimit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(annualMaximum, catchUp, companyContribution, description, employeeDeduction, frequencies, hsaContributionLimit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BenefitFeature{annualMaximum=$annualMaximum, catchUp=$catchUp, companyContribution=$companyContribution, description=$description, employeeDeduction=$employeeDeduction, frequencies=$frequencies, hsaContributionLimit=$hsaContributionLimit, additionalProperties=$additionalProperties}" - } - override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt deleted file mode 100644 index be8e05eb..00000000 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponse.kt +++ /dev/null @@ -1,918 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.tryfinch.api.models - -import com.fasterxml.jackson.annotation.JsonAnyGetter -import com.fasterxml.jackson.annotation.JsonAnySetter -import com.fasterxml.jackson.annotation.JsonCreator -import com.fasterxml.jackson.annotation.JsonProperty -import com.tryfinch.api.core.Enum -import com.tryfinch.api.core.ExcludeMissing -import com.tryfinch.api.core.JsonField -import com.tryfinch.api.core.JsonMissing -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.core.checkKnown -import com.tryfinch.api.core.toImmutable -import com.tryfinch.api.errors.FinchInvalidDataException -import java.util.Collections -import java.util.Objects -import java.util.Optional -import kotlin.jvm.optionals.getOrNull - -class BenefitListSupportedBenefitsResponse -private constructor( - private val annualMaximum: JsonField, - private val catchUp: JsonField, - private val companyContribution: JsonField>, - private val description: JsonField, - private val employeeDeduction: JsonField>, - private val frequencies: JsonField>, - private val hsaContributionLimit: JsonField>, - private val additionalProperties: MutableMap, -) { - - @JsonCreator - private constructor( - @JsonProperty("annual_maximum") - @ExcludeMissing - annualMaximum: JsonField = JsonMissing.of(), - @JsonProperty("catch_up") @ExcludeMissing catchUp: JsonField = JsonMissing.of(), - @JsonProperty("company_contribution") - @ExcludeMissing - companyContribution: JsonField> = JsonMissing.of(), - @JsonProperty("description") - @ExcludeMissing - description: JsonField = JsonMissing.of(), - @JsonProperty("employee_deduction") - @ExcludeMissing - employeeDeduction: JsonField> = JsonMissing.of(), - @JsonProperty("frequencies") - @ExcludeMissing - frequencies: JsonField> = JsonMissing.of(), - @JsonProperty("hsa_contribution_limit") - @ExcludeMissing - hsaContributionLimit: JsonField> = JsonMissing.of(), - ) : this( - annualMaximum, - catchUp, - companyContribution, - description, - employeeDeduction, - frequencies, - hsaContributionLimit, - mutableMapOf(), - ) - - /** - * Whether the provider supports an annual maximum for this benefit. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun annualMaximum(): Optional = annualMaximum.getOptional("annual_maximum") - - /** - * Whether the provider supports catch up for this benefit. This field will only be true for - * retirement benefits. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun catchUp(): Optional = catchUp.getOptional("catch_up") - - /** - * Supported contribution types. An empty array indicates contributions are not supported. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun companyContribution(): Optional> = - companyContribution.getOptional("company_contribution") - - /** - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun description(): Optional = description.getOptional("description") - - /** - * Supported deduction types. An empty array indicates deductions are not supported. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun employeeDeduction(): Optional> = - employeeDeduction.getOptional("employee_deduction") - - /** - * The list of frequencies supported by the provider for this benefit - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun frequencies(): Optional> = frequencies.getOptional("frequencies") - - /** - * Whether the provider supports HSA contribution limits. Empty if this feature is not supported - * for the benefit. This array only has values for HSA benefits. - * - * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the - * server responded with an unexpected value). - */ - fun hsaContributionLimit(): Optional> = - hsaContributionLimit.getOptional("hsa_contribution_limit") - - /** - * Returns the raw JSON value of [annualMaximum]. - * - * Unlike [annualMaximum], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("annual_maximum") - @ExcludeMissing - fun _annualMaximum(): JsonField = annualMaximum - - /** - * Returns the raw JSON value of [catchUp]. - * - * Unlike [catchUp], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("catch_up") @ExcludeMissing fun _catchUp(): JsonField = catchUp - - /** - * Returns the raw JSON value of [companyContribution]. - * - * Unlike [companyContribution], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("company_contribution") - @ExcludeMissing - fun _companyContribution(): JsonField> = companyContribution - - /** - * Returns the raw JSON value of [description]. - * - * Unlike [description], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - - /** - * Returns the raw JSON value of [employeeDeduction]. - * - * Unlike [employeeDeduction], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("employee_deduction") - @ExcludeMissing - fun _employeeDeduction(): JsonField> = employeeDeduction - - /** - * Returns the raw JSON value of [frequencies]. - * - * Unlike [frequencies], this method doesn't throw if the JSON field has an unexpected type. - */ - @JsonProperty("frequencies") - @ExcludeMissing - fun _frequencies(): JsonField> = frequencies - - /** - * Returns the raw JSON value of [hsaContributionLimit]. - * - * Unlike [hsaContributionLimit], this method doesn't throw if the JSON field has an unexpected - * type. - */ - @JsonProperty("hsa_contribution_limit") - @ExcludeMissing - fun _hsaContributionLimit(): JsonField> = hsaContributionLimit - - @JsonAnySetter - private fun putAdditionalProperty(key: String, value: JsonValue) { - additionalProperties.put(key, value) - } - - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = - Collections.unmodifiableMap(additionalProperties) - - fun toBuilder() = Builder().from(this) - - companion object { - - /** - * Returns a mutable builder for constructing an instance of - * [BenefitListSupportedBenefitsResponse]. - */ - @JvmStatic fun builder() = Builder() - } - - /** A builder for [BenefitListSupportedBenefitsResponse]. */ - class Builder internal constructor() { - - private var annualMaximum: JsonField = JsonMissing.of() - private var catchUp: JsonField = JsonMissing.of() - private var companyContribution: JsonField>? = null - private var description: JsonField = JsonMissing.of() - private var employeeDeduction: JsonField>? = null - private var frequencies: JsonField>? = null - private var hsaContributionLimit: JsonField>? = null - private var additionalProperties: MutableMap = mutableMapOf() - - @JvmSynthetic - internal fun from( - benefitListSupportedBenefitsResponse: BenefitListSupportedBenefitsResponse - ) = apply { - annualMaximum = benefitListSupportedBenefitsResponse.annualMaximum - catchUp = benefitListSupportedBenefitsResponse.catchUp - companyContribution = - benefitListSupportedBenefitsResponse.companyContribution.map { it.toMutableList() } - description = benefitListSupportedBenefitsResponse.description - employeeDeduction = - benefitListSupportedBenefitsResponse.employeeDeduction.map { it.toMutableList() } - frequencies = - benefitListSupportedBenefitsResponse.frequencies.map { it.toMutableList() } - hsaContributionLimit = - benefitListSupportedBenefitsResponse.hsaContributionLimit.map { it.toMutableList() } - additionalProperties = - benefitListSupportedBenefitsResponse.additionalProperties.toMutableMap() - } - - /** Whether the provider supports an annual maximum for this benefit. */ - fun annualMaximum(annualMaximum: Boolean?) = - annualMaximum(JsonField.ofNullable(annualMaximum)) - - /** - * Alias for [Builder.annualMaximum]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun annualMaximum(annualMaximum: Boolean) = annualMaximum(annualMaximum as Boolean?) - - /** Alias for calling [Builder.annualMaximum] with `annualMaximum.orElse(null)`. */ - fun annualMaximum(annualMaximum: Optional) = - annualMaximum(annualMaximum.getOrNull()) - - /** - * Sets [Builder.annualMaximum] to an arbitrary JSON value. - * - * You should usually call [Builder.annualMaximum] with a well-typed [Boolean] value - * instead. This method is primarily for setting the field to an undocumented or not yet - * supported value. - */ - fun annualMaximum(annualMaximum: JsonField) = apply { - this.annualMaximum = annualMaximum - } - - /** - * Whether the provider supports catch up for this benefit. This field will only be true for - * retirement benefits. - */ - fun catchUp(catchUp: Boolean?) = catchUp(JsonField.ofNullable(catchUp)) - - /** - * Alias for [Builder.catchUp]. - * - * This unboxed primitive overload exists for backwards compatibility. - */ - fun catchUp(catchUp: Boolean) = catchUp(catchUp as Boolean?) - - /** Alias for calling [Builder.catchUp] with `catchUp.orElse(null)`. */ - fun catchUp(catchUp: Optional) = catchUp(catchUp.getOrNull()) - - /** - * Sets [Builder.catchUp] to an arbitrary JSON value. - * - * You should usually call [Builder.catchUp] with a well-typed [Boolean] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. - */ - fun catchUp(catchUp: JsonField) = apply { this.catchUp = catchUp } - - /** - * Supported contribution types. An empty array indicates contributions are not supported. - */ - fun companyContribution(companyContribution: List?) = - companyContribution(JsonField.ofNullable(companyContribution)) - - /** - * Alias for calling [Builder.companyContribution] with `companyContribution.orElse(null)`. - */ - fun companyContribution(companyContribution: Optional>) = - companyContribution(companyContribution.getOrNull()) - - /** - * Sets [Builder.companyContribution] to an arbitrary JSON value. - * - * You should usually call [Builder.companyContribution] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun companyContribution(companyContribution: JsonField>) = - apply { - this.companyContribution = companyContribution.map { it.toMutableList() } - } - - /** - * Adds a single [CompanyContribution] to [Builder.companyContribution]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addCompanyContribution(companyContribution: CompanyContribution) = apply { - this.companyContribution = - (this.companyContribution ?: JsonField.of(mutableListOf())).also { - checkKnown("companyContribution", it).add(companyContribution) - } - } - - fun description(description: String?) = description(JsonField.ofNullable(description)) - - /** Alias for calling [Builder.description] with `description.orElse(null)`. */ - fun description(description: Optional) = description(description.getOrNull()) - - /** - * Sets [Builder.description] to an arbitrary JSON value. - * - * You should usually call [Builder.description] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. - */ - fun description(description: JsonField) = apply { this.description = description } - - /** Supported deduction types. An empty array indicates deductions are not supported. */ - fun employeeDeduction(employeeDeduction: List?) = - employeeDeduction(JsonField.ofNullable(employeeDeduction)) - - /** Alias for calling [Builder.employeeDeduction] with `employeeDeduction.orElse(null)`. */ - fun employeeDeduction(employeeDeduction: Optional>) = - employeeDeduction(employeeDeduction.getOrNull()) - - /** - * Sets [Builder.employeeDeduction] to an arbitrary JSON value. - * - * You should usually call [Builder.employeeDeduction] with a well-typed - * `List` value instead. This method is primarily for setting the field - * to an undocumented or not yet supported value. - */ - fun employeeDeduction(employeeDeduction: JsonField>) = apply { - this.employeeDeduction = employeeDeduction.map { it.toMutableList() } - } - - /** - * Adds a single [EmployeeDeduction] to [Builder.employeeDeduction]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { - this.employeeDeduction = - (this.employeeDeduction ?: JsonField.of(mutableListOf())).also { - checkKnown("employeeDeduction", it).add(employeeDeduction) - } - } - - /** The list of frequencies supported by the provider for this benefit */ - fun frequencies(frequencies: List) = - frequencies(JsonField.of(frequencies)) - - /** - * Sets [Builder.frequencies] to an arbitrary JSON value. - * - * You should usually call [Builder.frequencies] with a well-typed `List` - * value instead. This method is primarily for setting the field to an undocumented or not - * yet supported value. - */ - fun frequencies(frequencies: JsonField>) = apply { - this.frequencies = frequencies.map { it.toMutableList() } - } - - /** - * Adds a single [BenefitFrequency] to [frequencies]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addFrequency(frequency: BenefitFrequency) = apply { - frequencies = - (frequencies ?: JsonField.of(mutableListOf())).also { - checkKnown("frequencies", it).add(frequency) - } - } - - /** - * Whether the provider supports HSA contribution limits. Empty if this feature is not - * supported for the benefit. This array only has values for HSA benefits. - */ - fun hsaContributionLimit(hsaContributionLimit: List?) = - hsaContributionLimit(JsonField.ofNullable(hsaContributionLimit)) - - /** - * Alias for calling [Builder.hsaContributionLimit] with - * `hsaContributionLimit.orElse(null)`. - */ - fun hsaContributionLimit(hsaContributionLimit: Optional>) = - hsaContributionLimit(hsaContributionLimit.getOrNull()) - - /** - * Sets [Builder.hsaContributionLimit] to an arbitrary JSON value. - * - * You should usually call [Builder.hsaContributionLimit] with a well-typed - * `List` value instead. This method is primarily for setting the - * field to an undocumented or not yet supported value. - */ - fun hsaContributionLimit(hsaContributionLimit: JsonField>) = - apply { - this.hsaContributionLimit = hsaContributionLimit.map { it.toMutableList() } - } - - /** - * Adds a single [HsaContributionLimit] to [Builder.hsaContributionLimit]. - * - * @throws IllegalStateException if the field was previously set to a non-list. - */ - fun addHsaContributionLimit(hsaContributionLimit: HsaContributionLimit) = apply { - this.hsaContributionLimit = - (this.hsaContributionLimit ?: JsonField.of(mutableListOf())).also { - checkKnown("hsaContributionLimit", it).add(hsaContributionLimit) - } - } - - fun additionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.clear() - putAllAdditionalProperties(additionalProperties) - } - - fun putAdditionalProperty(key: String, value: JsonValue) = apply { - additionalProperties.put(key, value) - } - - fun putAllAdditionalProperties(additionalProperties: Map) = apply { - this.additionalProperties.putAll(additionalProperties) - } - - fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } - - fun removeAllAdditionalProperties(keys: Set) = apply { - keys.forEach(::removeAdditionalProperty) - } - - /** - * Returns an immutable instance of [BenefitListSupportedBenefitsResponse]. - * - * Further updates to this [Builder] will not mutate the returned instance. - */ - fun build(): BenefitListSupportedBenefitsResponse = - BenefitListSupportedBenefitsResponse( - annualMaximum, - catchUp, - (companyContribution ?: JsonMissing.of()).map { it.toImmutable() }, - description, - (employeeDeduction ?: JsonMissing.of()).map { it.toImmutable() }, - (frequencies ?: JsonMissing.of()).map { it.toImmutable() }, - (hsaContributionLimit ?: JsonMissing.of()).map { it.toImmutable() }, - additionalProperties.toMutableMap(), - ) - } - - private var validated: Boolean = false - - fun validate(): BenefitListSupportedBenefitsResponse = apply { - if (validated) { - return@apply - } - - annualMaximum() - catchUp() - companyContribution().ifPresent { it.forEach { it?.validate() } } - description() - employeeDeduction().ifPresent { it.forEach { it?.validate() } } - frequencies().ifPresent { it.forEach { it?.validate() } } - hsaContributionLimit().ifPresent { it.forEach { it?.validate() } } - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic - internal fun validity(): Int = - (if (annualMaximum.asKnown().isPresent) 1 else 0) + - (if (catchUp.asKnown().isPresent) 1 else 0) + - (companyContribution.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (if (description.asKnown().isPresent) 1 else 0) + - (employeeDeduction.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) + - (frequencies.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } ?: 0) + - (hsaContributionLimit.asKnown().getOrNull()?.sumOf { (it?.validity() ?: 0).toInt() } - ?: 0) - - class CompanyContribution - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIXED = of("fixed") - - @JvmField val PERCENT = of("percent") - - @JvmStatic fun of(value: String) = CompanyContribution(JsonField.of(value)) - } - - /** An enum containing [CompanyContribution]'s known values. */ - enum class Known { - FIXED, - PERCENT, - } - - /** - * An enum containing [CompanyContribution]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [CompanyContribution] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - FIXED, - PERCENT, - /** - * An enum member indicating that [CompanyContribution] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - FIXED -> Value.FIXED - PERCENT -> Value.PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - FIXED -> Known.FIXED - PERCENT -> Known.PERCENT - else -> throw FinchInvalidDataException("Unknown CompanyContribution: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): CompanyContribution = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is CompanyContribution && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class EmployeeDeduction @JsonCreator private constructor(private val value: JsonField) : - Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val FIXED = of("fixed") - - @JvmField val PERCENT = of("percent") - - @JvmStatic fun of(value: String) = EmployeeDeduction(JsonField.of(value)) - } - - /** An enum containing [EmployeeDeduction]'s known values. */ - enum class Known { - FIXED, - PERCENT, - } - - /** - * An enum containing [EmployeeDeduction]'s known values, as well as an [_UNKNOWN] member. - * - * An instance of [EmployeeDeduction] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - FIXED, - PERCENT, - /** - * An enum member indicating that [EmployeeDeduction] was instantiated with an unknown - * value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - FIXED -> Value.FIXED - PERCENT -> Value.PERCENT - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - FIXED -> Known.FIXED - PERCENT -> Known.PERCENT - else -> throw FinchInvalidDataException("Unknown EmployeeDeduction: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): EmployeeDeduction = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is EmployeeDeduction && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - class HsaContributionLimit - @JsonCreator - private constructor(private val value: JsonField) : Enum { - - /** - * Returns this class instance's raw value. - * - * This is usually only useful if this instance was deserialized from data that doesn't - * match any known member, and you want to know that value. For example, if the SDK is on an - * older version than the API, then the API may respond with new members that the SDK is - * unaware of. - */ - @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value - - companion object { - - @JvmField val INDIVIDUAL = of("individual") - - @JvmField val FAMILY = of("family") - - @JvmStatic fun of(value: String) = HsaContributionLimit(JsonField.of(value)) - } - - /** An enum containing [HsaContributionLimit]'s known values. */ - enum class Known { - INDIVIDUAL, - FAMILY, - } - - /** - * An enum containing [HsaContributionLimit]'s known values, as well as an [_UNKNOWN] - * member. - * - * An instance of [HsaContributionLimit] can contain an unknown value in a couple of cases: - * - It was deserialized from data that doesn't match any known member. For example, if the - * SDK is on an older version than the API, then the API may respond with new members that - * the SDK is unaware of. - * - It was constructed with an arbitrary value using the [of] method. - */ - enum class Value { - INDIVIDUAL, - FAMILY, - /** - * An enum member indicating that [HsaContributionLimit] was instantiated with an - * unknown value. - */ - _UNKNOWN, - } - - /** - * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] - * if the class was instantiated with an unknown value. - * - * Use the [known] method instead if you're certain the value is always known or if you want - * to throw for the unknown case. - */ - fun value(): Value = - when (this) { - INDIVIDUAL -> Value.INDIVIDUAL - FAMILY -> Value.FAMILY - else -> Value._UNKNOWN - } - - /** - * Returns an enum member corresponding to this class instance's value. - * - * Use the [value] method instead if you're uncertain the value is always known and don't - * want to throw for the unknown case. - * - * @throws FinchInvalidDataException if this class instance's value is a not a known member. - */ - fun known(): Known = - when (this) { - INDIVIDUAL -> Known.INDIVIDUAL - FAMILY -> Known.FAMILY - else -> throw FinchInvalidDataException("Unknown HsaContributionLimit: $value") - } - - /** - * Returns this class instance's primitive wire representation. - * - * This differs from the [toString] method because that method is primarily for debugging - * and generally doesn't throw. - * - * @throws FinchInvalidDataException if this class instance's value does not have the - * expected primitive type. - */ - fun asString(): String = - _value().asString().orElseThrow { FinchInvalidDataException("Value is not a String") } - - private var validated: Boolean = false - - fun validate(): HsaContributionLimit = apply { - if (validated) { - return@apply - } - - known() - validated = true - } - - fun isValid(): Boolean = - try { - validate() - true - } catch (e: FinchInvalidDataException) { - false - } - - /** - * Returns a score indicating how many valid values are contained in this object - * recursively. - * - * Used for best match union deserialization. - */ - @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is HsaContributionLimit && value == other.value /* spotless:on */ - } - - override fun hashCode() = value.hashCode() - - override fun toString() = value.toString() - } - - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } - - return /* spotless:off */ other is BenefitListSupportedBenefitsResponse && annualMaximum == other.annualMaximum && catchUp == other.catchUp && companyContribution == other.companyContribution && description == other.description && employeeDeduction == other.employeeDeduction && frequencies == other.frequencies && hsaContributionLimit == other.hsaContributionLimit && additionalProperties == other.additionalProperties /* spotless:on */ - } - - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(annualMaximum, catchUp, companyContribution, description, employeeDeduction, frequencies, hsaContributionLimit, additionalProperties) } - /* spotless:on */ - - override fun hashCode(): Int = hashCode - - override fun toString() = - "BenefitListSupportedBenefitsResponse{annualMaximum=$annualMaximum, catchUp=$catchUp, companyContribution=$companyContribution, description=$description, employeeDeduction=$employeeDeduction, frequencies=$frequencies, hsaContributionLimit=$hsaContributionLimit, additionalProperties=$additionalProperties}" -} diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt index e46538d6..15f3d0c8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPage.kt @@ -15,8 +15,8 @@ class HrisBenefitListSupportedBenefitsPage private constructor( private val service: BenefitService, private val params: HrisBenefitListSupportedBenefitsParams, - private val items: List, -) : Page { + private val items: List, +) : Page { override fun hasNextPage(): Boolean = false @@ -26,13 +26,13 @@ private constructor( override fun nextPage(): HrisBenefitListSupportedBenefitsPage = service.listSupportedBenefits(nextPageParams()) - fun autoPager(): AutoPager = AutoPager.from(this) + fun autoPager(): AutoPager = AutoPager.from(this) /** The parameters that were used to request this page. */ fun params(): HrisBenefitListSupportedBenefitsParams = params /** The response that this page was parsed from. */ - override fun items(): List = items + override fun items(): List = items fun toBuilder() = Builder().from(this) @@ -57,7 +57,7 @@ private constructor( private var service: BenefitService? = null private var params: HrisBenefitListSupportedBenefitsParams? = null - private var items: Optional>? = null + private var items: Optional>? = null @JvmSynthetic internal fun from( @@ -74,9 +74,7 @@ private constructor( fun params(params: HrisBenefitListSupportedBenefitsParams) = apply { this.params = params } /** The response that this page was parsed from. */ - fun items(items: Optional>) = apply { - this.items = items - } + fun items(items: Optional>) = apply { this.items = items } /** * Returns an immutable instance of [HrisBenefitListSupportedBenefitsPage]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt index 3e25be33..cdbc03ea 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitListSupportedBenefitsPageAsync.kt @@ -18,8 +18,8 @@ private constructor( private val service: BenefitServiceAsync, private val streamHandlerExecutor: Executor, private val params: HrisBenefitListSupportedBenefitsParams, - private val items: List, -) : PageAsync { + private val items: List, +) : PageAsync { override fun hasNextPage(): Boolean = false @@ -29,14 +29,14 @@ private constructor( override fun nextPage(): CompletableFuture = service.listSupportedBenefits(nextPageParams()) - fun autoPager(): AutoPagerAsync = + fun autoPager(): AutoPagerAsync = AutoPagerAsync.from(this, streamHandlerExecutor) /** The parameters that were used to request this page. */ fun params(): HrisBenefitListSupportedBenefitsParams = params /** The response that this page was parsed from. */ - override fun items(): List = items + override fun items(): List = items fun toBuilder() = Builder().from(this) @@ -63,7 +63,7 @@ private constructor( private var service: BenefitServiceAsync? = null private var streamHandlerExecutor: Executor? = null private var params: HrisBenefitListSupportedBenefitsParams? = null - private var items: Optional>? = null + private var items: Optional>? = null @JvmSynthetic internal fun from( @@ -85,9 +85,7 @@ private constructor( fun params(params: HrisBenefitListSupportedBenefitsParams) = apply { this.params = params } /** The response that this page was parsed from. */ - fun items(items: Optional>) = apply { - this.items = items - } + fun items(items: Optional>) = apply { this.items = items } /** * Returns an immutable instance of [HrisBenefitListSupportedBenefitsPageAsync]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt index 1e38a525..3465b62b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt @@ -16,7 +16,6 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.json import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepareAsync -import com.tryfinch.api.models.BenefitListSupportedBenefitsResponse import com.tryfinch.api.models.CompanyBenefit import com.tryfinch.api.models.CreateCompanyBenefitsResponse import com.tryfinch.api.models.HrisBenefitCreateParams @@ -26,6 +25,7 @@ import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsPageAsync import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams +import com.tryfinch.api.models.SupportedBenefit import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsyncImpl @@ -229,11 +229,8 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl } } - private val listSupportedBenefitsHandler: - Handler>> = - jsonHandler>>( - clientOptions.jsonMapper - ) + private val listSupportedBenefitsHandler: Handler>> = + jsonHandler>>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun listSupportedBenefits( diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt index 3fc43430..51b01e92 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt @@ -16,7 +16,6 @@ import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.core.http.json import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare -import com.tryfinch.api.models.BenefitListSupportedBenefitsResponse import com.tryfinch.api.models.CompanyBenefit import com.tryfinch.api.models.CreateCompanyBenefitsResponse import com.tryfinch.api.models.HrisBenefitCreateParams @@ -26,6 +25,7 @@ import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsPage import com.tryfinch.api.models.HrisBenefitListSupportedBenefitsParams import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams +import com.tryfinch.api.models.SupportedBenefit import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.blocking.hris.benefits.IndividualService import com.tryfinch.api.services.blocking.hris.benefits.IndividualServiceImpl @@ -213,11 +213,8 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO } } - private val listSupportedBenefitsHandler: - Handler>> = - jsonHandler>>( - clientOptions.jsonMapper - ) + private val listSupportedBenefitsHandler: Handler>> = + jsonHandler>>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) override fun listSupportedBenefits( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateEventTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateEventTest.kt index 6f34f4e4..a4782b0f 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateEventTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/AccountUpdateEventTest.kt @@ -25,28 +25,20 @@ internal class AccountUpdateEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -76,28 +68,20 @@ internal class AccountUpdateEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -127,28 +111,20 @@ internal class AccountUpdateEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -178,28 +154,20 @@ internal class AccountUpdateEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -229,28 +197,20 @@ internal class AccountUpdateEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -280,28 +240,20 @@ internal class AccountUpdateEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -331,28 +283,20 @@ internal class AccountUpdateEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -382,28 +326,20 @@ internal class AccountUpdateEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -433,28 +369,20 @@ internal class AccountUpdateEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -484,28 +412,20 @@ internal class AccountUpdateEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -535,28 +455,20 @@ internal class AccountUpdateEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -586,28 +498,20 @@ internal class AccountUpdateEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1024,25 +928,19 @@ internal class AccountUpdateEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1072,25 +970,19 @@ internal class AccountUpdateEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1120,25 +1012,19 @@ internal class AccountUpdateEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1168,25 +1054,19 @@ internal class AccountUpdateEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1216,25 +1096,19 @@ internal class AccountUpdateEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1264,25 +1138,19 @@ internal class AccountUpdateEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1312,25 +1180,19 @@ internal class AccountUpdateEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1360,25 +1222,19 @@ internal class AccountUpdateEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1408,25 +1264,19 @@ internal class AccountUpdateEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1456,25 +1306,19 @@ internal class AccountUpdateEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1504,25 +1348,19 @@ internal class AccountUpdateEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1552,25 +1390,19 @@ internal class AccountUpdateEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1979,28 +1811,20 @@ internal class AccountUpdateEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2030,28 +1854,20 @@ internal class AccountUpdateEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2081,28 +1897,20 @@ internal class AccountUpdateEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2132,28 +1940,20 @@ internal class AccountUpdateEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2183,28 +1983,20 @@ internal class AccountUpdateEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2234,28 +2026,20 @@ internal class AccountUpdateEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2285,28 +2069,20 @@ internal class AccountUpdateEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2336,28 +2112,20 @@ internal class AccountUpdateEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2387,28 +2155,20 @@ internal class AccountUpdateEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2438,28 +2198,20 @@ internal class AccountUpdateEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2489,28 +2241,20 @@ internal class AccountUpdateEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -2540,28 +2284,20 @@ internal class AccountUpdateEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperationsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperationsTest.kt index 8849aba2..9de222bf 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperationsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitFeaturesAndOperationsTest.kt @@ -14,21 +14,14 @@ internal class BenefitFeaturesAndOperationsTest { val benefitFeaturesAndOperations = BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) .build() ) .supportedOperations( @@ -55,20 +48,14 @@ internal class BenefitFeaturesAndOperationsTest { assertThat(benefitFeaturesAndOperations.supportedFeatures()) .contains( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit.INDIVIDUAL - ) + .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) .build() ) assertThat(benefitFeaturesAndOperations.supportedOperations()) @@ -100,21 +87,14 @@ internal class BenefitFeaturesAndOperationsTest { val benefitFeaturesAndOperations = BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution.FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL - ) + .addHsaContributionLimit(SupportedBenefit.HsaContributionLimit.INDIVIDUAL) .build() ) .supportedOperations( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt deleted file mode 100644 index ae8dc665..00000000 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitListSupportedBenefitsResponseTest.kt +++ /dev/null @@ -1,70 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. - -package com.tryfinch.api.models - -import com.fasterxml.jackson.module.kotlin.jacksonTypeRef -import com.tryfinch.api.core.jsonMapper -import kotlin.jvm.optionals.getOrNull -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test - -internal class BenefitListSupportedBenefitsResponseTest { - - @Test - fun create() { - val benefitListSupportedBenefitsResponse = - BenefitListSupportedBenefitsResponse.builder() - .annualMaximum(true) - .catchUp(true) - .addCompanyContribution( - BenefitListSupportedBenefitsResponse.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction(BenefitListSupportedBenefitsResponse.EmployeeDeduction.FIXED) - .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitListSupportedBenefitsResponse.HsaContributionLimit.INDIVIDUAL - ) - .build() - - assertThat(benefitListSupportedBenefitsResponse.annualMaximum()).contains(true) - assertThat(benefitListSupportedBenefitsResponse.catchUp()).contains(true) - assertThat(benefitListSupportedBenefitsResponse.companyContribution().getOrNull()) - .containsExactly(BenefitListSupportedBenefitsResponse.CompanyContribution.FIXED) - assertThat(benefitListSupportedBenefitsResponse.description()).contains("description") - assertThat(benefitListSupportedBenefitsResponse.employeeDeduction().getOrNull()) - .containsExactly(BenefitListSupportedBenefitsResponse.EmployeeDeduction.FIXED) - assertThat(benefitListSupportedBenefitsResponse.frequencies().getOrNull()) - .containsExactly(BenefitFrequency.ONE_TIME) - assertThat(benefitListSupportedBenefitsResponse.hsaContributionLimit().getOrNull()) - .containsExactly(BenefitListSupportedBenefitsResponse.HsaContributionLimit.INDIVIDUAL) - } - - @Test - fun roundtrip() { - val jsonMapper = jsonMapper() - val benefitListSupportedBenefitsResponse = - BenefitListSupportedBenefitsResponse.builder() - .annualMaximum(true) - .catchUp(true) - .addCompanyContribution( - BenefitListSupportedBenefitsResponse.CompanyContribution.FIXED - ) - .description("description") - .addEmployeeDeduction(BenefitListSupportedBenefitsResponse.EmployeeDeduction.FIXED) - .addFrequency(BenefitFrequency.ONE_TIME) - .addHsaContributionLimit( - BenefitListSupportedBenefitsResponse.HsaContributionLimit.INDIVIDUAL - ) - .build() - - val roundtrippedBenefitListSupportedBenefitsResponse = - jsonMapper.readValue( - jsonMapper.writeValueAsString(benefitListSupportedBenefitsResponse), - jacksonTypeRef(), - ) - - assertThat(roundtrippedBenefitListSupportedBenefitsResponse) - .isEqualTo(benefitListSupportedBenefitsResponse) - } -} diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitsSupportTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitsSupportTest.kt index 6490d096..9eb14c5c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitsSupportTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/BenefitsSupportTest.kt @@ -16,22 +16,15 @@ internal class BenefitsSupportTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -60,22 +53,15 @@ internal class BenefitsSupportTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -104,22 +90,15 @@ internal class BenefitsSupportTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -148,22 +127,15 @@ internal class BenefitsSupportTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -192,22 +164,15 @@ internal class BenefitsSupportTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -236,22 +201,15 @@ internal class BenefitsSupportTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -280,22 +238,15 @@ internal class BenefitsSupportTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -324,22 +275,15 @@ internal class BenefitsSupportTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -368,22 +312,15 @@ internal class BenefitsSupportTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -412,22 +349,15 @@ internal class BenefitsSupportTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -456,22 +386,15 @@ internal class BenefitsSupportTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -500,22 +423,15 @@ internal class BenefitsSupportTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -547,21 +463,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -591,21 +501,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -635,21 +539,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -679,21 +577,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -723,21 +615,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -767,21 +653,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -811,21 +691,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -855,21 +729,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -899,21 +767,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -943,21 +805,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -987,21 +843,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1031,21 +881,15 @@ internal class BenefitsSupportTest { .contains( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction.FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1081,22 +925,15 @@ internal class BenefitsSupportTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1125,22 +962,15 @@ internal class BenefitsSupportTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1169,22 +999,15 @@ internal class BenefitsSupportTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1213,22 +1036,15 @@ internal class BenefitsSupportTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1257,22 +1073,15 @@ internal class BenefitsSupportTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1301,22 +1110,15 @@ internal class BenefitsSupportTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1345,22 +1147,15 @@ internal class BenefitsSupportTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1389,22 +1184,15 @@ internal class BenefitsSupportTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1433,22 +1221,15 @@ internal class BenefitsSupportTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1477,22 +1258,15 @@ internal class BenefitsSupportTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1521,22 +1295,15 @@ internal class BenefitsSupportTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1565,22 +1332,15 @@ internal class BenefitsSupportTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) - .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature.CompanyContribution - .FIXED - ) + .addCompanyContribution(SupportedBenefit.CompanyContribution.FIXED) .description("description") - .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature.EmployeeDeduction - .FIXED - ) + .addEmployeeDeduction(SupportedBenefit.EmployeeDeduction.FIXED) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature.HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderTest.kt index c8c8d6be..b0966799 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/ProviderTest.kt @@ -22,25 +22,19 @@ internal class ProviderTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -69,25 +63,19 @@ internal class ProviderTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -116,25 +104,19 @@ internal class ProviderTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -163,25 +145,19 @@ internal class ProviderTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -210,25 +186,19 @@ internal class ProviderTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -257,25 +227,19 @@ internal class ProviderTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -304,25 +268,19 @@ internal class ProviderTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -351,25 +309,19 @@ internal class ProviderTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -398,25 +350,19 @@ internal class ProviderTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -445,25 +391,19 @@ internal class ProviderTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -492,25 +432,19 @@ internal class ProviderTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -539,25 +473,19 @@ internal class ProviderTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -936,25 +864,19 @@ internal class ProviderTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -983,25 +905,19 @@ internal class ProviderTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1030,25 +946,19 @@ internal class ProviderTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1077,25 +987,19 @@ internal class ProviderTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1124,25 +1028,19 @@ internal class ProviderTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1171,25 +1069,19 @@ internal class ProviderTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1218,25 +1110,19 @@ internal class ProviderTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1265,25 +1151,19 @@ internal class ProviderTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1312,25 +1192,19 @@ internal class ProviderTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1359,25 +1233,19 @@ internal class ProviderTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1406,25 +1274,19 @@ internal class ProviderTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1453,25 +1315,19 @@ internal class ProviderTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1852,25 +1708,19 @@ internal class ProviderTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1899,25 +1749,19 @@ internal class ProviderTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1946,25 +1790,19 @@ internal class ProviderTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -1993,25 +1831,19 @@ internal class ProviderTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2040,25 +1872,19 @@ internal class ProviderTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2087,25 +1913,19 @@ internal class ProviderTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2134,25 +1954,19 @@ internal class ProviderTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2181,25 +1995,19 @@ internal class ProviderTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2228,25 +2036,19 @@ internal class ProviderTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2275,25 +2077,19 @@ internal class ProviderTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2322,25 +2118,19 @@ internal class ProviderTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) @@ -2369,25 +2159,19 @@ internal class ProviderTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature.builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations.BenefitFeature - .CompanyContribution - .FIXED + SupportedBenefit.CompanyContribution.FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations.BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations.BenefitFeature - .HsaContributionLimit - .INDIVIDUAL + SupportedBenefit.HsaContributionLimit.INDIVIDUAL ) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/WebhookEventTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/WebhookEventTest.kt index 31778dac..b136c72b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/WebhookEventTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/WebhookEventTest.kt @@ -30,28 +30,20 @@ internal class WebhookEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -81,28 +73,20 @@ internal class WebhookEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -132,28 +116,20 @@ internal class WebhookEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -183,28 +159,20 @@ internal class WebhookEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -234,28 +202,20 @@ internal class WebhookEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -285,28 +245,20 @@ internal class WebhookEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -336,28 +288,20 @@ internal class WebhookEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -387,28 +331,20 @@ internal class WebhookEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -438,28 +374,20 @@ internal class WebhookEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -489,28 +417,20 @@ internal class WebhookEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -540,28 +460,20 @@ internal class WebhookEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -591,28 +503,20 @@ internal class WebhookEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction - .FIXED + SupportedBenefit.EmployeeDeduction.FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature - .HsaContributionLimit + SupportedBenefit.HsaContributionLimit .INDIVIDUAL ) .build() @@ -1046,27 +950,21 @@ internal class WebhookEventTest { .commuter( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1113,27 +1011,21 @@ internal class WebhookEventTest { .customPostTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1180,27 +1072,21 @@ internal class WebhookEventTest { .customPreTax( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1247,27 +1133,21 @@ internal class WebhookEventTest { .fsaDependentCare( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1314,27 +1194,21 @@ internal class WebhookEventTest { .fsaMedical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1381,27 +1255,21 @@ internal class WebhookEventTest { .hsaPost( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1448,27 +1316,21 @@ internal class WebhookEventTest { .hsaPre( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1515,27 +1377,21 @@ internal class WebhookEventTest { .s125Dental( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1582,27 +1438,21 @@ internal class WebhookEventTest { .s125Medical( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1649,27 +1499,21 @@ internal class WebhookEventTest { .s125Vision( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1716,27 +1560,21 @@ internal class WebhookEventTest { .simple( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) @@ -1783,27 +1621,21 @@ internal class WebhookEventTest { .simpleIra( BenefitFeaturesAndOperations.builder() .supportedFeatures( - BenefitFeaturesAndOperations.BenefitFeature - .builder() + SupportedBenefit.builder() .annualMaximum(true) .catchUp(true) .addCompanyContribution( - BenefitFeaturesAndOperations - .BenefitFeature - .CompanyContribution + SupportedBenefit.CompanyContribution .FIXED ) .description("description") .addEmployeeDeduction( - BenefitFeaturesAndOperations - .BenefitFeature - .EmployeeDeduction + SupportedBenefit.EmployeeDeduction .FIXED ) .addFrequency(BenefitFrequency.ONE_TIME) .addHsaContributionLimit( - BenefitFeaturesAndOperations - .BenefitFeature + SupportedBenefit .HsaContributionLimit .INDIVIDUAL ) From 66732fccc392a5366b5316f306bec6563d7fa19d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 4 Jun 2025 15:46:01 +0000 Subject: [PATCH 13/26] codegen metadata --- .stats.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.stats.yml b/.stats.yml index 774f2cc2..cfc3ec89 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-1a82d3230c420c8562600b0ad45133d79ab68ffd21d524ab26eef11e163dba09.yml openapi_spec_hash: 7bd02ce73505e51c5fd78608fed55c62 -config_hash: 9c795d6cb8440ac8e7e760997a486fc4 +config_hash: 5146b12344dae76238940989dac1e8a0 From ec234c1c781c1453c7cea59e897420e0b820a15b Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 10 Jun 2025 14:41:55 +0000 Subject: [PATCH 14/26] chore(internal): codegen related update --- release-please-config.json | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/release-please-config.json b/release-please-config.json index 9d3ea4fe..eb758e23 100644 --- a/release-please-config.json +++ b/release-please-config.json @@ -73,8 +73,5 @@ "minupalaniappan" ], "release-type": "simple", - "extra-files": [ - "README.md", - "build.gradle.kts" - ] + "extra-files": ["README.md", "build.gradle.kts"] } From 85f964f88bf80872817b2eff4e8a1017a9fabb4e Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 13:52:53 +0000 Subject: [PATCH 15/26] feat(api): api update --- .stats.yml | 4 ++-- .../kotlin/com/tryfinch/api/models/Income.kt | 23 ++++++++++--------- .../api/models/EmploymentDataResponseTest.kt | 13 ++++++----- .../tryfinch/api/models/EmploymentDataTest.kt | 9 ++++---- .../models/EmploymentUpdateResponseTest.kt | 13 ++++++----- ...sEmploymentRetrieveManyPageResponseTest.kt | 13 ++++++----- .../com/tryfinch/api/models/IncomeTest.kt | 7 +++--- .../SandboxDirectoryCreateParamsTest.kt | 13 ++++++----- .../SandboxEmploymentUpdateParamsTest.kt | 13 ++++++----- .../sandbox/DirectoryServiceAsyncTest.kt | 5 ++-- .../sandbox/EmploymentServiceAsyncTest.kt | 5 ++-- .../blocking/sandbox/DirectoryServiceTest.kt | 5 ++-- .../blocking/sandbox/EmploymentServiceTest.kt | 5 ++-- 13 files changed, 70 insertions(+), 58 deletions(-) diff --git a/.stats.yml b/.stats.yml index cfc3ec89..1afcb826 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-1a82d3230c420c8562600b0ad45133d79ab68ffd21d524ab26eef11e163dba09.yml -openapi_spec_hash: 7bd02ce73505e51c5fd78608fed55c62 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-dd2cdf274497a0f36aaa493457a1144f51f6c28e14b4521acca9715747688b50.yml +openapi_spec_hash: 8bbc0ac9dae255055b69c1d040c43c4b config_hash: 5146b12344dae76238940989dac1e8a0 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Income.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Income.kt index 99e6b081..9a9fc1d3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Income.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Income.kt @@ -13,6 +13,7 @@ import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.checkRequired import com.tryfinch.api.errors.FinchInvalidDataException +import java.time.LocalDate import java.util.Collections import java.util.Objects import java.util.Optional @@ -27,7 +28,7 @@ class Income private constructor( private val amount: JsonField, private val currency: JsonField, - private val effectiveDate: JsonField, + private val effectiveDate: JsonField, private val unit: JsonField, private val additionalProperties: MutableMap, ) { @@ -38,7 +39,7 @@ private constructor( @JsonProperty("currency") @ExcludeMissing currency: JsonField = JsonMissing.of(), @JsonProperty("effective_date") @ExcludeMissing - effectiveDate: JsonField = JsonMissing.of(), + effectiveDate: JsonField = JsonMissing.of(), @JsonProperty("unit") @ExcludeMissing unit: JsonField = JsonMissing.of(), ) : this(amount, currency, effectiveDate, unit, mutableMapOf()) @@ -64,7 +65,7 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun effectiveDate(): Optional = effectiveDate.getOptional("effective_date") + fun effectiveDate(): Optional = effectiveDate.getOptional("effective_date") /** * The income unit of payment. Options: `yearly`, `quarterly`, `monthly`, `semi_monthly`, @@ -96,7 +97,7 @@ private constructor( */ @JsonProperty("effective_date") @ExcludeMissing - fun _effectiveDate(): JsonField = effectiveDate + fun _effectiveDate(): JsonField = effectiveDate /** * Returns the raw JSON value of [unit]. @@ -138,7 +139,7 @@ private constructor( private var amount: JsonField? = null private var currency: JsonField? = null - private var effectiveDate: JsonField? = null + private var effectiveDate: JsonField? = null private var unit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -187,21 +188,21 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } /** The date the income amount went into effect. */ - fun effectiveDate(effectiveDate: String?) = + fun effectiveDate(effectiveDate: LocalDate?) = effectiveDate(JsonField.ofNullable(effectiveDate)) /** Alias for calling [Builder.effectiveDate] with `effectiveDate.orElse(null)`. */ - fun effectiveDate(effectiveDate: Optional) = + fun effectiveDate(effectiveDate: Optional) = effectiveDate(effectiveDate.getOrNull()) /** * Sets [Builder.effectiveDate] to an arbitrary JSON value. * - * You should usually call [Builder.effectiveDate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet supported - * value. + * You should usually call [Builder.effectiveDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. */ - fun effectiveDate(effectiveDate: JsonField) = apply { + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt index 78156f0f..1fe2d86c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataResponseTest.kt @@ -4,6 +4,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -62,7 +63,7 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -70,7 +71,7 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -133,7 +134,7 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -141,7 +142,7 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -209,7 +210,7 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -217,7 +218,7 @@ internal class EmploymentDataResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt index ea01aa1c..ea4f1a63 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentDataTest.kt @@ -6,6 +6,7 @@ import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper import com.tryfinch.api.errors.FinchInvalidDataException +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows @@ -63,7 +64,7 @@ internal class EmploymentDataTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -71,7 +72,7 @@ internal class EmploymentDataTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -138,7 +139,7 @@ internal class EmploymentDataTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -146,7 +147,7 @@ internal class EmploymentDataTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt index 2b9c3056..e280855b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/EmploymentUpdateResponseTest.kt @@ -5,6 +5,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.jsonMapper +import java.time.LocalDate import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -37,7 +38,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -45,7 +46,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -102,7 +103,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -111,7 +112,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -170,7 +171,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -178,7 +179,7 @@ internal class EmploymentUpdateResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt index 81c94a15..837c94a4 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyPageResponseTest.kt @@ -4,6 +4,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -70,7 +71,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -78,7 +79,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -148,7 +149,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -156,7 +157,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -232,7 +233,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -240,7 +241,7 @@ internal class HrisEmploymentRetrieveManyPageResponseTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IncomeTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IncomeTest.kt index f50c94ec..9fbc186d 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IncomeTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/IncomeTest.kt @@ -4,6 +4,7 @@ package com.tryfinch.api.models import com.fasterxml.jackson.module.kotlin.jacksonTypeRef import com.tryfinch.api.core.jsonMapper +import java.time.LocalDate import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -15,13 +16,13 @@ internal class IncomeTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() assertThat(income.amount()).contains(0L) assertThat(income.currency()).contains("currency") - assertThat(income.effectiveDate()).contains("effective_date") + assertThat(income.effectiveDate()).contains(LocalDate.parse("2019-12-27")) assertThat(income.unit()).contains(Income.Unit.YEARLY) } @@ -32,7 +33,7 @@ internal class IncomeTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt index 2cabe240..17320a99 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParamsTest.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.models import com.tryfinch.api.core.JsonValue +import java.time.LocalDate import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -60,7 +61,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -68,7 +69,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -182,7 +183,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -190,7 +191,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -298,7 +299,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -306,7 +307,7 @@ internal class SandboxDirectoryCreateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt index 5a5f9fab..5d37a553 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParamsTest.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.models import com.tryfinch.api.core.JsonValue +import java.time.LocalDate import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -34,7 +35,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -42,7 +43,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -108,7 +109,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -116,7 +117,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -174,7 +175,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -183,7 +184,7 @@ internal class SandboxEmploymentUpdateParamsTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt index ce338d43..56484790 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.Income import com.tryfinch.api.models.Location import com.tryfinch.api.models.SandboxDirectoryCreateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -87,7 +88,7 @@ internal class DirectoryServiceAsyncTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -95,7 +96,7 @@ internal class DirectoryServiceAsyncTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt index 8db4951b..6fa1664b 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncTest.kt @@ -8,6 +8,7 @@ import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.Income import com.tryfinch.api.models.Location import com.tryfinch.api.models.SandboxEmploymentUpdateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -50,7 +51,7 @@ internal class EmploymentServiceAsyncTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -58,7 +59,7 @@ internal class EmploymentServiceAsyncTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt index 2e1068ba..b14c55a9 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceTest.kt @@ -8,6 +8,7 @@ import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.Income import com.tryfinch.api.models.Location import com.tryfinch.api.models.SandboxDirectoryCreateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -87,7 +88,7 @@ internal class DirectoryServiceTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -95,7 +96,7 @@ internal class DirectoryServiceTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt index c372d897..235b740c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceTest.kt @@ -8,6 +8,7 @@ import com.tryfinch.api.core.JsonValue import com.tryfinch.api.models.Income import com.tryfinch.api.models.Location import com.tryfinch.api.models.SandboxEmploymentUpdateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -50,7 +51,7 @@ internal class EmploymentServiceTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) @@ -58,7 +59,7 @@ internal class EmploymentServiceTest { Income.builder() .amount(0L) .currency("currency") - .effectiveDate("effective_date") + .effectiveDate(LocalDate.parse("2019-12-27")) .unit(Income.Unit.YEARLY) .build() ) From ba2711a7466433c91cafd023ab09a29dda400322 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 14:58:51 +0000 Subject: [PATCH 16/26] feat(api): api update --- .stats.yml | 4 +- .../api/models/SandboxPaymentCreateParams.kt | 2654 ++++++++++++++++- .../models/SandboxPaymentCreateParamsTest.kt | 373 +-- .../async/sandbox/PaymentServiceAsyncTest.kt | 137 +- .../blocking/sandbox/PaymentServiceTest.kt | 137 +- 5 files changed, 2753 insertions(+), 552 deletions(-) diff --git a/.stats.yml b/.stats.yml index 1afcb826..1889fe28 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 45 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-dd2cdf274497a0f36aaa493457a1144f51f6c28e14b4521acca9715747688b50.yml -openapi_spec_hash: 8bbc0ac9dae255055b69c1d040c43c4b +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/finch%2Ffinch-f7e741bc6e0175fd96a9db5348092b90a77b0985154c0814bb681ad5dccdf19a.yml +openapi_spec_hash: b348a9ef407a8e91dd770fcb219d4ac5 config_hash: 5146b12344dae76238940989dac1e8a0 diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt index 0c4073f4..4de48809 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParams.kt @@ -6,16 +6,19 @@ import com.fasterxml.jackson.annotation.JsonAnyGetter import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.Enum import com.tryfinch.api.core.ExcludeMissing import com.tryfinch.api.core.JsonField import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.Params import com.tryfinch.api.core.checkKnown +import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.QueryParams import com.tryfinch.api.core.toImmutable import com.tryfinch.api.errors.FinchInvalidDataException +import java.time.LocalDate import java.util.Collections import java.util.Objects import java.util.Optional @@ -24,7 +27,7 @@ import kotlin.jvm.optionals.getOrNull /** Add a new sandbox payment */ class SandboxPaymentCreateParams private constructor( - private val body: Body, + private val body: CreateSandboxPaymentRequest, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, ) : Params { @@ -33,9 +36,11 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun endDate(): Optional = body.endDate() + fun endDate(): Optional = body.endDate() /** + * Array of pay statements to include in the payment. + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -45,14 +50,14 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startDate(): Optional = body.startDate() + fun startDate(): Optional = body.startDate() /** * Returns the raw JSON value of [endDate]. * * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. */ - fun _endDate(): JsonField = body._endDate() + fun _endDate(): JsonField = body._endDate() /** * Returns the raw JSON value of [payStatements]. @@ -66,7 +71,7 @@ private constructor( * * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. */ - fun _startDate(): JsonField = body._startDate() + fun _startDate(): JsonField = body._startDate() fun _additionalBodyProperties(): Map = body._additionalProperties() @@ -89,7 +94,8 @@ private constructor( /** A builder for [SandboxPaymentCreateParams]. */ class Builder internal constructor() { - private var body: Body.Builder = Body.builder() + private var body: CreateSandboxPaymentRequest.Builder = + CreateSandboxPaymentRequest.builder() private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() @@ -109,18 +115,20 @@ private constructor( * - [payStatements] * - [startDate] */ - fun body(body: Body) = apply { this.body = body.toBuilder() } + fun body(body: CreateSandboxPaymentRequest) = apply { this.body = body.toBuilder() } - fun endDate(endDate: String) = apply { body.endDate(endDate) } + fun endDate(endDate: LocalDate) = apply { body.endDate(endDate) } /** * Sets [Builder.endDate] to an arbitrary JSON value. * - * You should usually call [Builder.endDate] with a well-typed [String] value instead. This - * method is primarily for setting the field to an undocumented or not yet supported value. + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. */ - fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + /** Array of pay statements to include in the payment. */ fun payStatements(payStatements: List) = apply { body.payStatements(payStatements) } @@ -145,16 +153,16 @@ private constructor( body.addPayStatement(payStatement) } - fun startDate(startDate: String) = apply { body.startDate(startDate) } + fun startDate(startDate: LocalDate) = apply { body.startDate(startDate) } /** * Sets [Builder.startDate] to an arbitrary JSON value. * - * You should usually call [Builder.startDate] with a well-typed [String] value instead. + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value instead. * This method is primarily for setting the field to an undocumented or not yet supported * value. */ - fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } fun additionalBodyProperties(additionalBodyProperties: Map) = apply { body.additionalProperties(additionalBodyProperties) @@ -286,7 +294,7 @@ private constructor( ) } - fun _body(): Body = body + fun _body(): CreateSandboxPaymentRequest = body override fun _headers(): Headers = additionalHeaders @@ -296,32 +304,36 @@ private constructor( * Fields to configure the payment. Takes all fields from the `/payment` endpoint. All fields * are optional. */ - class Body + class CreateSandboxPaymentRequest private constructor( - private val endDate: JsonField, + private val endDate: JsonField, private val payStatements: JsonField>, - private val startDate: JsonField, + private val startDate: JsonField, private val additionalProperties: MutableMap, ) { @JsonCreator private constructor( - @JsonProperty("end_date") @ExcludeMissing endDate: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + endDate: JsonField = JsonMissing.of(), @JsonProperty("pay_statements") @ExcludeMissing payStatements: JsonField> = JsonMissing.of(), @JsonProperty("start_date") @ExcludeMissing - startDate: JsonField = JsonMissing.of(), + startDate: JsonField = JsonMissing.of(), ) : this(endDate, payStatements, startDate, mutableMapOf()) /** * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun endDate(): Optional = endDate.getOptional("end_date") + fun endDate(): Optional = endDate.getOptional("end_date") /** + * Array of pay statements to include in the payment. + * * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ @@ -332,14 +344,14 @@ private constructor( * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the * server responded with an unexpected value). */ - fun startDate(): Optional = startDate.getOptional("start_date") + fun startDate(): Optional = startDate.getOptional("start_date") /** * Returns the raw JSON value of [endDate]. * * Unlike [endDate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** * Returns the raw JSON value of [payStatements]. @@ -356,7 +368,9 @@ private constructor( * * Unlike [startDate], this method doesn't throw if the JSON field has an unexpected type. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnySetter private fun putAdditionalProperty(key: String, value: JsonValue) { @@ -372,37 +386,42 @@ private constructor( companion object { - /** Returns a mutable builder for constructing an instance of [Body]. */ + /** + * Returns a mutable builder for constructing an instance of + * [CreateSandboxPaymentRequest]. + */ @JvmStatic fun builder() = Builder() } - /** A builder for [Body]. */ + /** A builder for [CreateSandboxPaymentRequest]. */ class Builder internal constructor() { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() private var payStatements: JsonField>? = null - private var startDate: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic - internal fun from(body: Body) = apply { - endDate = body.endDate - payStatements = body.payStatements.map { it.toMutableList() } - startDate = body.startDate - additionalProperties = body.additionalProperties.toMutableMap() + internal fun from(createSandboxPaymentRequest: CreateSandboxPaymentRequest) = apply { + endDate = createSandboxPaymentRequest.endDate + payStatements = createSandboxPaymentRequest.payStatements.map { it.toMutableList() } + startDate = createSandboxPaymentRequest.startDate + additionalProperties = + createSandboxPaymentRequest.additionalProperties.toMutableMap() } - fun endDate(endDate: String) = endDate(JsonField.of(endDate)) + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) /** * Sets [Builder.endDate] to an arbitrary JSON value. * - * You should usually call [Builder.endDate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.endDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** Array of pay statements to include in the payment. */ fun payStatements(payStatements: List) = payStatements(JsonField.of(payStatements)) @@ -429,16 +448,16 @@ private constructor( } } - fun startDate(startDate: String) = startDate(JsonField.of(startDate)) + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) /** * Sets [Builder.startDate] to an arbitrary JSON value. * - * You should usually call [Builder.startDate] with a well-typed [String] value instead. - * This method is primarily for setting the field to an undocumented or not yet + * You should usually call [Builder.startDate] with a well-typed [LocalDate] value + * instead. This method is primarily for setting the field to an undocumented or not yet * supported value. */ - fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -460,12 +479,12 @@ private constructor( } /** - * Returns an immutable instance of [Body]. + * Returns an immutable instance of [CreateSandboxPaymentRequest]. * * Further updates to this [Builder] will not mutate the returned instance. */ - fun build(): Body = - Body( + fun build(): CreateSandboxPaymentRequest = + CreateSandboxPaymentRequest( endDate, (payStatements ?: JsonMissing.of()).map { it.toImmutable() }, startDate, @@ -475,7 +494,7 @@ private constructor( private var validated: Boolean = false - fun validate(): Body = apply { + fun validate(): CreateSandboxPaymentRequest = apply { if (validated) { return@apply } @@ -511,7 +530,7 @@ private constructor( return true } - return /* spotless:off */ other is Body && endDate == other.endDate && payStatements == other.payStatements && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ + return /* spotless:off */ other is CreateSandboxPaymentRequest && endDate == other.endDate && payStatements == other.payStatements && startDate == other.startDate && additionalProperties == other.additionalProperties /* spotless:on */ } /* spotless:off */ @@ -521,7 +540,2548 @@ private constructor( override fun hashCode(): Int = hashCode override fun toString() = - "Body{endDate=$endDate, payStatements=$payStatements, startDate=$startDate, additionalProperties=$additionalProperties}" + "CreateSandboxPaymentRequest{endDate=$endDate, payStatements=$payStatements, startDate=$startDate, additionalProperties=$additionalProperties}" + } + + class PayStatement + private constructor( + private val individualId: JsonField, + private val earnings: JsonField>, + private val employeeDeductions: JsonField>, + private val employerContributions: JsonField>, + private val grossPay: JsonField, + private val netPay: JsonField, + private val paymentMethod: JsonField, + private val taxes: JsonField>, + private val totalHours: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("individual_id") + @ExcludeMissing + individualId: JsonField = JsonMissing.of(), + @JsonProperty("earnings") + @ExcludeMissing + earnings: JsonField> = JsonMissing.of(), + @JsonProperty("employee_deductions") + @ExcludeMissing + employeeDeductions: JsonField> = JsonMissing.of(), + @JsonProperty("employer_contributions") + @ExcludeMissing + employerContributions: JsonField> = JsonMissing.of(), + @JsonProperty("gross_pay") @ExcludeMissing grossPay: JsonField = JsonMissing.of(), + @JsonProperty("net_pay") @ExcludeMissing netPay: JsonField = JsonMissing.of(), + @JsonProperty("payment_method") + @ExcludeMissing + paymentMethod: JsonField = JsonMissing.of(), + @JsonProperty("taxes") @ExcludeMissing taxes: JsonField> = JsonMissing.of(), + @JsonProperty("total_hours") + @ExcludeMissing + totalHours: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this( + individualId, + earnings, + employeeDeductions, + employerContributions, + grossPay, + netPay, + paymentMethod, + taxes, + totalHours, + type, + 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 individualId(): String = individualId.getRequired("individual_id") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun earnings(): Optional> = earnings.getOptional("earnings") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun employeeDeductions(): Optional> = + employeeDeductions.getOptional("employee_deductions") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun employerContributions(): Optional> = + employerContributions.getOptional("employer_contributions") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun grossPay(): Optional = grossPay.getOptional("gross_pay") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun netPay(): Optional = netPay.getOptional("net_pay") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun paymentMethod(): Optional = paymentMethod.getOptional("payment_method") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun taxes(): Optional> = taxes.getOptional("taxes") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun totalHours(): Optional = totalHours.getOptional("total_hours") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [individualId]. + * + * Unlike [individualId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId + + /** + * Returns the raw JSON value of [earnings]. + * + * Unlike [earnings], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("earnings") + @ExcludeMissing + fun _earnings(): JsonField> = earnings + + /** + * Returns the raw JSON value of [employeeDeductions]. + * + * Unlike [employeeDeductions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("employee_deductions") + @ExcludeMissing + fun _employeeDeductions(): JsonField> = employeeDeductions + + /** + * Returns the raw JSON value of [employerContributions]. + * + * Unlike [employerContributions], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("employer_contributions") + @ExcludeMissing + fun _employerContributions(): JsonField> = employerContributions + + /** + * Returns the raw JSON value of [grossPay]. + * + * Unlike [grossPay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay + + /** + * Returns the raw JSON value of [netPay]. + * + * Unlike [netPay], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay + + /** + * Returns the raw JSON value of [paymentMethod]. + * + * Unlike [paymentMethod], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("payment_method") + @ExcludeMissing + fun _paymentMethod(): JsonField = paymentMethod + + /** + * Returns the raw JSON value of [taxes]. + * + * Unlike [taxes], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes + + /** + * Returns the raw JSON value of [totalHours]. + * + * Unlike [totalHours], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("total_hours") + @ExcludeMissing + fun _totalHours(): JsonField = totalHours + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [PayStatement]. + * + * The following fields are required: + * ```java + * .individualId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [PayStatement]. */ + class Builder internal constructor() { + + private var individualId: JsonField? = null + private var earnings: JsonField>? = null + private var employeeDeductions: JsonField>? = null + private var employerContributions: JsonField>? = null + private var grossPay: JsonField = JsonMissing.of() + private var netPay: JsonField = JsonMissing.of() + private var paymentMethod: JsonField = JsonMissing.of() + private var taxes: JsonField>? = null + private var totalHours: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(payStatement: PayStatement) = apply { + individualId = payStatement.individualId + earnings = payStatement.earnings.map { it.toMutableList() } + employeeDeductions = payStatement.employeeDeductions.map { it.toMutableList() } + employerContributions = + payStatement.employerContributions.map { it.toMutableList() } + grossPay = payStatement.grossPay + netPay = payStatement.netPay + paymentMethod = payStatement.paymentMethod + taxes = payStatement.taxes.map { it.toMutableList() } + totalHours = payStatement.totalHours + type = payStatement.type + additionalProperties = payStatement.additionalProperties.toMutableMap() + } + + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** + * Sets [Builder.individualId] to an arbitrary JSON value. + * + * You should usually call [Builder.individualId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } + + fun earnings(earnings: List) = earnings(JsonField.of(earnings)) + + /** + * Sets [Builder.earnings] to an arbitrary JSON value. + * + * You should usually call [Builder.earnings] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun earnings(earnings: JsonField>) = apply { + this.earnings = earnings.map { it.toMutableList() } + } + + /** + * Adds a single [Earning] to [earnings]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEarning(earning: Earning) = apply { + earnings = + (earnings ?: JsonField.of(mutableListOf())).also { + checkKnown("earnings", it).add(earning) + } + } + + fun employeeDeductions(employeeDeductions: List) = + employeeDeductions(JsonField.of(employeeDeductions)) + + /** + * Sets [Builder.employeeDeductions] to an arbitrary JSON value. + * + * You should usually call [Builder.employeeDeductions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun employeeDeductions(employeeDeductions: JsonField>) = apply { + this.employeeDeductions = employeeDeductions.map { it.toMutableList() } + } + + /** + * Adds a single [EmployeeDeduction] to [employeeDeductions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { + employeeDeductions = + (employeeDeductions ?: JsonField.of(mutableListOf())).also { + checkKnown("employeeDeductions", it).add(employeeDeduction) + } + } + + fun employerContributions(employerContributions: List) = + employerContributions(JsonField.of(employerContributions)) + + /** + * Sets [Builder.employerContributions] to an arbitrary JSON value. + * + * You should usually call [Builder.employerContributions] with a well-typed + * `List` value instead. This method is primarily for setting the + * field to an undocumented or not yet supported value. + */ + fun employerContributions( + employerContributions: JsonField> + ) = apply { + this.employerContributions = employerContributions.map { it.toMutableList() } + } + + /** + * Adds a single [EmployerContribution] to [employerContributions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addEmployerContribution(employerContribution: EmployerContribution) = apply { + employerContributions = + (employerContributions ?: JsonField.of(mutableListOf())).also { + checkKnown("employerContributions", it).add(employerContribution) + } + } + + fun grossPay(grossPay: Long) = grossPay(JsonField.of(grossPay)) + + /** + * Sets [Builder.grossPay] to an arbitrary JSON value. + * + * You should usually call [Builder.grossPay] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } + + fun netPay(netPay: Long) = netPay(JsonField.of(netPay)) + + /** + * Sets [Builder.netPay] to an arbitrary JSON value. + * + * You should usually call [Builder.netPay] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun netPay(netPay: JsonField) = apply { this.netPay = netPay } + + fun paymentMethod(paymentMethod: PaymentMethod?) = + paymentMethod(JsonField.ofNullable(paymentMethod)) + + /** Alias for calling [Builder.paymentMethod] with `paymentMethod.orElse(null)`. */ + fun paymentMethod(paymentMethod: Optional) = + paymentMethod(paymentMethod.getOrNull()) + + /** + * Sets [Builder.paymentMethod] to an arbitrary JSON value. + * + * You should usually call [Builder.paymentMethod] with a well-typed [PaymentMethod] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun paymentMethod(paymentMethod: JsonField) = apply { + this.paymentMethod = paymentMethod + } + + fun taxes(taxes: List) = taxes(JsonField.of(taxes)) + + /** + * Sets [Builder.taxes] to an arbitrary JSON value. + * + * You should usually call [Builder.taxes] with a well-typed `List` value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun taxes(taxes: JsonField>) = apply { + this.taxes = taxes.map { it.toMutableList() } + } + + /** + * Adds a single [Tax] to [taxes]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addTax(tax: Tax) = apply { + taxes = + (taxes ?: JsonField.of(mutableListOf())).also { + checkKnown("taxes", it).add(tax) + } + } + + fun totalHours(totalHours: Double) = totalHours(JsonField.of(totalHours)) + + /** + * Sets [Builder.totalHours] to an arbitrary JSON value. + * + * You should usually call [Builder.totalHours] with a well-typed [Double] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun totalHours(totalHours: JsonField) = apply { this.totalHours = totalHours } + + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Alias for calling [Builder.type] with `type.orElse(null)`. */ + fun type(type: Optional) = type(type.getOrNull()) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [PayStatement]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .individualId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): PayStatement = + PayStatement( + checkRequired("individualId", individualId), + (earnings ?: JsonMissing.of()).map { it.toImmutable() }, + (employeeDeductions ?: JsonMissing.of()).map { it.toImmutable() }, + (employerContributions ?: JsonMissing.of()).map { it.toImmutable() }, + grossPay, + netPay, + paymentMethod, + (taxes ?: JsonMissing.of()).map { it.toImmutable() }, + totalHours, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): PayStatement = apply { + if (validated) { + return@apply + } + + individualId() + earnings().ifPresent { it.forEach { it.validate() } } + employeeDeductions().ifPresent { it.forEach { it.validate() } } + employerContributions().ifPresent { it.forEach { it.validate() } } + grossPay() + netPay() + paymentMethod().ifPresent { it.validate() } + taxes().ifPresent { it.forEach { it.validate() } } + totalHours() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (individualId.asKnown().isPresent) 1 else 0) + + (earnings.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (employeeDeductions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (employerContributions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } + ?: 0) + + (if (grossPay.asKnown().isPresent) 1 else 0) + + (if (netPay.asKnown().isPresent) 1 else 0) + + (paymentMethod.asKnown().getOrNull()?.validity() ?: 0) + + (taxes.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (totalHours.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Earning + private constructor( + private val amount: JsonField, + private val hours: JsonField, + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("hours") @ExcludeMissing hours: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(amount, hours, name, type, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun hours(): Optional = hours.getOptional("hours") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [hours]. + * + * Unlike [hours], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField = hours + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Earning]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Earning]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var hours: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(earning: Earning) = apply { + amount = earning.amount + hours = earning.hours + name = earning.name + type = earning.type + additionalProperties = earning.additionalProperties.toMutableMap() + } + + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun hours(hours: Double) = hours(JsonField.of(hours)) + + /** + * Sets [Builder.hours] to an arbitrary JSON value. + * + * You should usually call [Builder.hours] with a well-typed [Double] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun hours(hours: JsonField) = apply { this.hours = hours } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Earning]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Earning = + Earning(amount, hours, name, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Earning = apply { + if (validated) { + return@apply + } + + amount() + hours() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (hours.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val BONUS = of("bonus") + + @JvmField val COMMISSION = of("commission") + + @JvmField val DOUBLE_OVERTIME = of("double_overtime") + + @JvmField val OTHER = of("other") + + @JvmField val OVERTIME = of("overtime") + + @JvmField val PTO = of("pto") + + @JvmField val REIMBURSEMENT = of("reimbursement") + + @JvmField val SALARY = of("salary") + + @JvmField val SEVERANCE = of("severance") + + @JvmField val SICK = of("sick") + + @JvmField val TIPS = of("tips") + + @JvmField val WAGE = of("wage") + + @JvmField val _1099 = of("1099") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + BONUS, + COMMISSION, + DOUBLE_OVERTIME, + OTHER, + OVERTIME, + PTO, + REIMBURSEMENT, + SALARY, + SEVERANCE, + SICK, + TIPS, + WAGE, + _1099, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + BONUS, + COMMISSION, + DOUBLE_OVERTIME, + OTHER, + OVERTIME, + PTO, + REIMBURSEMENT, + SALARY, + SEVERANCE, + SICK, + TIPS, + WAGE, + _1099, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + BONUS -> Value.BONUS + COMMISSION -> Value.COMMISSION + DOUBLE_OVERTIME -> Value.DOUBLE_OVERTIME + OTHER -> Value.OTHER + OVERTIME -> Value.OVERTIME + PTO -> Value.PTO + REIMBURSEMENT -> Value.REIMBURSEMENT + SALARY -> Value.SALARY + SEVERANCE -> Value.SEVERANCE + SICK -> Value.SICK + TIPS -> Value.TIPS + WAGE -> Value.WAGE + _1099 -> Value._1099 + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + BONUS -> Known.BONUS + COMMISSION -> Known.COMMISSION + DOUBLE_OVERTIME -> Known.DOUBLE_OVERTIME + OTHER -> Known.OTHER + OVERTIME -> Known.OVERTIME + PTO -> Known.PTO + REIMBURSEMENT -> Known.REIMBURSEMENT + SALARY -> Known.SALARY + SEVERANCE -> Known.SEVERANCE + SICK -> Known.SICK + TIPS -> Known.TIPS + WAGE -> Known.WAGE + _1099 -> Known._1099 + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Earning && amount == other.amount && hours == other.hours && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, hours, name, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Earning{amount=$amount, hours=$hours, name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + class EmployeeDeduction + private constructor( + private val amount: JsonField, + private val name: JsonField, + private val preTax: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("pre_tax") + @ExcludeMissing + preTax: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(amount, name, preTax, type, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun preTax(): Optional = preTax.getOptional("pre_tax") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [preTax]. + * + * Unlike [preTax], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pre_tax") @ExcludeMissing fun _preTax(): JsonField = preTax + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EmployeeDeduction]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmployeeDeduction]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var preTax: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(employeeDeduction: EmployeeDeduction) = apply { + amount = employeeDeduction.amount + name = employeeDeduction.name + preTax = employeeDeduction.preTax + type = employeeDeduction.type + additionalProperties = employeeDeduction.additionalProperties.toMutableMap() + } + + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun preTax(preTax: Boolean) = preTax(JsonField.of(preTax)) + + /** + * Sets [Builder.preTax] to an arbitrary JSON value. + * + * You should usually call [Builder.preTax] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun preTax(preTax: JsonField) = apply { this.preTax = preTax } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmployeeDeduction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmployeeDeduction = + EmployeeDeduction( + amount, + name, + preTax, + type, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): EmployeeDeduction = apply { + if (validated) { + return@apply + } + + amount() + name() + preTax() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (if (preTax.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _457 = of("457") + + @JvmField val _401K = of("401k") + + @JvmField val _401K_ROTH = of("401k_roth") + + @JvmField val _401K_LOAN = of("401k_loan") + + @JvmField val _403B = of("403b") + + @JvmField val _403B_ROTH = of("403b_roth") + + @JvmField val _457_ROTH = of("457_roth") + + @JvmField val COMMUTER = of("commuter") + + @JvmField val CUSTOM_POST_TAX = of("custom_post_tax") + + @JvmField val CUSTOM_PRE_TAX = of("custom_pre_tax") + + @JvmField val FSA_DEPENDENT_CARE = of("fsa_dependent_care") + + @JvmField val FSA_MEDICAL = of("fsa_medical") + + @JvmField val HSA_POST = of("hsa_post") + + @JvmField val HSA_PRE = of("hsa_pre") + + @JvmField val S125_DENTAL = of("s125_dental") + + @JvmField val S125_MEDICAL = of("s125_medical") + + @JvmField val S125_VISION = of("s125_vision") + + @JvmField val SIMPLE = of("simple") + + @JvmField val SIMPLE_IRA = of("simple_ira") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + _457, + _401K, + _401K_ROTH, + _401K_LOAN, + _403B, + _403B_ROTH, + _457_ROTH, + COMMUTER, + CUSTOM_POST_TAX, + CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _457, + _401K, + _401K_ROTH, + _401K_LOAN, + _403B, + _403B_ROTH, + _457_ROTH, + COMMUTER, + CUSTOM_POST_TAX, + CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _457 -> Value._457 + _401K -> Value._401K + _401K_ROTH -> Value._401K_ROTH + _401K_LOAN -> Value._401K_LOAN + _403B -> Value._403B + _403B_ROTH -> Value._403B_ROTH + _457_ROTH -> Value._457_ROTH + COMMUTER -> Value.COMMUTER + CUSTOM_POST_TAX -> Value.CUSTOM_POST_TAX + CUSTOM_PRE_TAX -> Value.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Value.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Value.FSA_MEDICAL + HSA_POST -> Value.HSA_POST + HSA_PRE -> Value.HSA_PRE + S125_DENTAL -> Value.S125_DENTAL + S125_MEDICAL -> Value.S125_MEDICAL + S125_VISION -> Value.S125_VISION + SIMPLE -> Value.SIMPLE + SIMPLE_IRA -> Value.SIMPLE_IRA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _457 -> Known._457 + _401K -> Known._401K + _401K_ROTH -> Known._401K_ROTH + _401K_LOAN -> Known._401K_LOAN + _403B -> Known._403B + _403B_ROTH -> Known._403B_ROTH + _457_ROTH -> Known._457_ROTH + COMMUTER -> Known.COMMUTER + CUSTOM_POST_TAX -> Known.CUSTOM_POST_TAX + CUSTOM_PRE_TAX -> Known.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Known.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Known.FSA_MEDICAL + HSA_POST -> Known.HSA_POST + HSA_PRE -> Known.HSA_PRE + S125_DENTAL -> Known.S125_DENTAL + S125_MEDICAL -> Known.S125_MEDICAL + S125_VISION -> Known.S125_VISION + SIMPLE -> Known.SIMPLE + SIMPLE_IRA -> Known.SIMPLE_IRA + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EmployeeDeduction && amount == other.amount && name == other.name && preTax == other.preTax && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, name, preTax, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmployeeDeduction{amount=$amount, name=$name, preTax=$preTax, type=$type, additionalProperties=$additionalProperties}" + } + + class EmployerContribution + private constructor( + private val amount: JsonField, + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(amount, name, type, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [EmployerContribution]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [EmployerContribution]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(employerContribution: EmployerContribution) = apply { + amount = employerContribution.amount + name = employerContribution.name + type = employerContribution.type + additionalProperties = employerContribution.additionalProperties.toMutableMap() + } + + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [EmployerContribution]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): EmployerContribution = + EmployerContribution(amount, name, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): EmployerContribution = apply { + if (validated) { + return@apply + } + + amount() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val _457 = of("457") + + @JvmField val _401K = of("401k") + + @JvmField val _401K_ROTH = of("401k_roth") + + @JvmField val _401K_LOAN = of("401k_loan") + + @JvmField val _403B = of("403b") + + @JvmField val _403B_ROTH = of("403b_roth") + + @JvmField val _457_ROTH = of("457_roth") + + @JvmField val COMMUTER = of("commuter") + + @JvmField val CUSTOM_POST_TAX = of("custom_post_tax") + + @JvmField val CUSTOM_PRE_TAX = of("custom_pre_tax") + + @JvmField val FSA_DEPENDENT_CARE = of("fsa_dependent_care") + + @JvmField val FSA_MEDICAL = of("fsa_medical") + + @JvmField val HSA_POST = of("hsa_post") + + @JvmField val HSA_PRE = of("hsa_pre") + + @JvmField val S125_DENTAL = of("s125_dental") + + @JvmField val S125_MEDICAL = of("s125_medical") + + @JvmField val S125_VISION = of("s125_vision") + + @JvmField val SIMPLE = of("simple") + + @JvmField val SIMPLE_IRA = of("simple_ira") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + _457, + _401K, + _401K_ROTH, + _401K_LOAN, + _403B, + _403B_ROTH, + _457_ROTH, + COMMUTER, + CUSTOM_POST_TAX, + CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + _457, + _401K, + _401K_ROTH, + _401K_LOAN, + _403B, + _403B_ROTH, + _457_ROTH, + COMMUTER, + CUSTOM_POST_TAX, + CUSTOM_PRE_TAX, + FSA_DEPENDENT_CARE, + FSA_MEDICAL, + HSA_POST, + HSA_PRE, + S125_DENTAL, + S125_MEDICAL, + S125_VISION, + SIMPLE, + SIMPLE_IRA, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + _457 -> Value._457 + _401K -> Value._401K + _401K_ROTH -> Value._401K_ROTH + _401K_LOAN -> Value._401K_LOAN + _403B -> Value._403B + _403B_ROTH -> Value._403B_ROTH + _457_ROTH -> Value._457_ROTH + COMMUTER -> Value.COMMUTER + CUSTOM_POST_TAX -> Value.CUSTOM_POST_TAX + CUSTOM_PRE_TAX -> Value.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Value.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Value.FSA_MEDICAL + HSA_POST -> Value.HSA_POST + HSA_PRE -> Value.HSA_PRE + S125_DENTAL -> Value.S125_DENTAL + S125_MEDICAL -> Value.S125_MEDICAL + S125_VISION -> Value.S125_VISION + SIMPLE -> Value.SIMPLE + SIMPLE_IRA -> Value.SIMPLE_IRA + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + _457 -> Known._457 + _401K -> Known._401K + _401K_ROTH -> Known._401K_ROTH + _401K_LOAN -> Known._401K_LOAN + _403B -> Known._403B + _403B_ROTH -> Known._403B_ROTH + _457_ROTH -> Known._457_ROTH + COMMUTER -> Known.COMMUTER + CUSTOM_POST_TAX -> Known.CUSTOM_POST_TAX + CUSTOM_PRE_TAX -> Known.CUSTOM_PRE_TAX + FSA_DEPENDENT_CARE -> Known.FSA_DEPENDENT_CARE + FSA_MEDICAL -> Known.FSA_MEDICAL + HSA_POST -> Known.HSA_POST + HSA_PRE -> Known.HSA_PRE + S125_DENTAL -> Known.S125_DENTAL + S125_MEDICAL -> Known.S125_MEDICAL + S125_VISION -> Known.S125_VISION + SIMPLE -> Known.SIMPLE + SIMPLE_IRA -> Known.SIMPLE_IRA + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is EmployerContribution && amount == other.amount && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, name, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "EmployerContribution{amount=$amount, name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + class PaymentMethod @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val CHECK = of("check") + + @JvmField val DIRECT_DEPOSIT = of("direct_deposit") + + @JvmField val OTHER = of("other") + + @JvmStatic fun of(value: String) = PaymentMethod(JsonField.of(value)) + } + + /** An enum containing [PaymentMethod]'s known values. */ + enum class Known { + CHECK, + DIRECT_DEPOSIT, + OTHER, + } + + /** + * An enum containing [PaymentMethod]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [PaymentMethod] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + CHECK, + DIRECT_DEPOSIT, + OTHER, + /** + * An enum member indicating that [PaymentMethod] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + CHECK -> Value.CHECK + DIRECT_DEPOSIT -> Value.DIRECT_DEPOSIT + OTHER -> Value.OTHER + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + CHECK -> Known.CHECK + DIRECT_DEPOSIT -> Known.DIRECT_DEPOSIT + OTHER -> Known.OTHER + else -> throw FinchInvalidDataException("Unknown PaymentMethod: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): PaymentMethod = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PaymentMethod && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + class Tax + private constructor( + private val amount: JsonField, + private val employer: JsonField, + private val name: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("employer") + @ExcludeMissing + employer: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(amount, employer, name, type, mutableMapOf()) + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun amount(): Optional = amount.getOptional("amount") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun employer(): Optional = employer.getOptional("employer") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun name(): Optional = name.getOptional("name") + + /** + * @throws FinchInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun type(): Optional = type.getOptional("type") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [employer]. + * + * Unlike [employer], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer + + /** + * Returns the raw JSON value of [name]. + * + * Unlike [name], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * Returns the raw JSON value of [type]. + * + * Unlike [type], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** Returns a mutable builder for constructing an instance of [Tax]. */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Tax]. */ + class Builder internal constructor() { + + private var amount: JsonField = JsonMissing.of() + private var employer: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tax: Tax) = apply { + amount = tax.amount + employer = tax.employer + name = tax.name + type = tax.type + additionalProperties = tax.additionalProperties.toMutableMap() + } + + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun employer(employer: Boolean) = employer(JsonField.of(employer)) + + /** + * Sets [Builder.employer] to an arbitrary JSON value. + * + * You should usually call [Builder.employer] with a well-typed [Boolean] value + * instead. This method is primarily for setting the field to an undocumented or not + * yet supported value. + */ + fun employer(employer: JsonField) = apply { this.employer = employer } + + fun name(name: String) = name(JsonField.of(name)) + + /** + * Sets [Builder.name] to an arbitrary JSON value. + * + * You should usually call [Builder.name] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun name(name: JsonField) = apply { this.name = name } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun type(type: JsonField) = apply { this.type = type } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = + apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { + additionalProperties.remove(key) + } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Tax]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): Tax = + Tax(amount, employer, name, type, additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Tax = apply { + if (validated) { + return@apply + } + + amount() + employer() + name() + type().ifPresent { it.validate() } + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (employer.asKnown().isPresent) 1 else 0) + + (if (name.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + class Type @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that + * doesn't match any known member, and you want to know that value. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val FEDERAL = of("federal") + + @JvmField val FICA = of("fica") + + @JvmField val LOCAL = of("local") + + @JvmField val STATE = of("state") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + FEDERAL, + FICA, + LOCAL, + STATE, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, + * if the SDK is on an older version than the API, then the API may respond with + * new members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + FEDERAL, + FICA, + LOCAL, + STATE, + /** + * An enum member indicating that [Type] was instantiated with an unknown value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if + * you want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + FEDERAL -> Value.FEDERAL + FICA -> Value.FICA + LOCAL -> Value.LOCAL + STATE -> Value.STATE + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + FEDERAL -> Known.FEDERAL + FICA -> Known.FICA + LOCAL -> Known.LOCAL + STATE -> Known.STATE + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have + * the expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Tax && amount == other.amount && employer == other.employer && name == other.name && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(amount, employer, name, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Tax{amount=$amount, employer=$employer, name=$name, type=$type, additionalProperties=$additionalProperties}" + } + + class Type @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is + * on an older version than the API, then the API may respond with new members that the + * SDK is unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + @JvmField val OFF_CYCLE_PAYROLL = of("off_cycle_payroll") + + @JvmField val ONE_TIME_PAYMENT = of("one_time_payment") + + @JvmField val REGULAR_PAYROLL = of("regular_payroll") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + OFF_CYCLE_PAYROLL, + ONE_TIME_PAYMENT, + REGULAR_PAYROLL, + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if + * the SDK is on an older version than the API, then the API may respond with new + * members that the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + OFF_CYCLE_PAYROLL, + ONE_TIME_PAYMENT, + REGULAR_PAYROLL, + /** An enum member indicating that [Type] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or + * [Value._UNKNOWN] if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you + * want to throw for the unknown case. + */ + fun value(): Value = + when (this) { + OFF_CYCLE_PAYROLL -> Value.OFF_CYCLE_PAYROLL + ONE_TIME_PAYMENT -> Value.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Value.REGULAR_PAYROLL + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and + * don't want to throw for the unknown case. + * + * @throws FinchInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + OFF_CYCLE_PAYROLL -> Known.OFF_CYCLE_PAYROLL + ONE_TIME_PAYMENT -> Known.ONE_TIME_PAYMENT + REGULAR_PAYROLL -> Known.REGULAR_PAYROLL + else -> throw FinchInvalidDataException("Unknown Type: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for + * debugging and generally doesn't throw. + * + * @throws FinchInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + FinchInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Type = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: FinchInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is Type && value == other.value /* spotless:on */ + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is PayStatement && individualId == other.individualId && earnings == other.earnings && employeeDeductions == other.employeeDeductions && employerContributions == other.employerContributions && grossPay == other.grossPay && netPay == other.netPay && paymentMethod == other.paymentMethod && taxes == other.taxes && totalHours == other.totalHours && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(individualId, earnings, employeeDeductions, employerContributions, grossPay, netPay, paymentMethod, taxes, totalHours, type, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "PayStatement{individualId=$individualId, earnings=$earnings, employeeDeductions=$employeeDeductions, employerContributions=$employerContributions, grossPay=$grossPay, netPay=$netPay, paymentMethod=$paymentMethod, taxes=$taxes, totalHours=$totalHours, type=$type, additionalProperties=$additionalProperties}" } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt index a85a97ac..7373566a 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxPaymentCreateParamsTest.kt @@ -2,7 +2,7 @@ package com.tryfinch.api.models -import com.tryfinch.api.core.JsonValue +import java.time.LocalDate import kotlin.jvm.optionals.getOrNull import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.Test @@ -12,126 +12,54 @@ internal class SandboxPaymentCreateParamsTest { @Test fun create() { SandboxPaymentCreateParams.builder() - .endDate("end_date") + .endDate(LocalDate.parse("2019-12-27")) .addPayStatement( - PayStatement.builder() + SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( - PayStatement.Earning.builder() + SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .currency("currency") .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() .amount(0L) - .currency("currency") - .name("name") + .name("x") .preTax(true) - .type(BenefitType._457) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .type( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Type._457 ) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .currency("currency") - .name("name") - .type(BenefitType._457) + SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.EmployerContribution.Type + ._457 ) .build() ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) + .grossPay(1L) + .netPay(9007199254740991L) + .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( - PayStatement.Tax.builder() - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) + SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) + .employer(true) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - .startDate("start_date") + .startDate(LocalDate.parse("2019-12-27")) .build() } @@ -139,254 +67,109 @@ internal class SandboxPaymentCreateParamsTest { fun body() { val params = SandboxPaymentCreateParams.builder() - .endDate("end_date") + .endDate(LocalDate.parse("2019-12-27")) .addPayStatement( - PayStatement.builder() + SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( - PayStatement.Earning.builder() + SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .currency("currency") .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() .amount(0L) - .currency("currency") - .name("name") + .name("x") .preTax(true) - .type(BenefitType._457) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .type( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Type + ._457 ) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .currency("currency") - .name("name") - .type(BenefitType._457) + SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.EmployerContribution + .Type + ._457 ) .build() ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) + .grossPay(1L) + .netPay(9007199254740991L) + .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( - PayStatement.Tax.builder() - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) + SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) + .employer(true) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - .startDate("start_date") + .startDate(LocalDate.parse("2019-12-27")) .build() val body = params._body() - assertThat(body.endDate()).contains("end_date") + assertThat(body.endDate()).contains(LocalDate.parse("2019-12-27")) assertThat(body.payStatements().getOrNull()) .containsExactly( - PayStatement.builder() + SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( - PayStatement.Earning.builder() + SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .currency("currency") .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() .amount(0L) - .currency("currency") - .name("name") + .name("x") .preTax(true) - .type(BenefitType._457) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .type( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.Type._457 ) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .currency("currency") - .name("name") - .type(BenefitType._457) + SandboxPaymentCreateParams.PayStatement.EmployerContribution.builder() .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.EmployerContribution.Type + ._457 ) .build() ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) + .grossPay(1L) + .netPay(9007199254740991L) + .paymentMethod(SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK) .addTax( - PayStatement.Tax.builder() - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) + SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) + .employer(true) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - assertThat(body.startDate()).contains("start_date") + assertThat(body.startDate()).contains(LocalDate.parse("2019-12-27")) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt index 1ad649b2..9d051351 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncTest.kt @@ -4,11 +4,8 @@ package com.tryfinch.api.services.async.sandbox import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClientAsync -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.models.BenefitType -import com.tryfinch.api.models.Money -import com.tryfinch.api.models.PayStatement import com.tryfinch.api.models.SandboxPaymentCreateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -27,130 +24,62 @@ internal class PaymentServiceAsyncTest { val paymentFuture = paymentServiceAsync.create( SandboxPaymentCreateParams.builder() - .endDate("end_date") + .endDate(LocalDate.parse("2019-12-27")) .addPayStatement( - PayStatement.builder() + SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( - PayStatement.Earning.builder() + SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .currency("currency") .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS ) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() .amount(0L) - .currency("currency") - .name("name") + .name("x") .preTax(true) - .type(BenefitType._457) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .type( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction + .Type + ._457 ) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .currency("currency") - .name("name") - .type(BenefitType._457) + SandboxPaymentCreateParams.PayStatement.EmployerContribution + .builder() .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.EmployerContribution + .Type + ._457 ) .build() ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) + .grossPay(1L) + .netPay(9007199254740991L) + .paymentMethod( + SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK + ) .addTax( - PayStatement.Tax.builder() - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) + SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) + .employer(true) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - .startDate("start_date") + .startDate(LocalDate.parse("2019-12-27")) .build() ) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt index 51cadf5a..afb115b8 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceTest.kt @@ -4,11 +4,8 @@ package com.tryfinch.api.services.blocking.sandbox import com.tryfinch.api.TestServerExtension import com.tryfinch.api.client.okhttp.FinchOkHttpClient -import com.tryfinch.api.core.JsonValue -import com.tryfinch.api.models.BenefitType -import com.tryfinch.api.models.Money -import com.tryfinch.api.models.PayStatement import com.tryfinch.api.models.SandboxPaymentCreateParams +import java.time.LocalDate import org.junit.jupiter.api.Test import org.junit.jupiter.api.extension.ExtendWith @@ -27,130 +24,62 @@ internal class PaymentServiceTest { val payment = paymentService.create( SandboxPaymentCreateParams.builder() - .endDate("end_date") + .endDate(LocalDate.parse("2019-12-27")) .addPayStatement( - PayStatement.builder() + SandboxPaymentCreateParams.PayStatement.builder() + .individualId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .addEarning( - PayStatement.Earning.builder() + SandboxPaymentCreateParams.PayStatement.Earning.builder() .amount(0L) - .currency("currency") .hours(0.0) - .name("name") - .type(PayStatement.Earning.Type.SALARY) - .attributes( - PayStatement.Earning.Attributes.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata.builder() - .metadata( - PayStatement.Earning.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.Earning.Type.BONUS ) .build() ) .addEmployeeDeduction( - PayStatement.EmployeeDeduction.builder() + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction.builder() .amount(0L) - .currency("currency") - .name("name") + .name("x") .preTax(true) - .type(BenefitType._457) - .attributes( - PayStatement.EmployeeDeduction.Attributes.builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes.Metadata - .builder() - .metadata( - PayStatement.EmployeeDeduction.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .type( + SandboxPaymentCreateParams.PayStatement.EmployeeDeduction + .Type + ._457 ) .build() ) .addEmployerContribution( - PayStatement.EmployerContribution.builder() - .currency("currency") - .name("name") - .type(BenefitType._457) + SandboxPaymentCreateParams.PayStatement.EmployerContribution + .builder() .amount(0L) - .attributes( - PayStatement.EmployerContribution.Attributes.builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .builder() - .metadata( - PayStatement.EmployerContribution.Attributes - .Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() + .name("x") + .type( + SandboxPaymentCreateParams.PayStatement.EmployerContribution + .Type + ._457 ) .build() ) - .grossPay(Money.builder().amount(0L).currency("currency").build()) - .individualId("individual_id") - .netPay(Money.builder().amount(0L).currency("currency").build()) - .paymentMethod(PayStatement.PaymentMethod.CHECK) + .grossPay(1L) + .netPay(9007199254740991L) + .paymentMethod( + SandboxPaymentCreateParams.PayStatement.PaymentMethod.CHECK + ) .addTax( - PayStatement.Tax.builder() - .currency("currency") - .employer(true) - .name("name") - .type(PayStatement.Tax.Type.STATE) + SandboxPaymentCreateParams.PayStatement.Tax.builder() .amount(0L) - .attributes( - PayStatement.Tax.Attributes.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata.builder() - .metadata( - PayStatement.Tax.Attributes.Metadata - .InnerMetadata - .builder() - .putAdditionalProperty( - "foo", - JsonValue.from(mapOf()), - ) - .build() - ) - .build() - ) - .build() - ) + .employer(true) + .name("x") + .type(SandboxPaymentCreateParams.PayStatement.Tax.Type.FEDERAL) .build() ) - .totalHours(0.0) - .type(PayStatement.Type.OFF_CYCLE_PAYROLL) + .totalHours(1.0) + .type(SandboxPaymentCreateParams.PayStatement.Type.OFF_CYCLE_PAYROLL) .build() ) - .startDate("start_date") + .startDate(LocalDate.parse("2019-12-27")) .build() ) From 9b313e857a753068e492ffc9fd8a2a9022664ac9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 11 Jun 2025 17:28:20 +0000 Subject: [PATCH 17/26] feat(client): implement per-endpoint base URL support Refactor `HttpRequest` to always take a `baseUrl`, instead of storing this in `OkHttpClient`. This allows better reuse of `OkHttpClient` when changing the `baseUrl`. --- .../api/client/okhttp/FinchOkHttpClient.kt | 8 +---- .../client/okhttp/FinchOkHttpClientAsync.kt | 8 +---- .../api/client/okhttp/OkHttpClient.kt | 17 ++--------- .../com/tryfinch/api/core/ClientOptions.kt | 13 +++++---- .../com/tryfinch/api/core/http/HttpRequest.kt | 12 ++++---- .../async/AccessTokenServiceAsyncImpl.kt | 1 + .../services/async/AccountServiceAsyncImpl.kt | 2 ++ .../async/ProviderServiceAsyncImpl.kt | 1 + .../RequestForwardingServiceAsyncImpl.kt | 1 + .../async/connect/SessionServiceAsyncImpl.kt | 2 ++ .../async/hris/BenefitServiceAsyncImpl.kt | 5 ++++ .../async/hris/CompanyServiceAsyncImpl.kt | 1 + .../async/hris/DirectoryServiceAsyncImpl.kt | 2 ++ .../async/hris/DocumentServiceAsyncImpl.kt | 2 ++ .../async/hris/EmploymentServiceAsyncImpl.kt | 1 + .../async/hris/IndividualServiceAsyncImpl.kt | 1 + .../hris/PayStatementServiceAsyncImpl.kt | 1 + .../async/hris/PaymentServiceAsyncImpl.kt | 1 + .../benefits/IndividualServiceAsyncImpl.kt | 3 ++ .../PayStatementItemServiceAsyncImpl.kt | 1 + .../payStatementItem/RuleServiceAsyncImpl.kt | 4 +++ .../async/jobs/AutomatedServiceAsyncImpl.kt | 3 ++ .../async/jobs/ManualServiceAsyncImpl.kt | 1 + .../async/payroll/PayGroupServiceAsyncImpl.kt | 2 ++ .../async/sandbox/CompanyServiceAsyncImpl.kt | 1 + .../sandbox/ConnectionServiceAsyncImpl.kt | 1 + .../sandbox/DirectoryServiceAsyncImpl.kt | 1 + .../sandbox/EmploymentServiceAsyncImpl.kt | 1 + .../sandbox/IndividualServiceAsyncImpl.kt | 1 + .../async/sandbox/JobServiceAsyncImpl.kt | 1 + .../async/sandbox/PaymentServiceAsyncImpl.kt | 1 + .../connections/AccountServiceAsyncImpl.kt | 2 ++ .../jobs/ConfigurationServiceAsyncImpl.kt | 2 ++ .../blocking/AccessTokenServiceImpl.kt | 1 + .../services/blocking/AccountServiceImpl.kt | 2 ++ .../services/blocking/ProviderServiceImpl.kt | 1 + .../blocking/RequestForwardingServiceImpl.kt | 1 + .../blocking/connect/SessionServiceImpl.kt | 2 ++ .../blocking/hris/BenefitServiceImpl.kt | 5 ++++ .../blocking/hris/CompanyServiceImpl.kt | 1 + .../blocking/hris/DirectoryServiceImpl.kt | 2 ++ .../blocking/hris/DocumentServiceImpl.kt | 2 ++ .../blocking/hris/EmploymentServiceImpl.kt | 1 + .../blocking/hris/IndividualServiceImpl.kt | 1 + .../blocking/hris/PayStatementServiceImpl.kt | 1 + .../blocking/hris/PaymentServiceImpl.kt | 1 + .../hris/benefits/IndividualServiceImpl.kt | 3 ++ .../company/PayStatementItemServiceImpl.kt | 1 + .../payStatementItem/RuleServiceImpl.kt | 4 +++ .../blocking/jobs/AutomatedServiceImpl.kt | 3 ++ .../blocking/jobs/ManualServiceImpl.kt | 1 + .../blocking/payroll/PayGroupServiceImpl.kt | 2 ++ .../blocking/sandbox/CompanyServiceImpl.kt | 1 + .../blocking/sandbox/ConnectionServiceImpl.kt | 1 + .../blocking/sandbox/DirectoryServiceImpl.kt | 1 + .../blocking/sandbox/EmploymentServiceImpl.kt | 1 + .../blocking/sandbox/IndividualServiceImpl.kt | 1 + .../blocking/sandbox/JobServiceImpl.kt | 1 + .../blocking/sandbox/PaymentServiceImpl.kt | 1 + .../sandbox/connections/AccountServiceImpl.kt | 2 ++ .../sandbox/jobs/ConfigurationServiceImpl.kt | 2 ++ .../api/core/http/RetryingHttpClientTest.kt | 29 +++++++++++++++---- 62 files changed, 135 insertions(+), 44 deletions(-) diff --git a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt index 21e1d896..ea6fc295 100644 --- a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt +++ b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClient.kt @@ -189,13 +189,7 @@ class FinchOkHttpClient private constructor() { fun build(): FinchClient = FinchClientImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } diff --git a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt index ecfb663d..158818cc 100644 --- a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt +++ b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/FinchOkHttpClientAsync.kt @@ -189,13 +189,7 @@ class FinchOkHttpClientAsync private constructor() { fun build(): FinchClientAsync = FinchClientAsyncImpl( clientOptions - .httpClient( - OkHttpClient.builder() - .baseUrl(clientOptions.baseUrl()) - .timeout(timeout) - .proxy(proxy) - .build() - ) + .httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build()) .build() ) } diff --git a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt index be523572..7d825642 100644 --- a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt +++ b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt @@ -2,7 +2,6 @@ package com.tryfinch.api.client.okhttp import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.Timeout -import com.tryfinch.api.core.checkRequired import com.tryfinch.api.core.http.Headers import com.tryfinch.api.core.http.HttpClient import com.tryfinch.api.core.http.HttpMethod @@ -17,7 +16,6 @@ import java.time.Duration import java.util.concurrent.CompletableFuture import okhttp3.Call import okhttp3.Callback -import okhttp3.HttpUrl import okhttp3.HttpUrl.Companion.toHttpUrl import okhttp3.MediaType import okhttp3.MediaType.Companion.toMediaType @@ -28,8 +26,7 @@ import okhttp3.Response import okhttp3.logging.HttpLoggingInterceptor import okio.BufferedSink -class OkHttpClient -private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) : +class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) : HttpClient { override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse { @@ -140,11 +137,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val } private fun HttpRequest.toUrl(): String { - url?.let { - return it - } - - val builder = baseUrl.newBuilder() + val builder = baseUrl.toHttpUrl().newBuilder() pathSegments.forEach(builder::addPathSegment) queryParams.keys().forEach { key -> queryParams.values(key).forEach { builder.addQueryParameter(key, it) } @@ -194,12 +187,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val class Builder internal constructor() { - private var baseUrl: HttpUrl? = null private var timeout: Timeout = Timeout.default() private var proxy: Proxy? = null - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() } - fun timeout(timeout: Timeout) = apply { this.timeout = timeout } fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build()) @@ -214,8 +204,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val .writeTimeout(timeout.write()) .callTimeout(timeout.request()) .proxy(proxy) - .build(), - checkRequired("baseUrl", baseUrl), + .build() ) } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt index cfdb5e56..9721297c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt @@ -25,7 +25,7 @@ private constructor( @get:JvmName("jsonMapper") val jsonMapper: JsonMapper, @get:JvmName("streamHandlerExecutor") val streamHandlerExecutor: Executor, @get:JvmName("clock") val clock: Clock, - @get:JvmName("baseUrl") val baseUrl: String, + private val baseUrl: String?, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @get:JvmName("responseValidation") val responseValidation: Boolean, @@ -43,6 +43,8 @@ private constructor( } } + fun baseUrl(): String = baseUrl ?: PRODUCTION_URL + fun accessToken(): Optional = Optional.ofNullable(accessToken) fun clientId(): Optional = Optional.ofNullable(clientId) @@ -78,7 +80,7 @@ private constructor( private var jsonMapper: JsonMapper = jsonMapper() private var streamHandlerExecutor: Executor? = null private var clock: Clock = Clock.systemUTC() - private var baseUrl: String = PRODUCTION_URL + private var baseUrl: String? = null private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() private var responseValidation: Boolean = false @@ -122,7 +124,10 @@ private constructor( fun clock(clock: Clock) = apply { this.clock = clock } - fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun baseUrl(baseUrl: String?) = apply { this.baseUrl = baseUrl } + + /** Alias for calling [Builder.baseUrl] with `baseUrl.orElse(null)`. */ + fun baseUrl(baseUrl: Optional) = baseUrl(baseUrl.getOrNull()) fun responseValidation(responseValidation: Boolean) = apply { this.responseValidation = responseValidation @@ -233,8 +238,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun baseUrl(): String = baseUrl - fun fromEnv() = apply { System.getenv("FINCH_BASE_URL")?.let { baseUrl(it) } System.getenv("FINCH_CLIENT_ID")?.let { clientId(it) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/HttpRequest.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/HttpRequest.kt index c75e9fb9..ab9b11c1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/HttpRequest.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/http/HttpRequest.kt @@ -6,7 +6,7 @@ import com.tryfinch.api.core.toImmutable class HttpRequest private constructor( @get:JvmName("method") val method: HttpMethod, - @get:JvmName("url") val url: String?, + @get:JvmName("baseUrl") val baseUrl: String, @get:JvmName("pathSegments") val pathSegments: List, @get:JvmName("headers") val headers: Headers, @get:JvmName("queryParams") val queryParams: QueryParams, @@ -16,7 +16,7 @@ private constructor( fun toBuilder(): Builder = Builder().from(this) override fun toString(): String = - "HttpRequest{method=$method, url=$url, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" + "HttpRequest{method=$method, baseUrl=$baseUrl, pathSegments=$pathSegments, headers=$headers, queryParams=$queryParams, body=$body}" companion object { @JvmStatic fun builder() = Builder() @@ -25,7 +25,7 @@ private constructor( class Builder internal constructor() { private var method: HttpMethod? = null - private var url: String? = null + private var baseUrl: String? = null private var pathSegments: MutableList = mutableListOf() private var headers: Headers.Builder = Headers.builder() private var queryParams: QueryParams.Builder = QueryParams.builder() @@ -34,7 +34,7 @@ private constructor( @JvmSynthetic internal fun from(request: HttpRequest) = apply { method = request.method - url = request.url + baseUrl = request.baseUrl pathSegments = request.pathSegments.toMutableList() headers = request.headers.toBuilder() queryParams = request.queryParams.toBuilder() @@ -43,7 +43,7 @@ private constructor( fun method(method: HttpMethod) = apply { this.method = method } - fun url(url: String) = apply { this.url = url } + fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } fun addPathSegment(pathSegment: String) = apply { pathSegments.add(pathSegment) } @@ -136,7 +136,7 @@ private constructor( fun build(): HttpRequest = HttpRequest( checkRequired("method", method), - url, + checkRequired("baseUrl", baseUrl), pathSegments.toImmutable(), headers.build(), queryParams.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt index 6ad0bf71..af3369df 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt @@ -77,6 +77,7 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("auth", "token") .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(modifiedParams._queryParams()) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt index dc00271c..33904392 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt @@ -59,6 +59,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("disconnect") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -89,6 +90,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("introspect") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt index 9de04dba..c6293257 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 @@ -50,6 +50,7 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("providers") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt index 25b6c483..23a9ddfa 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt @@ -51,6 +51,7 @@ internal constructor(private val clientOptions: ClientOptions) : RequestForwardi val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("forward") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt index b703391c..80013715 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt @@ -59,6 +59,7 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("connect", "sessions") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -90,6 +91,7 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("connect", "sessions", "reauthenticate") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt index 3465b62b..c21af35f 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 @@ -105,6 +105,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -138,6 +139,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -171,6 +173,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -202,6 +205,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits") .build() .prepareAsync(clientOptions, params) @@ -240,6 +244,7 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", "meta") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt index 36674057..ec58540b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt @@ -64,6 +64,7 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "company") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt index 737aeac0..da50e8de 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 @@ -62,6 +62,7 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "directory") .build() .prepareAsync(clientOptions, params) @@ -101,6 +102,7 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "directory") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt index cd75084e..23a4ea2c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt @@ -61,6 +61,7 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "documents") .build() .prepareAsync(clientOptions, params) @@ -94,6 +95,7 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "documents", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsyncImpl.kt index a9c72d89..3de05962 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 @@ -52,6 +52,7 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "employment") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsyncImpl.kt index 26a7925a..b5e0c64d 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 @@ -52,6 +52,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "individual") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsyncImpl.kt index 6a682d8f..9c47d1ab 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 @@ -52,6 +52,7 @@ class PayStatementServiceAsyncImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncImpl.kt index c8b13fea..bbe1b4d5 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 @@ -50,6 +50,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "payment") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt index 959a36b0..c8efa8f9 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 @@ -75,6 +75,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "enrolled") .build() .prepareAsync(clientOptions, params) @@ -108,6 +109,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") .build() .prepareAsync(clientOptions, params) @@ -149,6 +151,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsyncImpl.kt index 6c1131c8..3f8e1b2f 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 @@ -63,6 +63,7 @@ internal constructor(private val clientOptions: ClientOptions) : PayStatementIte val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsyncImpl.kt index 71f908a0..0a934508 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 @@ -80,6 +80,7 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -113,6 +114,7 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -144,6 +146,7 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule") .build() .prepareAsync(clientOptions, params) @@ -184,6 +187,7 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt index 77de2441..ddf559e7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt @@ -71,6 +71,7 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -104,6 +105,7 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -134,6 +136,7 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt index f52bfd4e..d10dce02 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt @@ -54,6 +54,7 @@ class ManualServiceAsyncImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "manual", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncImpl.kt index 2e8dacac..868eb735 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 @@ -65,6 +65,7 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-groups", params._pathParam(0)) .build() .prepareAsync(clientOptions, params) @@ -95,6 +96,7 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-groups") .build() .prepareAsync(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt index bb6bd71a..606d2425 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt @@ -51,6 +51,7 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "company") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt index 25170227..af1dc997 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt @@ -63,6 +63,7 @@ class ConnectionServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt index 6da02916..39099319 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt @@ -51,6 +51,7 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "directory") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt index 9534d121..dde50650 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt @@ -56,6 +56,7 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "employment", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt index fca58ca0..30031709 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt @@ -56,6 +56,7 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "individual", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt index cbb5ae24..c9924ec5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt @@ -64,6 +64,7 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt index 6f4667da..337e52df 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt @@ -51,6 +51,7 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "payment") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt index 5f788805..919b3e43 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt @@ -60,6 +60,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -91,6 +92,7 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt index 4002444e..34922267 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt @@ -59,6 +59,7 @@ class ConfigurationServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs", "configuration") .build() .prepareAsync(clientOptions, params) @@ -89,6 +90,7 @@ class ConfigurationServiceAsyncImpl internal constructor(private val clientOptio val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs", "configuration") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt index 40a41b0d..917174ce 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt @@ -76,6 +76,7 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("auth", "token") .putAllQueryParams(clientOptions.queryParams) .replaceAllQueryParams(modifiedParams._queryParams()) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt index 84261e55..754420d1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt @@ -58,6 +58,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("disconnect") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -85,6 +86,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("introspect") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt index 0e75130d..3d0ed347 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 @@ -49,6 +49,7 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("providers") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt index f68e8ce7..dadeff29 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt @@ -50,6 +50,7 @@ class RequestForwardingServiceImpl internal constructor(private val clientOption val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("forward") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt index 70986f09..ec591a30 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt @@ -58,6 +58,7 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("connect", "sessions") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -86,6 +87,7 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("connect", "sessions", "reauthenticate") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt index 51b01e92..616637b0 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 @@ -102,6 +102,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -132,6 +133,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -162,6 +164,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -190,6 +193,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits") .build() .prepare(clientOptions, params) @@ -224,6 +228,7 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", "meta") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt index 89a1abcf..3f796652 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt @@ -62,6 +62,7 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "company") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt index b4ecac79..1177fa88 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 @@ -61,6 +61,7 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "directory") .build() .prepare(clientOptions, params) @@ -96,6 +97,7 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "directory") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt index 2f11fac7..0eda2c82 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt @@ -60,6 +60,7 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "documents") .build() .prepare(clientOptions, params) @@ -90,6 +91,7 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "documents", params._pathParam(0)) .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt index b3fbd9b9..dc8a9559 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 @@ -51,6 +51,7 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "employment") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt index 150aaa04..37d4b4ca 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 @@ -51,6 +51,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "individual") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt index 6cfadcaf..01d35d76 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 @@ -51,6 +51,7 @@ class PayStatementServiceImpl internal constructor(private val clientOptions: Cl val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt index 7cb22ea4..275d6727 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 @@ -49,6 +49,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "payment") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt index 9fc38484..ee1e664e 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 @@ -74,6 +74,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "enrolled") .build() .prepare(clientOptions, params) @@ -104,6 +105,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") .build() .prepare(clientOptions, params) @@ -141,6 +143,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "benefits", params._pathParam(0), "individuals") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt index 87dd1814..c1d7e09d 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 @@ -62,6 +62,7 @@ class PayStatementItemServiceImpl internal constructor(private val clientOptions val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt index c829f537..6b159099 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 @@ -78,6 +78,7 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -108,6 +109,7 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -136,6 +138,7 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule") .build() .prepare(clientOptions, params) @@ -172,6 +175,7 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti val request = HttpRequest.builder() .method(HttpMethod.DELETE) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-statement-item", "rule", params._pathParam(0)) .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt index 87e961d5..2e9dc8b2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt @@ -70,6 +70,7 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() @@ -100,6 +101,7 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -127,6 +129,7 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "automated") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt index 373dabf5..ceb71890 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt @@ -53,6 +53,7 @@ class ManualServiceImpl internal constructor(private val clientOptions: ClientOp val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("jobs", "manual", params._pathParam(0)) .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt index fffb28b5..00b9c9db 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 @@ -64,6 +64,7 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-groups", params._pathParam(0)) .build() .prepare(clientOptions, params) @@ -91,6 +92,7 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("employer", "pay-groups") .build() .prepare(clientOptions, params) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt index 6289d961..0d2869c2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt @@ -50,6 +50,7 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "company") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt index 18e96822..f9df4a88 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt @@ -62,6 +62,7 @@ class ConnectionServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt index 41ad5a2f..3bf09066 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt @@ -50,6 +50,7 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "directory") .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt index e956fc67..fc9bb4a4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt @@ -55,6 +55,7 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "employment", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt index df8ba4b5..e7c5ed53 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt @@ -55,6 +55,7 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "individual", params._pathParam(0)) .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt index 5a01752f..08a9e2a1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt @@ -62,6 +62,7 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt index efcd8f16..4f39d17d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt @@ -50,6 +50,7 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "payment") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt index 12f7aeb6..06721f17 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt @@ -59,6 +59,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() @@ -87,6 +88,7 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "connections", "accounts") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt index ce53138b..810001a4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt @@ -58,6 +58,7 @@ class ConfigurationServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.GET) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs", "configuration") .build() .prepare(clientOptions, params) @@ -85,6 +86,7 @@ class ConfigurationServiceImpl internal constructor(private val clientOptions: C val request = HttpRequest.builder() .method(HttpMethod.PUT) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("sandbox", "jobs", "configuration") .body(json(clientOptions.jsonMapper, params._body())) .build() diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/RetryingHttpClientTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/RetryingHttpClientTest.kt index b20e1b90..fd0f5b5f 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/RetryingHttpClientTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/http/RetryingHttpClientTest.kt @@ -20,11 +20,13 @@ import org.junit.jupiter.params.provider.ValueSource internal class RetryingHttpClientTest { private var openResponseCount = 0 + private lateinit var baseUrl: String private lateinit var httpClient: HttpClient @BeforeEach fun beforeEach(wmRuntimeInfo: WireMockRuntimeInfo) { - val okHttpClient = OkHttpClient.builder().baseUrl(wmRuntimeInfo.httpBaseUrl).build() + baseUrl = wmRuntimeInfo.httpBaseUrl + val okHttpClient = OkHttpClient.builder().build() httpClient = object : HttpClient { @@ -75,7 +77,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -97,7 +103,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -139,7 +149,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) @@ -187,6 +201,7 @@ internal class RetryingHttpClientTest { retryingClient.execute( HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(baseUrl) .addPathSegment("something") .putHeader("x-stainless-retry-count", "42") .build(), @@ -223,7 +238,11 @@ internal class RetryingHttpClientTest { val response = retryingClient.execute( - HttpRequest.builder().method(HttpMethod.POST).addPathSegment("something").build(), + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(baseUrl) + .addPathSegment("something") + .build(), async, ) From a6d2027c37a9dcf2582041bfa003b3d52a2699f4 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 13 Jun 2025 14:56:27 +0000 Subject: [PATCH 18/26] feat(client): add a `withOptions` method --- README.md | 15 +++++++++++++++ .../com/tryfinch/api/client/FinchClient.kt | 16 ++++++++++++++++ .../tryfinch/api/client/FinchClientAsync.kt | 16 ++++++++++++++++ .../api/client/FinchClientAsyncImpl.kt | 13 ++++++++++++- .../com/tryfinch/api/client/FinchClientImpl.kt | 13 ++++++++++++- .../services/async/AccessTokenServiceAsync.kt | 18 ++++++++++++++++++ .../async/AccessTokenServiceAsyncImpl.kt | 11 +++++++++++ .../api/services/async/AccountServiceAsync.kt | 18 ++++++++++++++++++ .../services/async/AccountServiceAsyncImpl.kt | 11 +++++++++++ .../api/services/async/ConnectServiceAsync.kt | 18 ++++++++++++++++++ .../services/async/ConnectServiceAsyncImpl.kt | 11 +++++++++++ .../api/services/async/HrisServiceAsync.kt | 16 ++++++++++++++++ .../api/services/async/HrisServiceAsyncImpl.kt | 11 +++++++++++ .../api/services/async/JobServiceAsync.kt | 16 ++++++++++++++++ .../api/services/async/JobServiceAsyncImpl.kt | 11 +++++++++++ .../api/services/async/PayrollServiceAsync.kt | 18 ++++++++++++++++++ .../services/async/PayrollServiceAsyncImpl.kt | 11 +++++++++++ .../api/services/async/ProviderServiceAsync.kt | 18 ++++++++++++++++++ .../services/async/ProviderServiceAsyncImpl.kt | 11 +++++++++++ .../async/RequestForwardingServiceAsync.kt | 18 ++++++++++++++++++ .../async/RequestForwardingServiceAsyncImpl.kt | 13 +++++++++++++ .../api/services/async/SandboxServiceAsync.kt | 18 ++++++++++++++++++ .../services/async/SandboxServiceAsyncImpl.kt | 11 +++++++++++ .../api/services/async/WebhookServiceAsync.kt | 9 +++++++++ .../services/async/WebhookServiceAsyncImpl.kt | 4 ++++ .../async/connect/SessionServiceAsync.kt | 18 ++++++++++++++++++ .../async/connect/SessionServiceAsyncImpl.kt | 11 +++++++++++ .../services/async/hris/BenefitServiceAsync.kt | 18 ++++++++++++++++++ .../async/hris/BenefitServiceAsyncImpl.kt | 11 +++++++++++ .../services/async/hris/CompanyServiceAsync.kt | 18 ++++++++++++++++++ .../async/hris/CompanyServiceAsyncImpl.kt | 11 +++++++++++ .../async/hris/DirectoryServiceAsync.kt | 18 ++++++++++++++++++ .../async/hris/DirectoryServiceAsyncImpl.kt | 11 +++++++++++ .../async/hris/DocumentServiceAsync.kt | 18 ++++++++++++++++++ .../async/hris/DocumentServiceAsyncImpl.kt | 11 +++++++++++ .../async/hris/EmploymentServiceAsync.kt | 18 ++++++++++++++++++ .../async/hris/EmploymentServiceAsyncImpl.kt | 11 +++++++++++ .../async/hris/IndividualServiceAsync.kt | 18 ++++++++++++++++++ .../async/hris/IndividualServiceAsyncImpl.kt | 11 +++++++++++ .../async/hris/PayStatementServiceAsync.kt | 18 ++++++++++++++++++ .../async/hris/PayStatementServiceAsyncImpl.kt | 11 +++++++++++ .../services/async/hris/PaymentServiceAsync.kt | 18 ++++++++++++++++++ .../async/hris/PaymentServiceAsyncImpl.kt | 11 +++++++++++ .../hris/benefits/IndividualServiceAsync.kt | 18 ++++++++++++++++++ .../benefits/IndividualServiceAsyncImpl.kt | 11 +++++++++++ .../company/PayStatementItemServiceAsync.kt | 18 ++++++++++++++++++ .../PayStatementItemServiceAsyncImpl.kt | 13 +++++++++++++ .../payStatementItem/RuleServiceAsync.kt | 16 ++++++++++++++++ .../payStatementItem/RuleServiceAsyncImpl.kt | 11 +++++++++++ .../async/jobs/AutomatedServiceAsync.kt | 18 ++++++++++++++++++ .../async/jobs/AutomatedServiceAsyncImpl.kt | 11 +++++++++++ .../services/async/jobs/ManualServiceAsync.kt | 18 ++++++++++++++++++ .../async/jobs/ManualServiceAsyncImpl.kt | 11 +++++++++++ .../async/payroll/PayGroupServiceAsync.kt | 18 ++++++++++++++++++ .../async/payroll/PayGroupServiceAsyncImpl.kt | 11 +++++++++++ .../async/sandbox/CompanyServiceAsync.kt | 18 ++++++++++++++++++ .../async/sandbox/CompanyServiceAsyncImpl.kt | 11 +++++++++++ .../async/sandbox/ConnectionServiceAsync.kt | 18 ++++++++++++++++++ .../sandbox/ConnectionServiceAsyncImpl.kt | 11 +++++++++++ .../async/sandbox/DirectoryServiceAsync.kt | 18 ++++++++++++++++++ .../async/sandbox/DirectoryServiceAsyncImpl.kt | 11 +++++++++++ .../async/sandbox/EmploymentServiceAsync.kt | 18 ++++++++++++++++++ .../sandbox/EmploymentServiceAsyncImpl.kt | 11 +++++++++++ .../async/sandbox/IndividualServiceAsync.kt | 18 ++++++++++++++++++ .../sandbox/IndividualServiceAsyncImpl.kt | 11 +++++++++++ .../services/async/sandbox/JobServiceAsync.kt | 16 ++++++++++++++++ .../async/sandbox/JobServiceAsyncImpl.kt | 11 +++++++++++ .../async/sandbox/PaymentServiceAsync.kt | 18 ++++++++++++++++++ .../async/sandbox/PaymentServiceAsyncImpl.kt | 11 +++++++++++ .../sandbox/connections/AccountServiceAsync.kt | 18 ++++++++++++++++++ .../connections/AccountServiceAsyncImpl.kt | 11 +++++++++++ .../sandbox/jobs/ConfigurationServiceAsync.kt | 18 ++++++++++++++++++ .../jobs/ConfigurationServiceAsyncImpl.kt | 11 +++++++++++ .../services/blocking/AccessTokenService.kt | 18 ++++++++++++++++++ .../blocking/AccessTokenServiceImpl.kt | 11 +++++++++++ .../api/services/blocking/AccountService.kt | 16 ++++++++++++++++ .../services/blocking/AccountServiceImpl.kt | 11 +++++++++++ .../api/services/blocking/ConnectService.kt | 16 ++++++++++++++++ .../services/blocking/ConnectServiceImpl.kt | 11 +++++++++++ .../api/services/blocking/HrisService.kt | 16 ++++++++++++++++ .../api/services/blocking/HrisServiceImpl.kt | 11 +++++++++++ .../api/services/blocking/JobService.kt | 16 ++++++++++++++++ .../api/services/blocking/JobServiceImpl.kt | 11 +++++++++++ .../api/services/blocking/PayrollService.kt | 16 ++++++++++++++++ .../services/blocking/PayrollServiceImpl.kt | 11 +++++++++++ .../api/services/blocking/ProviderService.kt | 16 ++++++++++++++++ .../services/blocking/ProviderServiceImpl.kt | 11 +++++++++++ .../blocking/RequestForwardingService.kt | 18 ++++++++++++++++++ .../blocking/RequestForwardingServiceImpl.kt | 11 +++++++++++ .../api/services/blocking/SandboxService.kt | 16 ++++++++++++++++ .../services/blocking/SandboxServiceImpl.kt | 11 +++++++++++ .../api/services/blocking/WebhookService.kt | 9 +++++++++ .../services/blocking/WebhookServiceImpl.kt | 4 ++++ .../blocking/connect/SessionService.kt | 16 ++++++++++++++++ .../blocking/connect/SessionServiceImpl.kt | 11 +++++++++++ .../services/blocking/hris/BenefitService.kt | 16 ++++++++++++++++ .../blocking/hris/BenefitServiceImpl.kt | 11 +++++++++++ .../services/blocking/hris/CompanyService.kt | 16 ++++++++++++++++ .../blocking/hris/CompanyServiceImpl.kt | 11 +++++++++++ .../services/blocking/hris/DirectoryService.kt | 16 ++++++++++++++++ .../blocking/hris/DirectoryServiceImpl.kt | 11 +++++++++++ .../services/blocking/hris/DocumentService.kt | 16 ++++++++++++++++ .../blocking/hris/DocumentServiceImpl.kt | 11 +++++++++++ .../blocking/hris/EmploymentService.kt | 18 ++++++++++++++++++ .../blocking/hris/EmploymentServiceImpl.kt | 11 +++++++++++ .../blocking/hris/IndividualService.kt | 18 ++++++++++++++++++ .../blocking/hris/IndividualServiceImpl.kt | 11 +++++++++++ .../blocking/hris/PayStatementService.kt | 18 ++++++++++++++++++ .../blocking/hris/PayStatementServiceImpl.kt | 11 +++++++++++ .../services/blocking/hris/PaymentService.kt | 16 ++++++++++++++++ .../blocking/hris/PaymentServiceImpl.kt | 11 +++++++++++ .../hris/benefits/IndividualService.kt | 18 ++++++++++++++++++ .../hris/benefits/IndividualServiceImpl.kt | 11 +++++++++++ .../hris/company/PayStatementItemService.kt | 18 ++++++++++++++++++ .../company/PayStatementItemServiceImpl.kt | 11 +++++++++++ .../company/payStatementItem/RuleService.kt | 16 ++++++++++++++++ .../payStatementItem/RuleServiceImpl.kt | 11 +++++++++++ .../services/blocking/jobs/AutomatedService.kt | 16 ++++++++++++++++ .../blocking/jobs/AutomatedServiceImpl.kt | 11 +++++++++++ .../services/blocking/jobs/ManualService.kt | 16 ++++++++++++++++ .../blocking/jobs/ManualServiceImpl.kt | 11 +++++++++++ .../blocking/payroll/PayGroupService.kt | 16 ++++++++++++++++ .../blocking/payroll/PayGroupServiceImpl.kt | 11 +++++++++++ .../blocking/sandbox/CompanyService.kt | 16 ++++++++++++++++ .../blocking/sandbox/CompanyServiceImpl.kt | 11 +++++++++++ .../blocking/sandbox/ConnectionService.kt | 18 ++++++++++++++++++ .../blocking/sandbox/ConnectionServiceImpl.kt | 11 +++++++++++ .../blocking/sandbox/DirectoryService.kt | 16 ++++++++++++++++ .../blocking/sandbox/DirectoryServiceImpl.kt | 11 +++++++++++ .../blocking/sandbox/EmploymentService.kt | 18 ++++++++++++++++++ .../blocking/sandbox/EmploymentServiceImpl.kt | 11 +++++++++++ .../blocking/sandbox/IndividualService.kt | 18 ++++++++++++++++++ .../blocking/sandbox/IndividualServiceImpl.kt | 11 +++++++++++ .../services/blocking/sandbox/JobService.kt | 16 ++++++++++++++++ .../blocking/sandbox/JobServiceImpl.kt | 11 +++++++++++ .../blocking/sandbox/PaymentService.kt | 16 ++++++++++++++++ .../blocking/sandbox/PaymentServiceImpl.kt | 11 +++++++++++ .../sandbox/connections/AccountService.kt | 16 ++++++++++++++++ .../sandbox/connections/AccountServiceImpl.kt | 11 +++++++++++ .../sandbox/jobs/ConfigurationService.kt | 18 ++++++++++++++++++ .../sandbox/jobs/ConfigurationServiceImpl.kt | 11 +++++++++++ 141 files changed, 1963 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bdb48061..44a5705e 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,21 @@ See this table for the available options: > Don't create more than one client in the same application. Each client has a connection pool and > thread pools, which are more efficient to share between requests. +### Modifying configuration + +To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service: + +```java +import com.tryfinch.api.client.FinchClient; + +FinchClient clientWithOptions = client.withOptions(optionsBuilder -> { + optionsBuilder.baseUrl("https://example.com"); + optionsBuilder.maxRetries(42); +}); +``` + +The `withOptions()` method does not affect the original client or service. + ## Requests and responses To send a request to the Finch API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt index 4d6662df..b1026a74 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClient.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.client import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.AccessTokenService import com.tryfinch.api.services.blocking.AccountService import com.tryfinch.api.services.blocking.ConnectService @@ -13,6 +14,7 @@ import com.tryfinch.api.services.blocking.ProviderService import com.tryfinch.api.services.blocking.RequestForwardingService import com.tryfinch.api.services.blocking.SandboxService import com.tryfinch.api.services.blocking.WebhookService +import java.util.function.Consumer /** * A client for interacting with the Finch REST API synchronously. You can also switch to @@ -43,6 +45,13 @@ interface FinchClient { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FinchClient + fun accessTokens(): AccessTokenService fun hris(): HrisService @@ -109,6 +118,13 @@ interface FinchClient { /** A view of [FinchClient] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FinchClient.WithRawResponse + fun accessTokens(): AccessTokenService.WithRawResponse fun hris(): HrisService.WithRawResponse diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt index d829a593..df116b22 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsync.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.client import com.fasterxml.jackson.annotation.JsonProperty +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.AccessTokenServiceAsync import com.tryfinch.api.services.async.AccountServiceAsync import com.tryfinch.api.services.async.ConnectServiceAsync @@ -14,6 +15,7 @@ import com.tryfinch.api.services.async.RequestForwardingServiceAsync import com.tryfinch.api.services.async.SandboxServiceAsync import com.tryfinch.api.services.async.WebhookServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer /** * A client for interacting with the Finch REST API asynchronously. You can also switch to @@ -44,6 +46,13 @@ interface FinchClientAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FinchClientAsync + fun accessTokens(): AccessTokenServiceAsync fun hris(): HrisServiceAsync @@ -110,6 +119,13 @@ interface FinchClientAsync { /** A view of [FinchClientAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): FinchClientAsync.WithRawResponse + fun accessTokens(): AccessTokenServiceAsync.WithRawResponse fun hris(): HrisServiceAsync.WithRawResponse diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt index 23a0f4e0..8fba331e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt @@ -37,6 +37,7 @@ import com.tryfinch.api.services.async.WebhookServiceAsync import com.tryfinch.api.services.async.WebhookServiceAsyncImpl import java.net.URLEncoder import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClientAsync { @@ -99,6 +100,9 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie override fun withRawResponse(): FinchClientAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FinchClientAsync = + FinchClientAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun accessTokens(): AccessTokenServiceAsync = accessTokens override fun hris(): HrisServiceAsync = hris @@ -166,7 +170,7 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie .httpClient(clientOptions.httpClient) .jsonMapper(clientOptions.jsonMapper) .clock(clientOptions.clock) - .baseUrl(clientOptions.baseUrl) + .baseUrl(clientOptions.baseUrl()) .accessToken(accessToken) .clientId(clientOptions.clientId()) .clientSecret(clientOptions.clientSecret()) @@ -235,6 +239,13 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie ConnectServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FinchClientAsync.WithRawResponse = + FinchClientAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun accessTokens(): AccessTokenServiceAsync.WithRawResponse = accessTokens override fun hris(): HrisServiceAsync.WithRawResponse = hris diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt index 766d1631..bfce2413 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt @@ -36,6 +36,7 @@ import com.tryfinch.api.services.blocking.SandboxServiceImpl import com.tryfinch.api.services.blocking.WebhookService import com.tryfinch.api.services.blocking.WebhookServiceImpl import java.net.URLEncoder +import java.util.function.Consumer class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { @@ -88,6 +89,9 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { override fun withRawResponse(): FinchClient.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): FinchClient = + FinchClientImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun accessTokens(): AccessTokenService = accessTokens override fun hris(): HrisService = hris @@ -155,7 +159,7 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { .httpClient(clientOptions.httpClient) .jsonMapper(clientOptions.jsonMapper) .clock(clientOptions.clock) - .baseUrl(clientOptions.baseUrl) + .baseUrl(clientOptions.baseUrl()) .accessToken(accessToken) .clientId(clientOptions.clientId()) .clientSecret(clientOptions.clientSecret()) @@ -224,6 +228,13 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { ConnectServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): FinchClient.WithRawResponse = + FinchClientImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun accessTokens(): AccessTokenService.WithRawResponse = accessTokens override fun hris(): HrisService.WithRawResponse = hris diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt index 4857cd1e..36c9661d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AccessTokenServiceAsync { @@ -15,6 +17,13 @@ interface AccessTokenServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccessTokenServiceAsync + /** Exchange the authorization code for an access token */ fun create(params: AccessTokenCreateParams): CompletableFuture = create(params, RequestOptions.none()) @@ -31,6 +40,15 @@ interface AccessTokenServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccessTokenServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /auth/token`, but is otherwise the same as * [AccessTokenServiceAsync.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt index af3369df..ef156b00 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccessTokenServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.errors.FinchException import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions override fun withRawResponse(): AccessTokenServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccessTokenServiceAsync = + AccessTokenServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AccessTokenCreateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class AccessTokenServiceAsyncImpl internal constructor(private val clientOptions private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccessTokenServiceAsync.WithRawResponse = + AccessTokenServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt index 78f646be..7212dfad 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountDisconnectParams @@ -9,6 +10,7 @@ import com.tryfinch.api.models.AccountIntrospectParams import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AccountServiceAsync { @@ -17,6 +19,13 @@ interface AccountServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountServiceAsync + /** Disconnect one or more `access_token`s from your application. */ fun disconnect(): CompletableFuture = disconnect(AccountDisconnectParams.none()) @@ -59,6 +68,15 @@ interface AccountServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /disconnect`, but is otherwise the same as * [AccountServiceAsync.disconnect]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt index 33904392..3ba53cae 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/AccountServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.AccountIntrospectParams import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AccountServiceAsync { @@ -30,6 +31,9 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): AccountServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccountServiceAsync = + AccountServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun disconnect( params: AccountDisconnectParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse = + AccountServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val disconnectHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsync.kt index 53ceda78..511e36b2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsync.kt @@ -2,7 +2,9 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.connect.SessionServiceAsync +import java.util.function.Consumer interface ConnectServiceAsync { @@ -11,6 +13,13 @@ interface ConnectServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectServiceAsync + fun sessions(): SessionServiceAsync /** @@ -18,6 +27,15 @@ interface ConnectServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConnectServiceAsync.WithRawResponse + fun sessions(): SessionServiceAsync.WithRawResponse } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsyncImpl.kt index f93bc643..38e8db16 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ConnectServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.tryfinch.api.services.async import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.connect.SessionServiceAsync import com.tryfinch.api.services.async.connect.SessionServiceAsyncImpl +import java.util.function.Consumer class ConnectServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ConnectServiceAsync { @@ -17,6 +18,9 @@ class ConnectServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): ConnectServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConnectServiceAsync = + ConnectServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun sessions(): SessionServiceAsync = sessions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class ConnectServiceAsyncImpl internal constructor(private val clientOptions: Cl SessionServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConnectServiceAsync.WithRawResponse = + ConnectServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun sessions(): SessionServiceAsync.WithRawResponse = sessions } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsync.kt index 9a2feba1..0093242b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.hris.BenefitServiceAsync import com.tryfinch.api.services.async.hris.CompanyServiceAsync import com.tryfinch.api.services.async.hris.DirectoryServiceAsync @@ -10,6 +11,7 @@ import com.tryfinch.api.services.async.hris.EmploymentServiceAsync import com.tryfinch.api.services.async.hris.IndividualServiceAsync import com.tryfinch.api.services.async.hris.PayStatementServiceAsync import com.tryfinch.api.services.async.hris.PaymentServiceAsync +import java.util.function.Consumer interface HrisServiceAsync { @@ -18,6 +20,13 @@ interface HrisServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HrisServiceAsync + fun company(): CompanyServiceAsync fun directory(): DirectoryServiceAsync @@ -37,6 +46,13 @@ interface HrisServiceAsync { /** A view of [HrisServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HrisServiceAsync.WithRawResponse + fun company(): CompanyServiceAsync.WithRawResponse fun directory(): DirectoryServiceAsync.WithRawResponse diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsyncImpl.kt index 93d03324..afccc63c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/HrisServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.services.async.hris.PayStatementServiceAsync import com.tryfinch.api.services.async.hris.PayStatementServiceAsyncImpl import com.tryfinch.api.services.async.hris.PaymentServiceAsync import com.tryfinch.api.services.async.hris.PaymentServiceAsyncImpl +import java.util.function.Consumer class HrisServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : HrisServiceAsync { @@ -53,6 +54,9 @@ class HrisServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): HrisServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): HrisServiceAsync = + HrisServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun company(): CompanyServiceAsync = company override fun directory(): DirectoryServiceAsync = directory @@ -104,6 +108,13 @@ class HrisServiceAsyncImpl internal constructor(private val clientOptions: Clien BenefitServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): HrisServiceAsync.WithRawResponse = + HrisServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun company(): CompanyServiceAsync.WithRawResponse = company override fun directory(): DirectoryServiceAsync.WithRawResponse = directory diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsync.kt index 5b415166..d0f8e96a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsync.kt @@ -2,8 +2,10 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.jobs.AutomatedServiceAsync import com.tryfinch.api.services.async.jobs.ManualServiceAsync +import java.util.function.Consumer interface JobServiceAsync { @@ -12,6 +14,13 @@ interface JobServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync + fun automated(): AutomatedServiceAsync fun manual(): ManualServiceAsync @@ -19,6 +28,13 @@ interface JobServiceAsync { /** A view of [JobServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync.WithRawResponse + fun automated(): AutomatedServiceAsync.WithRawResponse fun manual(): ManualServiceAsync.WithRawResponse diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsyncImpl.kt index 5849135c..e1313907 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/JobServiceAsyncImpl.kt @@ -7,6 +7,7 @@ import com.tryfinch.api.services.async.jobs.AutomatedServiceAsync import com.tryfinch.api.services.async.jobs.AutomatedServiceAsyncImpl import com.tryfinch.api.services.async.jobs.ManualServiceAsync import com.tryfinch.api.services.async.jobs.ManualServiceAsyncImpl +import java.util.function.Consumer class JobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : JobServiceAsync { @@ -23,6 +24,9 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): JobServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobServiceAsync = + JobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun automated(): AutomatedServiceAsync = automated override fun manual(): ManualServiceAsync = manual @@ -38,6 +42,13 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client ManualServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobServiceAsync.WithRawResponse = + JobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun automated(): AutomatedServiceAsync.WithRawResponse = automated override fun manual(): ManualServiceAsync.WithRawResponse = manual diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsync.kt index 66caaaaa..c7c8ab69 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsync.kt @@ -2,7 +2,9 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.payroll.PayGroupServiceAsync +import java.util.function.Consumer interface PayrollServiceAsync { @@ -11,6 +13,13 @@ interface PayrollServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayrollServiceAsync + fun payGroups(): PayGroupServiceAsync /** @@ -18,6 +27,15 @@ interface PayrollServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayrollServiceAsync.WithRawResponse + fun payGroups(): PayGroupServiceAsync.WithRawResponse } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsyncImpl.kt index 6c3ca41f..ee6470c8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/PayrollServiceAsyncImpl.kt @@ -5,6 +5,7 @@ package com.tryfinch.api.services.async import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.payroll.PayGroupServiceAsync import com.tryfinch.api.services.async.payroll.PayGroupServiceAsyncImpl +import java.util.function.Consumer class PayrollServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PayrollServiceAsync { @@ -17,6 +18,9 @@ class PayrollServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): PayrollServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayrollServiceAsync = + PayrollServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun payGroups(): PayGroupServiceAsync = payGroups class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class PayrollServiceAsyncImpl internal constructor(private val clientOptions: Cl PayGroupServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): PayrollServiceAsync.WithRawResponse = + PayrollServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun payGroups(): PayGroupServiceAsync.WithRawResponse = payGroups } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt index a7ff5368..40d2a85c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ProviderListPageAsync import com.tryfinch.api.models.ProviderListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ProviderServiceAsync { @@ -15,6 +17,13 @@ interface ProviderServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderServiceAsync + /** Return details on all available payroll and HR systems. */ fun list(): CompletableFuture = list(ProviderListParams.none()) @@ -38,6 +47,15 @@ interface ProviderServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ProviderServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /providers`, but is otherwise the same as * [ProviderServiceAsync.list]. 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 c6293257..4a98315b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/ProviderServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.models.Provider import com.tryfinch.api.models.ProviderListPageAsync import com.tryfinch.api.models.ProviderListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ProviderServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ProviderServiceAsync { @@ -28,6 +29,9 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): ProviderServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ProviderServiceAsync = + ProviderServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: ProviderListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ProviderServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ProviderServiceAsync.WithRawResponse = + ProviderServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt index 764b0e6b..883d8abc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RequestForwardingServiceAsync { @@ -15,6 +17,13 @@ interface RequestForwardingServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RequestForwardingServiceAsync + /** * The Forward API allows you to make direct requests to an employment system. If Finch’s * unified API doesn’t have a data model that cleanly fits your needs, then Forward allows you @@ -36,6 +45,15 @@ interface RequestForwardingServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RequestForwardingServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /forward`, but is otherwise the same as * [RequestForwardingServiceAsync.forward]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt index 23a9ddfa..3f406b22 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/RequestForwardingServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class RequestForwardingServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : RequestForwardingServiceAsync { @@ -28,6 +29,11 @@ internal constructor(private val clientOptions: ClientOptions) : RequestForwardi override fun withRawResponse(): RequestForwardingServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): RequestForwardingServiceAsync = + RequestForwardingServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun forward( params: RequestForwardingForwardParams, requestOptions: RequestOptions, @@ -40,6 +46,13 @@ internal constructor(private val clientOptions: ClientOptions) : RequestForwardi private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RequestForwardingServiceAsync.WithRawResponse = + RequestForwardingServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val forwardHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsync.kt index d7cf62b6..f04490d9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.async.sandbox.CompanyServiceAsync import com.tryfinch.api.services.async.sandbox.ConnectionServiceAsync import com.tryfinch.api.services.async.sandbox.DirectoryServiceAsync @@ -9,6 +10,7 @@ import com.tryfinch.api.services.async.sandbox.EmploymentServiceAsync import com.tryfinch.api.services.async.sandbox.IndividualServiceAsync import com.tryfinch.api.services.async.sandbox.JobServiceAsync import com.tryfinch.api.services.async.sandbox.PaymentServiceAsync +import java.util.function.Consumer interface SandboxServiceAsync { @@ -17,6 +19,13 @@ interface SandboxServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SandboxServiceAsync + fun connections(): ConnectionServiceAsync fun company(): CompanyServiceAsync @@ -36,6 +45,15 @@ interface SandboxServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SandboxServiceAsync.WithRawResponse + fun connections(): ConnectionServiceAsync.WithRawResponse fun company(): CompanyServiceAsync.WithRawResponse diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsyncImpl.kt index 409d5daf..65186547 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/SandboxServiceAsyncImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.services.async.sandbox.JobServiceAsync import com.tryfinch.api.services.async.sandbox.JobServiceAsyncImpl import com.tryfinch.api.services.async.sandbox.PaymentServiceAsync import com.tryfinch.api.services.async.sandbox.PaymentServiceAsyncImpl +import java.util.function.Consumer class SandboxServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SandboxServiceAsync { @@ -49,6 +50,9 @@ class SandboxServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): SandboxServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SandboxServiceAsync = + SandboxServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun connections(): ConnectionServiceAsync = connections override fun company(): CompanyServiceAsync = company @@ -94,6 +98,13 @@ class SandboxServiceAsyncImpl internal constructor(private val clientOptions: Cl JobServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): SandboxServiceAsync.WithRawResponse = + SandboxServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun connections(): ConnectionServiceAsync.WithRawResponse = connections override fun company(): CompanyServiceAsync.WithRawResponse = company diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsync.kt index 922adb3f..67dae0f0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsync.kt @@ -2,11 +2,20 @@ package com.tryfinch.api.services.async +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.http.Headers import com.tryfinch.api.models.WebhookEvent +import java.util.function.Consumer interface WebhookServiceAsync { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebhookServiceAsync + fun unwrap(payload: String, headers: Headers, secret: String?): WebhookEvent fun verifySignature(payload: String, headers: Headers, secret: String?) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsyncImpl.kt index 594a5792..c6488253 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/WebhookServiceAsyncImpl.kt @@ -12,6 +12,7 @@ import java.security.MessageDigest import java.time.Duration import java.time.Instant import java.util.Base64 +import java.util.function.Consumer import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec import kotlin.jvm.optionals.getOrNull @@ -19,6 +20,9 @@ import kotlin.jvm.optionals.getOrNull class WebhookServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : WebhookServiceAsync { + override fun withOptions(modifier: Consumer): WebhookServiceAsync = + WebhookServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun unwrap(payload: String, headers: Headers, secret: String?): WebhookEvent { verifySignature(payload, headers, secret) return try { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt index 9d4fc709..930e06a7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.connect +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectSessionNewParams @@ -9,6 +10,7 @@ import com.tryfinch.api.models.ConnectSessionReauthenticateParams import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface SessionServiceAsync { @@ -17,6 +19,13 @@ interface SessionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SessionServiceAsync + /** Create a new connect session for an employer */ fun new_(params: ConnectSessionNewParams): CompletableFuture = new_(params, RequestOptions.none()) @@ -44,6 +53,15 @@ interface SessionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): SessionServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /connect/sessions`, but is otherwise the same as * [SessionServiceAsync.new_]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt index 80013715..384db65f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/connect/SessionServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.ConnectSessionReauthenticateParams import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class SessionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : SessionServiceAsync { @@ -30,6 +31,9 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): SessionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SessionServiceAsync = + SessionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class SessionServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SessionServiceAsync.WithRawResponse = + SessionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val newHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt index 5f8c15a9..3d239a23 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.hris +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyBenefit @@ -16,6 +17,7 @@ import com.tryfinch.api.models.HrisBenefitUpdateParams import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface BenefitServiceAsync { @@ -24,6 +26,13 @@ interface BenefitServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BenefitServiceAsync + fun individuals(): IndividualServiceAsync /** @@ -166,6 +175,15 @@ interface BenefitServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): BenefitServiceAsync.WithRawResponse + fun individuals(): IndividualServiceAsync.WithRawResponse /** 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 c21af35f..05273d48 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/BenefitServiceAsyncImpl.kt @@ -31,6 +31,7 @@ import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsync import com.tryfinch.api.services.async.hris.benefits.IndividualServiceAsyncImpl import java.util.Optional import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BenefitServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -46,6 +47,9 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): BenefitServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BenefitServiceAsync = + BenefitServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun individuals(): IndividualServiceAsync = individuals override fun create( @@ -92,6 +96,13 @@ class BenefitServiceAsyncImpl internal constructor(private val clientOptions: Cl IndividualServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): BenefitServiceAsync.WithRawResponse = + BenefitServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun individuals(): IndividualServiceAsync.WithRawResponse = individuals private val createHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt index 6eeb46cd..ca3d512f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsync.kt @@ -2,12 +2,14 @@ package com.tryfinch.api.services.async.hris +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.Company import com.tryfinch.api.models.HrisCompanyRetrieveParams import com.tryfinch.api.services.async.hris.company.PayStatementItemServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CompanyServiceAsync { @@ -16,6 +18,13 @@ interface CompanyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyServiceAsync + fun payStatementItem(): PayStatementItemServiceAsync /** Read basic company data */ @@ -41,6 +50,15 @@ interface CompanyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompanyServiceAsync.WithRawResponse + fun payStatementItem(): PayStatementItemServiceAsync.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt index ec58540b..61e667e3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/CompanyServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisCompanyRetrieveParams import com.tryfinch.api.services.async.hris.company.PayStatementItemServiceAsync import com.tryfinch.api.services.async.hris.company.PayStatementItemServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CompanyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CompanyServiceAsync { @@ -33,6 +34,9 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): CompanyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompanyServiceAsync = + CompanyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun payStatementItem(): PayStatementItemServiceAsync = payStatementItem override fun retrieve( @@ -51,6 +55,13 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl PayStatementItemServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): CompanyServiceAsync.WithRawResponse = + CompanyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun payStatementItem(): PayStatementItemServiceAsync.WithRawResponse = payStatementItem diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt index fa2b7b87..9bfba346 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.hris +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisDirectoryListIndividualsPageAsync @@ -9,6 +10,7 @@ import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPageAsync import com.tryfinch.api.models.HrisDirectoryListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface DirectoryServiceAsync { @@ -17,6 +19,13 @@ interface DirectoryServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryServiceAsync + /** Read company directory and organization structure */ fun list(): CompletableFuture = list(HrisDirectoryListParams.none()) @@ -66,6 +75,15 @@ interface DirectoryServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DirectoryServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/directory`, but is otherwise the same as * [DirectoryServiceAsync.list]. 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 da50e8de..dccddb59 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DirectoryServiceAsyncImpl.kt @@ -21,6 +21,7 @@ import com.tryfinch.api.models.HrisDirectoryListPageAsync import com.tryfinch.api.models.HrisDirectoryListPageResponse import com.tryfinch.api.models.HrisDirectoryListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DirectoryServiceAsync { @@ -31,6 +32,9 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): DirectoryServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DirectoryServiceAsync = + DirectoryServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisDirectoryListParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DirectoryServiceAsync.WithRawResponse = + DirectoryServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt index bf6a4a3b..22ffb8a9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.hris +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DocumentListResponse @@ -9,6 +10,7 @@ import com.tryfinch.api.models.DocumentRetreiveResponse import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface DocumentServiceAsync { @@ -17,6 +19,13 @@ interface DocumentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DocumentServiceAsync + /** * **Beta:** This endpoint is in beta and may change. Retrieve a list of company-wide documents. */ @@ -81,6 +90,15 @@ interface DocumentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DocumentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/documents`, but is otherwise the same as * [DocumentServiceAsync.list]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt index 23a4ea2c..24c48edb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/DocumentServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.DocumentRetreiveResponse import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class DocumentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,6 +32,9 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): DocumentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DocumentServiceAsync = + DocumentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisDocumentListParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class DocumentServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DocumentServiceAsync.WithRawResponse = + DocumentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt index aeb30c65..6ad32bab 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.hris +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageAsync import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EmploymentServiceAsync { @@ -15,6 +17,13 @@ interface EmploymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmploymentServiceAsync + /** Read individual employment and income data */ fun retrieveMany( params: HrisEmploymentRetrieveManyParams @@ -33,6 +42,15 @@ interface EmploymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmploymentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/employment`, but is otherwise the same as * [EmploymentServiceAsync.retrieveMany]. 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 3de05962..22d9baa8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/EmploymentServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageAsync import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageResponse import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : EmploymentServiceAsync { @@ -29,6 +30,9 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): EmploymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmploymentServiceAsync = + EmploymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisEmploymentRetrieveManyParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmploymentServiceAsync.WithRawResponse = + EmploymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt index 04e8c2f7..e05abbc3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.hris +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisIndividualRetrieveManyPageAsync import com.tryfinch.api.models.HrisIndividualRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface IndividualServiceAsync { @@ -15,6 +17,13 @@ interface IndividualServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualServiceAsync + /** Read individual data, excluding income and employment data */ fun retrieveMany(): CompletableFuture = retrieveMany(HrisIndividualRetrieveManyParams.none()) @@ -43,6 +52,15 @@ interface IndividualServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/individual`, but is otherwise the same as * [IndividualServiceAsync.retrieveMany]. 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 b5e0c64d..1d4cc4fd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/IndividualServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisIndividualRetrieveManyPageAsync import com.tryfinch.api.models.HrisIndividualRetrieveManyPageResponse import com.tryfinch.api.models.HrisIndividualRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : IndividualServiceAsync { @@ -29,6 +30,9 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): IndividualServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualServiceAsync = + IndividualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisIndividualRetrieveManyParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse = + IndividualServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt index f500d3e4..586f6283 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.hris +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageAsync import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PayStatementServiceAsync { @@ -15,6 +17,13 @@ interface PayStatementServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayStatementServiceAsync + /** * Read detailed pay statements for each individual. * @@ -37,6 +46,15 @@ interface PayStatementServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayStatementServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/pay-statement`, but is otherwise the same * as [PayStatementServiceAsync.retrieveMany]. 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 9c47d1ab..bee508d7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PayStatementServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageAsync import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageResponse import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class PayStatementServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PayStatementServiceAsync { @@ -29,6 +30,9 @@ class PayStatementServiceAsyncImpl internal constructor(private val clientOption override fun withRawResponse(): PayStatementServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayStatementServiceAsync = + PayStatementServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisPayStatementRetrieveManyParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class PayStatementServiceAsyncImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PayStatementServiceAsync.WithRawResponse = + PayStatementServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt index fd439bf5..fb6012e9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.hris +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPaymentListPageAsync import com.tryfinch.api.models.HrisPaymentListParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PaymentServiceAsync { @@ -15,6 +17,13 @@ interface PaymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentServiceAsync + /** Read payroll and contractor related payments by the company. */ fun list(params: HrisPaymentListParams): CompletableFuture = list(params, RequestOptions.none()) @@ -30,6 +39,15 @@ interface PaymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PaymentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/payment`, but is otherwise the same as * [PaymentServiceAsync.list]. 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 bbe1b4d5..afd34eef 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/PaymentServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.models.HrisPaymentListPageAsync import com.tryfinch.api.models.HrisPaymentListParams import com.tryfinch.api.models.Payment import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class PaymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PaymentServiceAsync { @@ -28,6 +29,9 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): PaymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PaymentServiceAsync = + PaymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisPaymentListParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PaymentServiceAsync.WithRawResponse = + PaymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt index 37349762..691053a3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.hris.benefits +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams @@ -11,6 +12,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface IndividualServiceAsync { @@ -19,6 +21,13 @@ interface IndividualServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualServiceAsync + /** Lists individuals currently enrolled in a given deduction. */ fun enrolledIds(benefitId: String): CompletableFuture = enrolledIds(benefitId, HrisBenefitIndividualEnrolledIdsParams.none()) @@ -150,6 +159,15 @@ interface IndividualServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/enrolled`, but is * otherwise the same as [IndividualServiceAsync.enrolledIds]. 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 c8efa8f9..e78ec6a1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/benefits/IndividualServiceAsyncImpl.kt @@ -24,6 +24,7 @@ import com.tryfinch.api.models.IndividualBenefit import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -35,6 +36,9 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): IndividualServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualServiceAsync = + IndividualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams, requestOptions: RequestOptions, @@ -61,6 +65,13 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse = + IndividualServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val enrolledIdsHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt index 6af3fb5b..939e8743 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsync.kt @@ -2,12 +2,14 @@ package com.tryfinch.api.services.async.hris.company +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemListPageAsync import com.tryfinch.api.models.HrisCompanyPayStatementItemListParams import com.tryfinch.api.services.async.hris.company.payStatementItem.RuleServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PayStatementItemServiceAsync { @@ -16,6 +18,13 @@ interface PayStatementItemServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayStatementItemServiceAsync + fun rules(): RuleServiceAsync /** @@ -51,6 +60,15 @@ interface PayStatementItemServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayStatementItemServiceAsync.WithRawResponse + fun rules(): RuleServiceAsync.WithRawResponse /** 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 3f8e1b2f..6839e175 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/PayStatementItemServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.HrisCompanyPayStatementItemListParams import com.tryfinch.api.services.async.hris.company.payStatementItem.RuleServiceAsync import com.tryfinch.api.services.async.hris.company.payStatementItem.RuleServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class PayStatementItemServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PayStatementItemServiceAsync { @@ -32,6 +33,11 @@ internal constructor(private val clientOptions: ClientOptions) : PayStatementIte override fun withRawResponse(): PayStatementItemServiceAsync.WithRawResponse = withRawResponse + override fun withOptions( + modifier: Consumer + ): PayStatementItemServiceAsync = + PayStatementItemServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun rules(): RuleServiceAsync = rules override fun list( @@ -50,6 +56,13 @@ internal constructor(private val clientOptions: ClientOptions) : PayStatementIte RuleServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): PayStatementItemServiceAsync.WithRawResponse = + PayStatementItemServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun rules(): RuleServiceAsync.WithRawResponse = rules private val listHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt index ff332b44..6fa6af04 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.hris.company.payStatementItem +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleCreateParams @@ -13,6 +14,7 @@ import com.tryfinch.api.models.RuleCreateResponse import com.tryfinch.api.models.RuleDeleteResponse import com.tryfinch.api.models.RuleUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface RuleServiceAsync { @@ -21,6 +23,13 @@ interface RuleServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleServiceAsync + /** * **Beta:** this endpoint currently serves employers onboarded after March 4th and historical * support will be added soon Custom rules can be created to associate specific attributes to @@ -160,6 +169,13 @@ interface RuleServiceAsync { /** A view of [RuleServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/pay-statement-item/rule`, but is * otherwise the same as [RuleServiceAsync.create]. 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 0a934508..376f8892 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/hris/company/payStatementItem/RuleServiceAsyncImpl.kt @@ -26,6 +26,7 @@ import com.tryfinch.api.models.RuleCreateResponse import com.tryfinch.api.models.RuleDeleteResponse import com.tryfinch.api.models.RuleUpdateResponse import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class RuleServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -37,6 +38,9 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): RuleServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RuleServiceAsync = + RuleServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: HrisCompanyPayStatementItemRuleCreateParams, requestOptions: RequestOptions, @@ -70,6 +74,13 @@ class RuleServiceAsyncImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RuleServiceAsync.WithRawResponse = + RuleServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt index 2d46e589..d6854525 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.jobs +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AutomatedAsyncJob @@ -11,6 +12,7 @@ import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AutomatedServiceAsync { @@ -19,6 +21,13 @@ interface AutomatedServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AutomatedServiceAsync + /** * Enqueue an automated job. * @@ -114,6 +123,15 @@ interface AutomatedServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AutomatedServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /jobs/automated`, but is otherwise the same as * [AutomatedServiceAsync.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt index ddf559e7..da95121d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/AutomatedServiceAsyncImpl.kt @@ -23,6 +23,7 @@ import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): AutomatedServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AutomatedServiceAsync = + AutomatedServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: JobAutomatedCreateParams, requestOptions: RequestOptions, @@ -60,6 +64,13 @@ class AutomatedServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AutomatedServiceAsync.WithRawResponse = + AutomatedServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt index 2d0e0e00..a7cdb0bf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.jobs +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ManualServiceAsync { @@ -15,6 +17,13 @@ interface ManualServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ManualServiceAsync + /** * Get a manual job by `job_id`. Manual jobs are completed by a human and include Assisted * Benefits jobs. @@ -55,6 +64,15 @@ interface ManualServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ManualServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /jobs/manual/{job_id}`, but is otherwise the same as * [ManualServiceAsync.retrieve]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt index d10dce02..a7f58b32 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/jobs/ManualServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ManualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class ManualServiceAsyncImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): ManualServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ManualServiceAsync = + ManualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: JobManualRetrieveParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class ManualServiceAsyncImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ManualServiceAsync.WithRawResponse = + ManualServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt index 7dffeec5..02e5f8a8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.payroll +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PayGroupRetrieveResponse @@ -9,6 +10,7 @@ import com.tryfinch.api.models.PayrollPayGroupListPageAsync import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PayGroupServiceAsync { @@ -17,6 +19,13 @@ interface PayGroupServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayGroupServiceAsync + /** Read information from a single pay group */ fun retrieve(payGroupId: String): CompletableFuture = retrieve(payGroupId, PayrollPayGroupRetrieveParams.none()) @@ -78,6 +87,15 @@ interface PayGroupServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayGroupServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/pay-groups/{pay_group_id}`, but is * otherwise the same as [PayGroupServiceAsync.retrieve]. 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 868eb735..fcbee564 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/payroll/PayGroupServiceAsyncImpl.kt @@ -21,6 +21,7 @@ import com.tryfinch.api.models.PayrollPayGroupListPageAsync import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -32,6 +33,9 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C override fun withRawResponse(): PayGroupServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayGroupServiceAsync = + PayGroupServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: PayrollPayGroupRetrieveParams, requestOptions: RequestOptions, @@ -51,6 +55,13 @@ class PayGroupServiceAsyncImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PayGroupServiceAsync.WithRawResponse = + PayGroupServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt index c0a59b23..5a8a0f05 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.sandbox +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface CompanyServiceAsync { @@ -15,6 +17,13 @@ interface CompanyServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyServiceAsync + /** Update a sandbox company's data */ fun update(params: SandboxCompanyUpdateParams): CompletableFuture = update(params, RequestOptions.none()) @@ -30,6 +39,15 @@ interface CompanyServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CompanyServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/company`, but is otherwise the same as * [CompanyServiceAsync.update]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt index 606d2425..df0d2518 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/CompanyServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class CompanyServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : CompanyServiceAsync { @@ -28,6 +29,9 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): CompanyServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompanyServiceAsync = + CompanyServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxCompanyUpdateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class CompanyServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompanyServiceAsync.WithRawResponse = + CompanyServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt index 4a311397..a56b40d9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsync.kt @@ -2,12 +2,14 @@ package com.tryfinch.api.services.async.sandbox +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectionCreateResponse import com.tryfinch.api.models.SandboxConnectionCreateParams import com.tryfinch.api.services.async.sandbox.connections.AccountServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ConnectionServiceAsync { @@ -16,6 +18,13 @@ interface ConnectionServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectionServiceAsync + fun accounts(): AccountServiceAsync /** Create a new connection (new company/provider pair) with a new account */ @@ -34,6 +43,15 @@ interface ConnectionServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConnectionServiceAsync.WithRawResponse + fun accounts(): AccountServiceAsync.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt index af1dc997..3faa4d60 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/ConnectionServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.SandboxConnectionCreateParams import com.tryfinch.api.services.async.sandbox.connections.AccountServiceAsync import com.tryfinch.api.services.async.sandbox.connections.AccountServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ConnectionServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ConnectionServiceAsync { @@ -32,6 +33,9 @@ class ConnectionServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): ConnectionServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConnectionServiceAsync = + ConnectionServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun accounts(): AccountServiceAsync = accounts override fun create( @@ -50,6 +54,13 @@ class ConnectionServiceAsyncImpl internal constructor(private val clientOptions: AccountServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConnectionServiceAsync.WithRawResponse = + ConnectionServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun accounts(): AccountServiceAsync.WithRawResponse = accounts private val createHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt index b85d5326..9068bce6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.sandbox +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DirectoryCreateResponse import com.tryfinch.api.models.SandboxDirectoryCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface DirectoryServiceAsync { @@ -15,6 +17,13 @@ interface DirectoryServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryServiceAsync + /** Add new individuals to a sandbox company */ fun create(): CompletableFuture> = create(SandboxDirectoryCreateParams.none()) @@ -39,6 +48,15 @@ interface DirectoryServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): DirectoryServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/directory`, but is otherwise the same as * [DirectoryServiceAsync.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt index 39099319..678bcd63 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/DirectoryServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.DirectoryCreateResponse import com.tryfinch.api.models.SandboxDirectoryCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : DirectoryServiceAsync { @@ -28,6 +29,9 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): DirectoryServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DirectoryServiceAsync = + DirectoryServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxDirectoryCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class DirectoryServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DirectoryServiceAsync.WithRawResponse = + DirectoryServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt index 2789998e..e025f5a1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.sandbox +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface EmploymentServiceAsync { @@ -15,6 +17,13 @@ interface EmploymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmploymentServiceAsync + /** Update sandbox employment */ fun update(individualId: String): CompletableFuture = update(individualId, SandboxEmploymentUpdateParams.none()) @@ -57,6 +66,15 @@ interface EmploymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmploymentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/employment/{individual_id}`, but is * otherwise the same as [EmploymentServiceAsync.update]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt index dde50650..f2094734 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/EmploymentServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): EmploymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmploymentServiceAsync = + EmploymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxEmploymentUpdateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class EmploymentServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmploymentServiceAsync.WithRawResponse = + EmploymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt index 503a8a59..f91b34e6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.sandbox +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface IndividualServiceAsync { @@ -15,6 +17,13 @@ interface IndividualServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualServiceAsync + /** Update sandbox individual */ fun update(individualId: String): CompletableFuture = update(individualId, SandboxIndividualUpdateParams.none()) @@ -57,6 +66,15 @@ interface IndividualServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/individual/{individual_id}`, but is * otherwise the same as [IndividualServiceAsync.update]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt index 30031709..8b3777eb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/IndividualServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class IndividualServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: override fun withRawResponse(): IndividualServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualServiceAsync = + IndividualServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxIndividualUpdateParams, requestOptions: RequestOptions, @@ -42,6 +46,13 @@ class IndividualServiceAsyncImpl internal constructor(private val clientOptions: private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualServiceAsync.WithRawResponse = + IndividualServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt index 62432ff8..30011030 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsync.kt @@ -2,12 +2,14 @@ package com.tryfinch.api.services.async.sandbox +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobCreateResponse import com.tryfinch.api.models.SandboxJobCreateParams import com.tryfinch.api.services.async.sandbox.jobs.ConfigurationServiceAsync import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface JobServiceAsync { @@ -16,6 +18,13 @@ interface JobServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync + fun configuration(): ConfigurationServiceAsync /** Enqueue a new sandbox job */ @@ -31,6 +40,13 @@ interface JobServiceAsync { /** A view of [JobServiceAsync] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobServiceAsync.WithRawResponse + fun configuration(): ConfigurationServiceAsync.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt index c9924ec5..701f75e3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/JobServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.SandboxJobCreateParams import com.tryfinch.api.services.async.sandbox.jobs.ConfigurationServiceAsync import com.tryfinch.api.services.async.sandbox.jobs.ConfigurationServiceAsyncImpl import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class JobServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : JobServiceAsync { @@ -34,6 +35,9 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): JobServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobServiceAsync = + JobServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun configuration(): ConfigurationServiceAsync = configuration override fun create( @@ -52,6 +56,13 @@ class JobServiceAsyncImpl internal constructor(private val clientOptions: Client ConfigurationServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobServiceAsync.WithRawResponse = + JobServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun configuration(): ConfigurationServiceAsync.WithRawResponse = configuration private val createHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt index b2d0c98c..b1668fdb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsync.kt @@ -2,11 +2,13 @@ package com.tryfinch.api.services.async.sandbox +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface PaymentServiceAsync { @@ -15,6 +17,13 @@ interface PaymentServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentServiceAsync + /** Add a new sandbox payment */ fun create(): CompletableFuture = create(SandboxPaymentCreateParams.none()) @@ -39,6 +48,15 @@ interface PaymentServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PaymentServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/payment`, but is otherwise the same as * [PaymentServiceAsync.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt index 337e52df..f18555ce 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/PaymentServiceAsyncImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepareAsync import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class PaymentServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : PaymentServiceAsync { @@ -28,6 +29,9 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): PaymentServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PaymentServiceAsync = + PaymentServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxPaymentCreateParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class PaymentServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PaymentServiceAsync.WithRawResponse = + PaymentServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt index 2e7483b7..1afa9577 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsync.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.async.sandbox.connections +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountCreateResponse @@ -9,6 +10,7 @@ import com.tryfinch.api.models.AccountUpdateResponse import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface AccountServiceAsync { @@ -17,6 +19,13 @@ interface AccountServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountServiceAsync + /** Create a new account for an existing connection (company/provider pair) */ fun create( params: SandboxConnectionAccountCreateParams @@ -55,6 +64,15 @@ interface AccountServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/connections/accounts`, but is otherwise * the same as [AccountServiceAsync.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt index 919b3e43..a81cdad1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/connections/AccountServiceAsyncImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.AccountUpdateResponse import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class AccountServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : AccountServiceAsync { @@ -30,6 +31,9 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): AccountServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccountServiceAsync = + AccountServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxConnectionAccountCreateParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class AccountServiceAsyncImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccountServiceAsync.WithRawResponse = + AccountServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt index 77dfa8c7..bbacb035 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsync.kt @@ -2,12 +2,14 @@ package com.tryfinch.api.services.async.sandbox.jobs +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer interface ConfigurationServiceAsync { @@ -16,6 +18,13 @@ interface ConfigurationServiceAsync { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigurationServiceAsync + /** Get configurations for sandbox jobs */ fun retrieve(): CompletableFuture> = retrieve(SandboxJobConfigurationRetrieveParams.none()) @@ -53,6 +62,15 @@ interface ConfigurationServiceAsync { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConfigurationServiceAsync.WithRawResponse + /** * Returns a raw HTTP response for `get /sandbox/jobs/configuration`, but is otherwise the * same as [ConfigurationServiceAsync.retrieve]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt index 34922267..510717f3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/async/sandbox/jobs/ConfigurationServiceAsyncImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams import java.util.concurrent.CompletableFuture +import java.util.function.Consumer class ConfigurationServiceAsyncImpl internal constructor(private val clientOptions: ClientOptions) : ConfigurationServiceAsync { @@ -29,6 +30,9 @@ class ConfigurationServiceAsyncImpl internal constructor(private val clientOptio override fun withRawResponse(): ConfigurationServiceAsync.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConfigurationServiceAsync = + ConfigurationServiceAsyncImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: SandboxJobConfigurationRetrieveParams, requestOptions: RequestOptions, @@ -48,6 +52,13 @@ class ConfigurationServiceAsyncImpl internal constructor(private val clientOptio private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ConfigurationServiceAsync.WithRawResponse = + ConfigurationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenService.kt index 0a0b9cf5..c927481f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse +import java.util.function.Consumer interface AccessTokenService { @@ -15,6 +17,13 @@ interface AccessTokenService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccessTokenService + /** Exchange the authorization code for an access token */ fun create(params: AccessTokenCreateParams): CreateAccessTokenResponse = create(params, RequestOptions.none()) @@ -30,6 +39,15 @@ interface AccessTokenService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): AccessTokenService.WithRawResponse + /** * Returns a raw HTTP response for `post /auth/token`, but is otherwise the same as * [AccessTokenService.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt index 917174ce..437cc9c3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccessTokenServiceImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.errors.FinchException import com.tryfinch.api.models.AccessTokenCreateParams import com.tryfinch.api.models.CreateAccessTokenResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AccessTokenServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli override fun withRawResponse(): AccessTokenService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccessTokenService = + AccessTokenServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: AccessTokenCreateParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class AccessTokenServiceImpl internal constructor(private val clientOptions: Cli private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccessTokenService.WithRawResponse = + AccessTokenServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt index 9247468f..67064bbd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection +import java.util.function.Consumer interface AccountService { @@ -17,6 +19,13 @@ interface AccountService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountService + /** Disconnect one or more `access_token`s from your application. */ fun disconnect(): DisconnectResponse = disconnect(AccountDisconnectParams.none()) @@ -56,6 +65,13 @@ interface AccountService { /** A view of [AccountService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountService.WithRawResponse + /** * Returns a raw HTTP response for `post /disconnect`, but is otherwise the same as * [AccountService.disconnect]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt index 754420d1..0423e3e8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/AccountServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.AccountDisconnectParams import com.tryfinch.api.models.AccountIntrospectParams import com.tryfinch.api.models.DisconnectResponse import com.tryfinch.api.models.Introspection +import java.util.function.Consumer class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : AccountService { @@ -29,6 +30,9 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): AccountService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccountService = + AccountServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun disconnect( params: AccountDisconnectParams, requestOptions: RequestOptions, @@ -48,6 +52,13 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccountService.WithRawResponse = + AccountServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val disconnectHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectService.kt index 5ac1c0d8..911e7b34 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectService.kt @@ -2,7 +2,9 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.connect.SessionService +import java.util.function.Consumer interface ConnectService { @@ -11,11 +13,25 @@ interface ConnectService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectService + fun sessions(): SessionService /** A view of [ConnectService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectService.WithRawResponse + fun sessions(): SessionService.WithRawResponse } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectServiceImpl.kt index 762f16c3..85c5a244 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ConnectServiceImpl.kt @@ -5,6 +5,7 @@ package com.tryfinch.api.services.blocking import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.connect.SessionService import com.tryfinch.api.services.blocking.connect.SessionServiceImpl +import java.util.function.Consumer class ConnectServiceImpl internal constructor(private val clientOptions: ClientOptions) : ConnectService { @@ -17,6 +18,9 @@ class ConnectServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): ConnectService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConnectService = + ConnectServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun sessions(): SessionService = sessions class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class ConnectServiceImpl internal constructor(private val clientOptions: ClientO SessionServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConnectService.WithRawResponse = + ConnectServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun sessions(): SessionService.WithRawResponse = sessions } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisService.kt index eae9dfe1..b8fc7d38 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisService.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.hris.BenefitService import com.tryfinch.api.services.blocking.hris.CompanyService import com.tryfinch.api.services.blocking.hris.DirectoryService @@ -10,6 +11,7 @@ import com.tryfinch.api.services.blocking.hris.EmploymentService import com.tryfinch.api.services.blocking.hris.IndividualService import com.tryfinch.api.services.blocking.hris.PayStatementService import com.tryfinch.api.services.blocking.hris.PaymentService +import java.util.function.Consumer interface HrisService { @@ -18,6 +20,13 @@ interface HrisService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HrisService + fun company(): CompanyService fun directory(): DirectoryService @@ -37,6 +46,13 @@ interface HrisService { /** A view of [HrisService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): HrisService.WithRawResponse + fun company(): CompanyService.WithRawResponse fun directory(): DirectoryService.WithRawResponse diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisServiceImpl.kt index 15fd8b2e..0ace050b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/HrisServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.services.blocking.hris.PayStatementService import com.tryfinch.api.services.blocking.hris.PayStatementServiceImpl import com.tryfinch.api.services.blocking.hris.PaymentService import com.tryfinch.api.services.blocking.hris.PaymentServiceImpl +import java.util.function.Consumer class HrisServiceImpl internal constructor(private val clientOptions: ClientOptions) : HrisService { @@ -46,6 +47,9 @@ class HrisServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): HrisService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): HrisService = + HrisServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun company(): CompanyService = company override fun directory(): DirectoryService = directory @@ -97,6 +101,13 @@ class HrisServiceImpl internal constructor(private val clientOptions: ClientOpti BenefitServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): HrisService.WithRawResponse = + HrisServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun company(): CompanyService.WithRawResponse = company override fun directory(): DirectoryService.WithRawResponse = directory diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobService.kt index 09461d9d..1f72c6c8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobService.kt @@ -2,8 +2,10 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.jobs.AutomatedService import com.tryfinch.api.services.blocking.jobs.ManualService +import java.util.function.Consumer interface JobService { @@ -12,6 +14,13 @@ interface JobService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService + fun automated(): AutomatedService fun manual(): ManualService @@ -19,6 +28,13 @@ interface JobService { /** A view of [JobService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService.WithRawResponse + fun automated(): AutomatedService.WithRawResponse fun manual(): ManualService.WithRawResponse diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobServiceImpl.kt index bd836478..ff34cf39 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/JobServiceImpl.kt @@ -7,6 +7,7 @@ import com.tryfinch.api.services.blocking.jobs.AutomatedService import com.tryfinch.api.services.blocking.jobs.AutomatedServiceImpl import com.tryfinch.api.services.blocking.jobs.ManualService import com.tryfinch.api.services.blocking.jobs.ManualServiceImpl +import java.util.function.Consumer class JobServiceImpl internal constructor(private val clientOptions: ClientOptions) : JobService { @@ -20,6 +21,9 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): JobService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobService = + JobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun automated(): AutomatedService = automated override fun manual(): ManualService = manual @@ -35,6 +39,13 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio ManualServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobService.WithRawResponse = + JobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun automated(): AutomatedService.WithRawResponse = automated override fun manual(): ManualService.WithRawResponse = manual diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollService.kt index 872b220a..dd191ae0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollService.kt @@ -2,7 +2,9 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.payroll.PayGroupService +import java.util.function.Consumer interface PayrollService { @@ -11,11 +13,25 @@ interface PayrollService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayrollService + fun payGroups(): PayGroupService /** A view of [PayrollService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayrollService.WithRawResponse + fun payGroups(): PayGroupService.WithRawResponse } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollServiceImpl.kt index f3e89397..dc8e8e9f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/PayrollServiceImpl.kt @@ -5,6 +5,7 @@ package com.tryfinch.api.services.blocking import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.payroll.PayGroupService import com.tryfinch.api.services.blocking.payroll.PayGroupServiceImpl +import java.util.function.Consumer class PayrollServiceImpl internal constructor(private val clientOptions: ClientOptions) : PayrollService { @@ -17,6 +18,9 @@ class PayrollServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): PayrollService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayrollService = + PayrollServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun payGroups(): PayGroupService = payGroups class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : @@ -26,6 +30,13 @@ class PayrollServiceImpl internal constructor(private val clientOptions: ClientO PayGroupServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): PayrollService.WithRawResponse = + PayrollServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun payGroups(): PayGroupService.WithRawResponse = payGroups } } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderService.kt index 92ef210e..a2c68ded 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ProviderListPage import com.tryfinch.api.models.ProviderListParams +import java.util.function.Consumer interface ProviderService { @@ -15,6 +17,13 @@ interface ProviderService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderService + /** Return details on all available payroll and HR systems. */ fun list(): ProviderListPage = list(ProviderListParams.none()) @@ -35,6 +44,13 @@ interface ProviderService { /** A view of [ProviderService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ProviderService.WithRawResponse + /** * Returns a raw HTTP response for `get /providers`, but is otherwise the same as * [ProviderService.list]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt index 3d0ed347..dfb4ba66 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/ProviderServiceImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.Provider import com.tryfinch.api.models.ProviderListPage import com.tryfinch.api.models.ProviderListParams +import java.util.function.Consumer class ProviderServiceImpl internal constructor(private val clientOptions: ClientOptions) : ProviderService { @@ -27,6 +28,9 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): ProviderService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ProviderService = + ProviderServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: ProviderListParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class ProviderServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ProviderService.WithRawResponse = + ProviderServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingService.kt index 2d29034b..a180b608 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse +import java.util.function.Consumer interface RequestForwardingService { @@ -15,6 +17,13 @@ interface RequestForwardingService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RequestForwardingService + /** * The Forward API allows you to make direct requests to an employment system. If Finch’s * unified API doesn’t have a data model that cleanly fits your needs, then Forward allows you @@ -35,6 +44,15 @@ interface RequestForwardingService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): RequestForwardingService.WithRawResponse + /** * Returns a raw HTTP response for `post /forward`, but is otherwise the same as * [RequestForwardingService.forward]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt index dadeff29..51c3a9c7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.RequestForwardingForwardParams import com.tryfinch.api.models.RequestForwardingForwardResponse +import java.util.function.Consumer class RequestForwardingServiceImpl internal constructor(private val clientOptions: ClientOptions) : RequestForwardingService { @@ -27,6 +28,9 @@ class RequestForwardingServiceImpl internal constructor(private val clientOption override fun withRawResponse(): RequestForwardingService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RequestForwardingService = + RequestForwardingServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun forward( params: RequestForwardingForwardParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class RequestForwardingServiceImpl internal constructor(private val clientOption private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RequestForwardingService.WithRawResponse = + RequestForwardingServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val forwardHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxService.kt index 413e04e5..53ad137c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxService.kt @@ -2,6 +2,7 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.services.blocking.sandbox.CompanyService import com.tryfinch.api.services.blocking.sandbox.ConnectionService import com.tryfinch.api.services.blocking.sandbox.DirectoryService @@ -9,6 +10,7 @@ import com.tryfinch.api.services.blocking.sandbox.EmploymentService import com.tryfinch.api.services.blocking.sandbox.IndividualService import com.tryfinch.api.services.blocking.sandbox.JobService import com.tryfinch.api.services.blocking.sandbox.PaymentService +import java.util.function.Consumer interface SandboxService { @@ -17,6 +19,13 @@ interface SandboxService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SandboxService + fun connections(): ConnectionService fun company(): CompanyService @@ -34,6 +43,13 @@ interface SandboxService { /** A view of [SandboxService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SandboxService.WithRawResponse + fun connections(): ConnectionService.WithRawResponse fun company(): CompanyService.WithRawResponse diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxServiceImpl.kt index a52a4ba6..69c45bcc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/SandboxServiceImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.services.blocking.sandbox.JobService import com.tryfinch.api.services.blocking.sandbox.JobServiceImpl import com.tryfinch.api.services.blocking.sandbox.PaymentService import com.tryfinch.api.services.blocking.sandbox.PaymentServiceImpl +import java.util.function.Consumer class SandboxServiceImpl internal constructor(private val clientOptions: ClientOptions) : SandboxService { @@ -41,6 +42,9 @@ class SandboxServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): SandboxService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SandboxService = + SandboxServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun connections(): ConnectionService = connections override fun company(): CompanyService = company @@ -86,6 +90,13 @@ class SandboxServiceImpl internal constructor(private val clientOptions: ClientO JobServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): SandboxService.WithRawResponse = + SandboxServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun connections(): ConnectionService.WithRawResponse = connections override fun company(): CompanyService.WithRawResponse = company diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookService.kt index a4236a2e..98bb6c85 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookService.kt @@ -2,11 +2,20 @@ package com.tryfinch.api.services.blocking +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.http.Headers import com.tryfinch.api.models.WebhookEvent +import java.util.function.Consumer interface WebhookService { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): WebhookService + fun unwrap(payload: String, headers: Headers, secret: String?): WebhookEvent fun verifySignature(payload: String, headers: Headers, secret: String?) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookServiceImpl.kt index 88069c27..e1e26fdb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/WebhookServiceImpl.kt @@ -12,6 +12,7 @@ import java.security.MessageDigest import java.time.Duration import java.time.Instant import java.util.Base64 +import java.util.function.Consumer import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec import kotlin.jvm.optionals.getOrNull @@ -19,6 +20,9 @@ import kotlin.jvm.optionals.getOrNull class WebhookServiceImpl internal constructor(private val clientOptions: ClientOptions) : WebhookService { + override fun withOptions(modifier: Consumer): WebhookService = + WebhookServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun unwrap(payload: String, headers: Headers, secret: String?): WebhookEvent { verifySignature(payload, headers, secret) return try { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt index ba280313..7ca4c307 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.connect import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse +import java.util.function.Consumer interface SessionService { @@ -17,6 +19,13 @@ interface SessionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SessionService + /** Create a new connect session for an employer */ fun new_(params: ConnectSessionNewParams): SessionNewResponse = new_(params, RequestOptions.none()) @@ -40,6 +49,13 @@ interface SessionService { /** A view of [SessionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): SessionService.WithRawResponse + /** * Returns a raw HTTP response for `post /connect/sessions`, but is otherwise the same as * [SessionService.new_]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt index ec591a30..3a470a8c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/connect/SessionServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.ConnectSessionNewParams import com.tryfinch.api.models.ConnectSessionReauthenticateParams import com.tryfinch.api.models.SessionNewResponse import com.tryfinch.api.models.SessionReauthenticateResponse +import java.util.function.Consumer class SessionServiceImpl internal constructor(private val clientOptions: ClientOptions) : SessionService { @@ -29,6 +30,9 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): SessionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): SessionService = + SessionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun new_( params: ConnectSessionNewParams, requestOptions: RequestOptions, @@ -48,6 +52,13 @@ class SessionServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): SessionService.WithRawResponse = + SessionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val newHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt index 43c93d72..5cda4c26 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitService.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyBenefit @@ -16,6 +17,7 @@ import com.tryfinch.api.models.HrisBenefitRetrieveParams import com.tryfinch.api.models.HrisBenefitUpdateParams import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.blocking.hris.benefits.IndividualService +import java.util.function.Consumer interface BenefitService { @@ -24,6 +26,13 @@ interface BenefitService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BenefitService + fun individuals(): IndividualService /** @@ -153,6 +162,13 @@ interface BenefitService { /** A view of [BenefitService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): BenefitService.WithRawResponse + fun individuals(): IndividualService.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt index 616637b0..407c88c5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/BenefitServiceImpl.kt @@ -30,6 +30,7 @@ import com.tryfinch.api.models.UpdateCompanyBenefitResponse import com.tryfinch.api.services.blocking.hris.benefits.IndividualService import com.tryfinch.api.services.blocking.hris.benefits.IndividualServiceImpl import java.util.Optional +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class BenefitServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -43,6 +44,9 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): BenefitService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): BenefitService = + BenefitServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun individuals(): IndividualService = individuals override fun create( @@ -89,6 +93,13 @@ class BenefitServiceImpl internal constructor(private val clientOptions: ClientO IndividualServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): BenefitService.WithRawResponse = + BenefitServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun individuals(): IndividualService.WithRawResponse = individuals private val createHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyService.kt index 82ff7c15..befdb985 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.Company import com.tryfinch.api.models.HrisCompanyRetrieveParams import com.tryfinch.api.services.blocking.hris.company.PayStatementItemService +import java.util.function.Consumer interface CompanyService { @@ -16,6 +18,13 @@ interface CompanyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyService + fun payStatementItem(): PayStatementItemService /** Read basic company data */ @@ -38,6 +47,13 @@ interface CompanyService { /** A view of [CompanyService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyService.WithRawResponse + fun payStatementItem(): PayStatementItemService.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt index 3f796652..0e99459f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/CompanyServiceImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.models.Company import com.tryfinch.api.models.HrisCompanyRetrieveParams import com.tryfinch.api.services.blocking.hris.company.PayStatementItemService import com.tryfinch.api.services.blocking.hris.company.PayStatementItemServiceImpl +import java.util.function.Consumer class CompanyServiceImpl internal constructor(private val clientOptions: ClientOptions) : CompanyService { @@ -32,6 +33,9 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): CompanyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompanyService = + CompanyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun payStatementItem(): PayStatementItemService = payStatementItem override fun retrieve( @@ -50,6 +54,13 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO PayStatementItemServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): CompanyService.WithRawResponse = + CompanyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun payStatementItem(): PayStatementItemService.WithRawResponse = payStatementItem private val retrieveHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt index dc9adbd0..6fb6faf4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisDirectoryListIndividualsPage import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPage import com.tryfinch.api.models.HrisDirectoryListParams +import java.util.function.Consumer interface DirectoryService { @@ -17,6 +19,13 @@ interface DirectoryService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryService + /** Read company directory and organization structure */ fun list(): HrisDirectoryListPage = list(HrisDirectoryListParams.none()) @@ -61,6 +70,13 @@ interface DirectoryService { /** A view of [DirectoryService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/directory`, but is otherwise the same as * [DirectoryService.list]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt index 1177fa88..7a66cfad 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DirectoryServiceImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.HrisDirectoryListIndividualsParams import com.tryfinch.api.models.HrisDirectoryListPage import com.tryfinch.api.models.HrisDirectoryListPageResponse import com.tryfinch.api.models.HrisDirectoryListParams +import java.util.function.Consumer class DirectoryServiceImpl internal constructor(private val clientOptions: ClientOptions) : DirectoryService { @@ -30,6 +31,9 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): DirectoryService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DirectoryService = + DirectoryServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisDirectoryListParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DirectoryService.WithRawResponse = + DirectoryServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentService.kt index 0fb3dc39..1e34a568 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DocumentListResponse import com.tryfinch.api.models.DocumentRetreiveResponse import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams +import java.util.function.Consumer interface DocumentService { @@ -17,6 +19,13 @@ interface DocumentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DocumentService + /** * **Beta:** This endpoint is in beta and may change. Retrieve a list of company-wide documents. */ @@ -74,6 +83,13 @@ interface DocumentService { /** A view of [DocumentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DocumentService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/documents`, but is otherwise the same as * [DocumentService.list]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt index 0eda2c82..f1e8b7b3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/DocumentServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.DocumentListResponse import com.tryfinch.api.models.DocumentRetreiveResponse import com.tryfinch.api.models.HrisDocumentListParams import com.tryfinch.api.models.HrisDocumentRetreiveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class DocumentServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -30,6 +31,9 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): DocumentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DocumentService = + DocumentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisDocumentListParams, requestOptions: RequestOptions, @@ -49,6 +53,13 @@ class DocumentServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DocumentService.WithRawResponse = + DocumentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentService.kt index e2d11244..f3842a5e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisEmploymentRetrieveManyPage import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams +import java.util.function.Consumer interface EmploymentService { @@ -15,6 +17,13 @@ interface EmploymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmploymentService + /** Read individual employment and income data */ fun retrieveMany(params: HrisEmploymentRetrieveManyParams): HrisEmploymentRetrieveManyPage = retrieveMany(params, RequestOptions.none()) @@ -28,6 +37,15 @@ interface EmploymentService { /** A view of [EmploymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmploymentService.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/employment`, but is otherwise the same as * [EmploymentService.retrieveMany]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt index dc8a9559..dcafefc2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/EmploymentServiceImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisEmploymentRetrieveManyPage import com.tryfinch.api.models.HrisEmploymentRetrieveManyPageResponse import com.tryfinch.api.models.HrisEmploymentRetrieveManyParams +import java.util.function.Consumer class EmploymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : EmploymentService { @@ -28,6 +29,9 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): EmploymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmploymentService = + EmploymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisEmploymentRetrieveManyParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmploymentService.WithRawResponse = + EmploymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualService.kt index fa435bf7..3b38fc15 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisIndividualRetrieveManyPage import com.tryfinch.api.models.HrisIndividualRetrieveManyParams +import java.util.function.Consumer interface IndividualService { @@ -15,6 +17,13 @@ interface IndividualService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualService + /** Read individual data, excluding income and employment data */ fun retrieveMany(): HrisIndividualRetrieveManyPage = retrieveMany(HrisIndividualRetrieveManyParams.none()) @@ -37,6 +46,15 @@ interface IndividualService { /** A view of [IndividualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/individual`, but is otherwise the same as * [IndividualService.retrieveMany]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt index 37d4b4ca..d6b74967 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/IndividualServiceImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisIndividualRetrieveManyPage import com.tryfinch.api.models.HrisIndividualRetrieveManyPageResponse import com.tryfinch.api.models.HrisIndividualRetrieveManyParams +import java.util.function.Consumer class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : IndividualService { @@ -28,6 +29,9 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): IndividualService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualService = + IndividualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisIndividualRetrieveManyParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse = + IndividualServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementService.kt index de869d8c..59692114 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPayStatementRetrieveManyPage import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams +import java.util.function.Consumer interface PayStatementService { @@ -15,6 +17,13 @@ interface PayStatementService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayStatementService + /** * Read detailed pay statements for each individual. * @@ -34,6 +43,15 @@ interface PayStatementService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayStatementService.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/pay-statement`, but is otherwise the same * as [PayStatementService.retrieveMany]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt index 01d35d76..89acf8ea 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PayStatementServiceImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisPayStatementRetrieveManyPage import com.tryfinch.api.models.HrisPayStatementRetrieveManyPageResponse import com.tryfinch.api.models.HrisPayStatementRetrieveManyParams +import java.util.function.Consumer class PayStatementServiceImpl internal constructor(private val clientOptions: ClientOptions) : PayStatementService { @@ -28,6 +29,9 @@ class PayStatementServiceImpl internal constructor(private val clientOptions: Cl override fun withRawResponse(): PayStatementService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayStatementService = + PayStatementServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieveMany( params: HrisPayStatementRetrieveManyParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class PayStatementServiceImpl internal constructor(private val clientOptions: Cl private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PayStatementService.WithRawResponse = + PayStatementServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveManyHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentService.kt index f62d1061..d72883ab 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.hris import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisPaymentListPage import com.tryfinch.api.models.HrisPaymentListParams +import java.util.function.Consumer interface PaymentService { @@ -15,6 +17,13 @@ interface PaymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentService + /** Read payroll and contractor related payments by the company. */ fun list(params: HrisPaymentListParams): HrisPaymentListPage = list(params, RequestOptions.none()) @@ -28,6 +37,13 @@ interface PaymentService { /** A view of [PaymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/payment`, but is otherwise the same as * [PaymentService.list]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt index 275d6727..67f5b3fc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/PaymentServiceImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.HrisPaymentListPage import com.tryfinch.api.models.HrisPaymentListParams import com.tryfinch.api.models.Payment +import java.util.function.Consumer class PaymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : PaymentService { @@ -27,6 +28,9 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): PaymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PaymentService = + PaymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun list( params: HrisPaymentListParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PaymentService.WithRawResponse = + PaymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val listHandler: Handler> = jsonHandler>(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt index 9a306ff3..c62cf835 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualService.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.services.blocking.hris.benefits import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisBenefitIndividualEnrolledIdsParams @@ -11,6 +12,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualRetrieveManyBenefitsParams import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse +import java.util.function.Consumer interface IndividualService { @@ -19,6 +21,13 @@ interface IndividualService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualService + /** Lists individuals currently enrolled in a given deduction. */ fun enrolledIds(benefitId: String): IndividualEnrolledIdsResponse = enrolledIds(benefitId, HrisBenefitIndividualEnrolledIdsParams.none()) @@ -141,6 +150,15 @@ interface IndividualService { /** A view of [IndividualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/benefits/{benefit_id}/enrolled`, but is * otherwise the same as [IndividualService.enrolledIds]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt index ee1e664e..92551aa3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/benefits/IndividualServiceImpl.kt @@ -23,6 +23,7 @@ import com.tryfinch.api.models.HrisBenefitIndividualUnenrollManyParams import com.tryfinch.api.models.IndividualBenefit import com.tryfinch.api.models.IndividualEnrolledIdsResponse import com.tryfinch.api.models.UnenrolledIndividualBenefitResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -34,6 +35,9 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): IndividualService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualService = + IndividualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun enrolledIds( params: HrisBenefitIndividualEnrolledIdsParams, requestOptions: RequestOptions, @@ -60,6 +64,13 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse = + IndividualServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val enrolledIdsHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemService.kt index c498a733..9b75490b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.hris.company import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemListPage import com.tryfinch.api.models.HrisCompanyPayStatementItemListParams import com.tryfinch.api.services.blocking.hris.company.payStatementItem.RuleService +import java.util.function.Consumer interface PayStatementItemService { @@ -16,6 +18,13 @@ interface PayStatementItemService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayStatementItemService + fun rules(): RuleService /** @@ -48,6 +57,15 @@ interface PayStatementItemService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): PayStatementItemService.WithRawResponse + fun rules(): RuleService.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt index c1d7e09d..63335ea0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/PayStatementItemServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.HrisCompanyPayStatementItemListPageResponse import com.tryfinch.api.models.HrisCompanyPayStatementItemListParams import com.tryfinch.api.services.blocking.hris.company.payStatementItem.RuleService import com.tryfinch.api.services.blocking.hris.company.payStatementItem.RuleServiceImpl +import java.util.function.Consumer class PayStatementItemServiceImpl internal constructor(private val clientOptions: ClientOptions) : PayStatementItemService { @@ -31,6 +32,9 @@ class PayStatementItemServiceImpl internal constructor(private val clientOptions override fun withRawResponse(): PayStatementItemService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayStatementItemService = + PayStatementItemServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun rules(): RuleService = rules override fun list( @@ -49,6 +53,13 @@ class PayStatementItemServiceImpl internal constructor(private val clientOptions RuleServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): PayStatementItemService.WithRawResponse = + PayStatementItemServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun rules(): RuleService.WithRawResponse = rules private val listHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleService.kt index 288e3791..9014d674 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleService.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.services.blocking.hris.company.payStatementItem import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleCreateParams @@ -13,6 +14,7 @@ import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleUpdateParams import com.tryfinch.api.models.RuleCreateResponse import com.tryfinch.api.models.RuleDeleteResponse import com.tryfinch.api.models.RuleUpdateResponse +import java.util.function.Consumer interface RuleService { @@ -21,6 +23,13 @@ interface RuleService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleService + /** * **Beta:** this endpoint currently serves employers onboarded after March 4th and historical * support will be added soon Custom rules can be created to associate specific attributes to @@ -146,6 +155,13 @@ interface RuleService { /** A view of [RuleService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): RuleService.WithRawResponse + /** * Returns a raw HTTP response for `post /employer/pay-statement-item/rule`, but is * otherwise the same as [RuleService.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt index 6b159099..94afdfa8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/hris/company/payStatementItem/RuleServiceImpl.kt @@ -25,6 +25,7 @@ import com.tryfinch.api.models.HrisCompanyPayStatementItemRuleUpdateParams import com.tryfinch.api.models.RuleCreateResponse import com.tryfinch.api.models.RuleDeleteResponse import com.tryfinch.api.models.RuleUpdateResponse +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class RuleServiceImpl internal constructor(private val clientOptions: ClientOptions) : RuleService { @@ -35,6 +36,9 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti override fun withRawResponse(): RuleService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): RuleService = + RuleServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: HrisCompanyPayStatementItemRuleCreateParams, requestOptions: RequestOptions, @@ -68,6 +72,13 @@ class RuleServiceImpl internal constructor(private val clientOptions: ClientOpti private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): RuleService.WithRawResponse = + RuleServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt index 4bc55fe3..ff25fa31 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedService.kt @@ -3,6 +3,7 @@ package com.tryfinch.api.services.blocking.jobs import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AutomatedAsyncJob @@ -11,6 +12,7 @@ import com.tryfinch.api.models.AutomatedListResponse import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams +import java.util.function.Consumer interface AutomatedService { @@ -19,6 +21,13 @@ interface AutomatedService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AutomatedService + /** * Enqueue an automated job. * @@ -107,6 +116,13 @@ interface AutomatedService { /** A view of [AutomatedService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AutomatedService.WithRawResponse + /** * Returns a raw HTTP response for `post /jobs/automated`, but is otherwise the same as * [AutomatedService.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt index 2e9dc8b2..029ae982 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/AutomatedServiceImpl.kt @@ -22,6 +22,7 @@ import com.tryfinch.api.models.AutomatedListResponse import com.tryfinch.api.models.JobAutomatedCreateParams import com.tryfinch.api.models.JobAutomatedListParams import com.tryfinch.api.models.JobAutomatedRetrieveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class AutomatedServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -33,6 +34,9 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): AutomatedService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AutomatedService = + AutomatedServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: JobAutomatedCreateParams, requestOptions: RequestOptions, @@ -59,6 +63,13 @@ class AutomatedServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AutomatedService.WithRawResponse = + AutomatedServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualService.kt index 4e0334df..4b375204 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.jobs import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob +import java.util.function.Consumer interface ManualService { @@ -15,6 +17,13 @@ interface ManualService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ManualService + /** * Get a manual job by `job_id`. Manual jobs are completed by a human and include Assisted * Benefits jobs. @@ -51,6 +60,13 @@ interface ManualService { /** A view of [ManualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ManualService.WithRawResponse + /** * Returns a raw HTTP response for `get /jobs/manual/{job_id}`, but is otherwise the same as * [ManualService.retrieve]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt index ceb71890..ec73e616 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/jobs/ManualServiceImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.JobManualRetrieveParams import com.tryfinch.api.models.ManualAsyncJob +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class ManualServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -28,6 +29,9 @@ class ManualServiceImpl internal constructor(private val clientOptions: ClientOp override fun withRawResponse(): ManualService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ManualService = + ManualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: JobManualRetrieveParams, requestOptions: RequestOptions, @@ -40,6 +44,13 @@ class ManualServiceImpl internal constructor(private val clientOptions: ClientOp private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ManualService.WithRawResponse = + ManualServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper).withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupService.kt index 05717f0b..cef03233 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.payroll import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PayGroupRetrieveResponse import com.tryfinch.api.models.PayrollPayGroupListPage import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams +import java.util.function.Consumer interface PayGroupService { @@ -17,6 +19,13 @@ interface PayGroupService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayGroupService + /** Read information from a single pay group */ fun retrieve(payGroupId: String): PayGroupRetrieveResponse = retrieve(payGroupId, PayrollPayGroupRetrieveParams.none()) @@ -70,6 +79,13 @@ interface PayGroupService { /** A view of [PayGroupService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PayGroupService.WithRawResponse + /** * Returns a raw HTTP response for `get /employer/pay-groups/{pay_group_id}`, but is * otherwise the same as [PayGroupService.retrieve]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt index 00b9c9db..4a0b8e4e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/payroll/PayGroupServiceImpl.kt @@ -20,6 +20,7 @@ import com.tryfinch.api.models.PayGroupRetrieveResponse import com.tryfinch.api.models.PayrollPayGroupListPage import com.tryfinch.api.models.PayrollPayGroupListParams import com.tryfinch.api.models.PayrollPayGroupRetrieveParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class PayGroupServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -31,6 +32,9 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client override fun withRawResponse(): PayGroupService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PayGroupService = + PayGroupServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: PayrollPayGroupRetrieveParams, requestOptions: RequestOptions, @@ -50,6 +54,13 @@ class PayGroupServiceImpl internal constructor(private val clientOptions: Client private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PayGroupService.WithRawResponse = + PayGroupServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyService.kt index c2f4eaf2..e01715b6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams +import java.util.function.Consumer interface CompanyService { @@ -15,6 +17,13 @@ interface CompanyService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyService + /** Update a sandbox company's data */ fun update(params: SandboxCompanyUpdateParams): CompanyUpdateResponse = update(params, RequestOptions.none()) @@ -28,6 +37,13 @@ interface CompanyService { /** A view of [CompanyService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CompanyService.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/company`, but is otherwise the same as * [CompanyService.update]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt index 0d2869c2..afc15beb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/CompanyServiceImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.CompanyUpdateResponse import com.tryfinch.api.models.SandboxCompanyUpdateParams +import java.util.function.Consumer class CompanyServiceImpl internal constructor(private val clientOptions: ClientOptions) : CompanyService { @@ -27,6 +28,9 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): CompanyService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): CompanyService = + CompanyServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxCompanyUpdateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class CompanyServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): CompanyService.WithRawResponse = + CompanyServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionService.kt index 7d3ce2c5..1cf89b9f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.ConnectionCreateResponse import com.tryfinch.api.models.SandboxConnectionCreateParams import com.tryfinch.api.services.blocking.sandbox.connections.AccountService +import java.util.function.Consumer interface ConnectionService { @@ -16,6 +18,13 @@ interface ConnectionService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConnectionService + fun accounts(): AccountService /** Create a new connection (new company/provider pair) with a new account */ @@ -31,6 +40,15 @@ interface ConnectionService { /** A view of [ConnectionService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConnectionService.WithRawResponse + fun accounts(): AccountService.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt index f9df4a88..d7dcd7d9 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/ConnectionServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.ConnectionCreateResponse import com.tryfinch.api.models.SandboxConnectionCreateParams import com.tryfinch.api.services.blocking.sandbox.connections.AccountService import com.tryfinch.api.services.blocking.sandbox.connections.AccountServiceImpl +import java.util.function.Consumer class ConnectionServiceImpl internal constructor(private val clientOptions: ClientOptions) : ConnectionService { @@ -31,6 +32,9 @@ class ConnectionServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): ConnectionService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConnectionService = + ConnectionServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun accounts(): AccountService = accounts override fun create( @@ -49,6 +53,13 @@ class ConnectionServiceImpl internal constructor(private val clientOptions: Clie AccountServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): ConnectionService.WithRawResponse = + ConnectionServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun accounts(): AccountService.WithRawResponse = accounts private val createHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryService.kt index afe8fbc5..aafbb8b7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.DirectoryCreateResponse import com.tryfinch.api.models.SandboxDirectoryCreateParams +import java.util.function.Consumer interface DirectoryService { @@ -15,6 +17,13 @@ interface DirectoryService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryService + /** Add new individuals to a sandbox company */ fun create(): List = create(SandboxDirectoryCreateParams.none()) @@ -36,6 +45,13 @@ interface DirectoryService { /** A view of [DirectoryService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): DirectoryService.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/directory`, but is otherwise the same as * [DirectoryService.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt index 3bf09066..97ea4078 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/DirectoryServiceImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.DirectoryCreateResponse import com.tryfinch.api.models.SandboxDirectoryCreateParams +import java.util.function.Consumer class DirectoryServiceImpl internal constructor(private val clientOptions: ClientOptions) : DirectoryService { @@ -27,6 +28,9 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien override fun withRawResponse(): DirectoryService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): DirectoryService = + DirectoryServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxDirectoryCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class DirectoryServiceImpl internal constructor(private val clientOptions: Clien private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): DirectoryService.WithRawResponse = + DirectoryServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentService.kt index 8c83ae62..b33e45c7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams +import java.util.function.Consumer interface EmploymentService { @@ -15,6 +17,13 @@ interface EmploymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): EmploymentService + /** Update sandbox employment */ fun update(individualId: String): EmploymentUpdateResponse = update(individualId, SandboxEmploymentUpdateParams.none()) @@ -50,6 +59,15 @@ interface EmploymentService { /** A view of [EmploymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): EmploymentService.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/employment/{individual_id}`, but is * otherwise the same as [EmploymentService.update]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt index fc9bb4a4..9ff66a89 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/EmploymentServiceImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.EmploymentUpdateResponse import com.tryfinch.api.models.SandboxEmploymentUpdateParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class EmploymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): EmploymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): EmploymentService = + EmploymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxEmploymentUpdateParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class EmploymentServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): EmploymentService.WithRawResponse = + EmploymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualService.kt index e8c5faef..50633080 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams +import java.util.function.Consumer interface IndividualService { @@ -15,6 +17,13 @@ interface IndividualService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): IndividualService + /** Update sandbox individual */ fun update(individualId: String): IndividualUpdateResponse = update(individualId, SandboxIndividualUpdateParams.none()) @@ -50,6 +59,15 @@ interface IndividualService { /** A view of [IndividualService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse + /** * Returns a raw HTTP response for `put /sandbox/individual/{individual_id}`, but is * otherwise the same as [IndividualService.update]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt index e7c5ed53..530c11bc 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/IndividualServiceImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.IndividualUpdateResponse import com.tryfinch.api.models.SandboxIndividualUpdateParams +import java.util.function.Consumer import kotlin.jvm.optionals.getOrNull class IndividualServiceImpl internal constructor(private val clientOptions: ClientOptions) : @@ -29,6 +30,9 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie override fun withRawResponse(): IndividualService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): IndividualService = + IndividualServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun update( params: SandboxIndividualUpdateParams, requestOptions: RequestOptions, @@ -41,6 +45,13 @@ class IndividualServiceImpl internal constructor(private val clientOptions: Clie private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): IndividualService.WithRawResponse = + IndividualServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val updateHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobService.kt index cbff8247..76af0515 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.JobCreateResponse import com.tryfinch.api.models.SandboxJobCreateParams import com.tryfinch.api.services.blocking.sandbox.jobs.ConfigurationService +import java.util.function.Consumer interface JobService { @@ -16,6 +18,13 @@ interface JobService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService + fun configuration(): ConfigurationService /** Enqueue a new sandbox job */ @@ -31,6 +40,13 @@ interface JobService { /** A view of [JobService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): JobService.WithRawResponse + fun configuration(): ConfigurationService.WithRawResponse /** diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt index 08a9e2a1..66377981 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/JobServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.JobCreateResponse import com.tryfinch.api.models.SandboxJobCreateParams import com.tryfinch.api.services.blocking.sandbox.jobs.ConfigurationService import com.tryfinch.api.services.blocking.sandbox.jobs.ConfigurationServiceImpl +import java.util.function.Consumer class JobServiceImpl internal constructor(private val clientOptions: ClientOptions) : JobService { @@ -32,6 +33,9 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio override fun withRawResponse(): JobService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): JobService = + JobServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun configuration(): ConfigurationService = configuration override fun create( @@ -50,6 +54,13 @@ class JobServiceImpl internal constructor(private val clientOptions: ClientOptio ConfigurationServiceImpl.WithRawResponseImpl(clientOptions) } + override fun withOptions( + modifier: Consumer + ): JobService.WithRawResponse = + JobServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + override fun configuration(): ConfigurationService.WithRawResponse = configuration private val createHandler: Handler = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentService.kt index 5f78f493..8c4d831c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentService.kt @@ -3,10 +3,12 @@ package com.tryfinch.api.services.blocking.sandbox import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams +import java.util.function.Consumer interface PaymentService { @@ -15,6 +17,13 @@ interface PaymentService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentService + /** Add a new sandbox payment */ fun create(): PaymentCreateResponse = create(SandboxPaymentCreateParams.none()) @@ -36,6 +45,13 @@ interface PaymentService { /** A view of [PaymentService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): PaymentService.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/payment`, but is otherwise the same as * [PaymentService.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt index 4f39d17d..7c11b1e3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/PaymentServiceImpl.kt @@ -17,6 +17,7 @@ import com.tryfinch.api.core.http.parseable import com.tryfinch.api.core.prepare import com.tryfinch.api.models.PaymentCreateResponse import com.tryfinch.api.models.SandboxPaymentCreateParams +import java.util.function.Consumer class PaymentServiceImpl internal constructor(private val clientOptions: ClientOptions) : PaymentService { @@ -27,6 +28,9 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): PaymentService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): PaymentService = + PaymentServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxPaymentCreateParams, requestOptions: RequestOptions, @@ -39,6 +43,13 @@ class PaymentServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): PaymentService.WithRawResponse = + PaymentServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountService.kt index 205880de..57e81402 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountService.kt @@ -3,12 +3,14 @@ package com.tryfinch.api.services.blocking.sandbox.connections import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.AccountCreateResponse import com.tryfinch.api.models.AccountUpdateResponse import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams +import java.util.function.Consumer interface AccountService { @@ -17,6 +19,13 @@ interface AccountService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountService + /** Create a new account for an existing connection (company/provider pair) */ fun create(params: SandboxConnectionAccountCreateParams): AccountCreateResponse = create(params, RequestOptions.none()) @@ -51,6 +60,13 @@ interface AccountService { /** A view of [AccountService] that provides access to raw HTTP responses for each method. */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): AccountService.WithRawResponse + /** * Returns a raw HTTP response for `post /sandbox/connections/accounts`, but is otherwise * the same as [AccountService.create]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt index 06721f17..da103eb5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/connections/AccountServiceImpl.kt @@ -19,6 +19,7 @@ import com.tryfinch.api.models.AccountCreateResponse import com.tryfinch.api.models.AccountUpdateResponse import com.tryfinch.api.models.SandboxConnectionAccountCreateParams import com.tryfinch.api.models.SandboxConnectionAccountUpdateParams +import java.util.function.Consumer class AccountServiceImpl internal constructor(private val clientOptions: ClientOptions) : AccountService { @@ -29,6 +30,9 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO override fun withRawResponse(): AccountService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): AccountService = + AccountServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun create( params: SandboxConnectionAccountCreateParams, requestOptions: RequestOptions, @@ -48,6 +52,13 @@ class AccountServiceImpl internal constructor(private val clientOptions: ClientO private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): AccountService.WithRawResponse = + AccountServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val createHandler: Handler = jsonHandler(clientOptions.jsonMapper) .withErrorHandler(errorHandler) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt index d9fa6264..527c841e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationService.kt @@ -3,11 +3,13 @@ package com.tryfinch.api.services.blocking.sandbox.jobs import com.google.errorprone.annotations.MustBeClosed +import com.tryfinch.api.core.ClientOptions import com.tryfinch.api.core.RequestOptions import com.tryfinch.api.core.http.HttpResponseFor import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams +import java.util.function.Consumer interface ConfigurationService { @@ -16,6 +18,13 @@ interface ConfigurationService { */ fun withRawResponse(): WithRawResponse + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): ConfigurationService + /** Get configurations for sandbox jobs */ fun retrieve(): List = retrieve(SandboxJobConfigurationRetrieveParams.none()) @@ -51,6 +60,15 @@ interface ConfigurationService { */ interface WithRawResponse { + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): ConfigurationService.WithRawResponse + /** * Returns a raw HTTP response for `get /sandbox/jobs/configuration`, but is otherwise the * same as [ConfigurationService.retrieve]. diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt index 810001a4..faf95a70 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/services/blocking/sandbox/jobs/ConfigurationServiceImpl.kt @@ -18,6 +18,7 @@ import com.tryfinch.api.core.prepare import com.tryfinch.api.models.SandboxJobConfiguration import com.tryfinch.api.models.SandboxJobConfigurationRetrieveParams import com.tryfinch.api.models.SandboxJobConfigurationUpdateParams +import java.util.function.Consumer class ConfigurationServiceImpl internal constructor(private val clientOptions: ClientOptions) : ConfigurationService { @@ -28,6 +29,9 @@ class ConfigurationServiceImpl internal constructor(private val clientOptions: C override fun withRawResponse(): ConfigurationService.WithRawResponse = withRawResponse + override fun withOptions(modifier: Consumer): ConfigurationService = + ConfigurationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + override fun retrieve( params: SandboxJobConfigurationRetrieveParams, requestOptions: RequestOptions, @@ -47,6 +51,13 @@ class ConfigurationServiceImpl internal constructor(private val clientOptions: C private val errorHandler: Handler = errorHandler(clientOptions.jsonMapper) + override fun withOptions( + modifier: Consumer + ): ConfigurationService.WithRawResponse = + ConfigurationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + private val retrieveHandler: Handler> = jsonHandler>(clientOptions.jsonMapper) .withErrorHandler(errorHandler) From d88d4b39718a89f914aa89ad944d67eabb833f7a Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 17 Jun 2025 00:13:11 +0000 Subject: [PATCH 19/26] chore(ci): enable for pull requests --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 480eb784..15c474d2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,10 @@ on: - 'integrated/**' - 'stl-preview-head/**' - 'stl-preview-base/**' + pull_request: + branches-ignore: + - 'stl-preview-head/**' + - 'stl-preview-base/**' jobs: lint: From c2130c25fe4053c6d85800dbf4e00935b85ff293 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 23 Jun 2025 18:14:05 +0000 Subject: [PATCH 20/26] fix(client): bump max requests per host to max requests (5 -> 64) --- .../kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt index 7d825642..9d66fadb 100644 --- a/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt +++ b/finch-java-client-okhttp/src/main/kotlin/com/tryfinch/api/client/okhttp/OkHttpClient.kt @@ -205,6 +205,11 @@ class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpC .callTimeout(timeout.request()) .proxy(proxy) .build() + .apply { + // We usually make all our requests to the same host so it makes sense to + // raise the per-host limit to the overall limit. + dispatcher.maxRequestsPerHost = dispatcher.maxRequests + } ) } } From 9ec953ffd3bc6c481f8b426db00fdee0364f737f Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Thu, 26 Jun 2025 14:07:27 +0000 Subject: [PATCH 21/26] =?UTF-8?q?fix(ci):=20release-doctor=20=E2=80=94=20r?= =?UTF-8?q?eport=20correct=20token=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/check-release-environment | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/check-release-environment b/bin/check-release-environment index 5e7c517a..3a6a7b4a 100644 --- a/bin/check-release-environment +++ b/bin/check-release-environment @@ -3,19 +3,19 @@ errors=() if [ -z "${SONATYPE_USERNAME}" ]; then - errors+=("The FINCH_SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The SONATYPE_USERNAME secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${SONATYPE_PASSWORD}" ]; then - errors+=("The FINCH_SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The SONATYPE_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${GPG_SIGNING_KEY}" ]; then - errors+=("The FINCH_SONATYPE_GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The GPG_SIGNING_KEY secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi if [ -z "${GPG_SIGNING_PASSWORD}" ]; then - errors+=("The FINCH_SONATYPE_GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") + errors+=("The GPG_SIGNING_PASSWORD secret has not been set. Please set it in either this repository's secrets or your organization secrets") fi lenErrors=${#errors[@]} From 65d0eb99b3b44fca36f3b1598911b242f1405ef0 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 27 Jun 2025 22:40:05 +0000 Subject: [PATCH 22/26] chore(ci): only run for pushes and fork pull requests --- .github/workflows/ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 15c474d2..2914c6d4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,6 +17,7 @@ jobs: timeout-minutes: 10 name: lint runs-on: ${{ github.repository == 'stainless-sdks/finch-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 @@ -39,6 +40,7 @@ jobs: timeout-minutes: 10 name: test runs-on: ${{ github.repository == 'stainless-sdks/finch-java' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }} + if: github.event_name == 'push' || github.event.pull_request.head.repo.fork steps: - uses: actions/checkout@v4 From f16754fba73202a310517fafa12da662f70030e2 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Sun, 29 Jun 2025 20:49:13 +0000 Subject: [PATCH 23/26] fix(client): don't close client on `withOptions` usage when original is gc'd --- .../com/tryfinch/api/core/ClientOptions.kt | 16 ++++----- .../tryfinch/api/core/ClientOptionsTest.kt | 33 +++++++++++++++++++ 2 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt index 9721297c..e63f1d29 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/core/ClientOptions.kt @@ -110,7 +110,9 @@ private constructor( webhookSecret = clientOptions.webhookSecret } - fun httpClient(httpClient: HttpClient) = apply { this.httpClient = httpClient } + fun httpClient(httpClient: HttpClient) = apply { + this.httpClient = PhantomReachableClosingHttpClient(httpClient) + } fun checkJacksonVersionCompatibility(checkJacksonVersionCompatibility: Boolean) = apply { this.checkJacksonVersionCompatibility = checkJacksonVersionCompatibility @@ -290,13 +292,11 @@ private constructor( return ClientOptions( httpClient, - PhantomReachableClosingHttpClient( - RetryingHttpClient.builder() - .httpClient(httpClient) - .clock(clock) - .maxRetries(maxRetries) - .build() - ), + RetryingHttpClient.builder() + .httpClient(httpClient) + .clock(clock) + .maxRetries(maxRetries) + .build(), checkJacksonVersionCompatibility, jsonMapper, streamHandlerExecutor diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt new file mode 100644 index 00000000..d2e44e67 --- /dev/null +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt @@ -0,0 +1,33 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.tryfinch.api.core + +import com.tryfinch.api.core.http.HttpClient +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith +import org.mockito.junit.jupiter.MockitoExtension +import org.mockito.kotlin.mock +import org.mockito.kotlin.never +import org.mockito.kotlin.verify + +@ExtendWith(MockitoExtension::class) +internal class ClientOptionsTest { + + @Test + fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { + val httpClient = mock() + var clientOptions = + ClientOptions.builder().httpClient(httpClient).accessToken("My Access Token").build() + verify(httpClient, never()).close() + + // Overwrite the `clientOptions` variable so that the original `ClientOptions` is GC'd. + clientOptions = clientOptions.toBuilder().build() + System.gc() + Thread.sleep(100) + + verify(httpClient, never()).close() + // This exists so that `clientOptions` is still reachable. + assertThat(clientOptions).isEqualTo(clientOptions) + } +} From 459de5c5529c89b73febf0d0b30c12d46d314460 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 30 Jun 2025 17:41:32 +0000 Subject: [PATCH 24/26] refactor(internal): minor `ClientOptionsTest` change --- .../src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt index d2e44e67..679c514c 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/core/ClientOptionsTest.kt @@ -14,9 +14,10 @@ import org.mockito.kotlin.verify @ExtendWith(MockitoExtension::class) internal class ClientOptionsTest { + private val httpClient = mock() + @Test fun toBuilder_whenOriginalClientOptionsGarbageCollected_doesNotCloseOriginalClient() { - val httpClient = mock() var clientOptions = ClientOptions.builder().httpClient(httpClient).accessToken("My Access Token").build() verify(httpClient, never()).close() From 2040de9e68d7b36faf74855e99b3e6d2d960cf7b Mon Sep 17 00:00:00 2001 From: Tomer Aberbach Date: Wed, 2 Jul 2025 15:39:16 -0400 Subject: [PATCH 25/26] fix: missing baseUrl call --- .../main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt | 1 + .../src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt | 1 + .../test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt | 2 ++ .../src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt | 2 ++ 4 files changed, 6 insertions(+) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt index 8fba331e..5f8e59fb 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientAsyncImpl.kt @@ -140,6 +140,7 @@ class FinchClientAsyncImpl(private val clientOptions: ClientOptions) : FinchClie val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("auth", "token") .body( json( diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt index bfce2413..efa56805 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/client/FinchClientImpl.kt @@ -129,6 +129,7 @@ class FinchClientImpl(private val clientOptions: ClientOptions) : FinchClient { val request = HttpRequest.builder() .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) .addPathSegments("auth", "token") .body( json( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt index eddacf85..6b784fa0 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientAsyncTest.kt @@ -10,8 +10,10 @@ import com.tryfinch.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") class FinchClientAsyncTest { private lateinit var client: FinchClientAsync diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt index 9ae63cc9..67118106 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/client/FinchClientTest.kt @@ -10,8 +10,10 @@ import com.tryfinch.api.models.* import org.assertj.core.api.Assertions.assertThat import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test +import org.junit.jupiter.api.parallel.ResourceLock @WireMockTest +@ResourceLock("https://github.com/wiremock/wiremock/issues/169") class FinchClientTest { private lateinit var client: FinchClient From 0657c130f4c5e4ade1896547e45161350a4615fc Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 2 Jul 2025 19:39:46 +0000 Subject: [PATCH 26/26] release: 7.3.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 39 +++++++++++++++++++++++++++++++++++ README.md | 10 ++++----- build.gradle.kts | 2 +- 4 files changed, 46 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ad42ef71..6bec2480 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "7.2.0" + ".": "7.3.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index bc506e14..5a1dac19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,44 @@ # Changelog +## 7.3.0 (2025-07-02) + +Full Changelog: [v7.2.0...v7.3.0](https://github.com/Finch-API/finch-api-java/compare/v7.2.0...v7.3.0) + +### Features + +* **api:** api update ([ba2711a](https://github.com/Finch-API/finch-api-java/commit/ba2711a7466433c91cafd023ab09a29dda400322)) +* **api:** api update ([85f964f](https://github.com/Finch-API/finch-api-java/commit/85f964f88bf80872817b2eff4e8a1017a9fabb4e)) +* **api:** api update ([d06d641](https://github.com/Finch-API/finch-api-java/commit/d06d641383d5b756ed558ce9dc23382995855b97)) +* **api:** api update ([ad3d78f](https://github.com/Finch-API/finch-api-java/commit/ad3d78f6515a72e9bc485e5eb9a5dfd98e8cd3d9)) +* **client:** add a `withOptions` method ([a6d2027](https://github.com/Finch-API/finch-api-java/commit/a6d2027c37a9dcf2582041bfa003b3d52a2699f4)) +* **client:** implement per-endpoint base URL support ([9b313e8](https://github.com/Finch-API/finch-api-java/commit/9b313e857a753068e492ffc9fd8a2a9022664ac9)) + + +### Bug Fixes + +* **ci:** release-doctor — report correct token name ([9ec953f](https://github.com/Finch-API/finch-api-java/commit/9ec953ffd3bc6c481f8b426db00fdee0364f737f)) +* **client:** `hasNextPage` impl for some classes ([1d74258](https://github.com/Finch-API/finch-api-java/commit/1d74258cd7af29bab12fa98e22201fdd736ff70e)) +* **client:** bump max requests per host to max requests (5 -> 64) ([c2130c2](https://github.com/Finch-API/finch-api-java/commit/c2130c25fe4053c6d85800dbf4e00935b85ff293)) +* **client:** don't close client on `withOptions` usage when original is gc'd ([f16754f](https://github.com/Finch-API/finch-api-java/commit/f16754fba73202a310517fafa12da662f70030e2)) +* **client:** fix PayStatementResponse body ([6e3128c](https://github.com/Finch-API/finch-api-java/commit/6e3128c15c5554728a0a1ab30f52458031d52f6c)) +* **client:** remove `@MustBeClosed` for future returning methods ([17cef16](https://github.com/Finch-API/finch-api-java/commit/17cef164e3b1da2ee49ed2c8e134bc3b2ff22e18)) +* **client:** update pagination ([d6b79ed](https://github.com/Finch-API/finch-api-java/commit/d6b79edb8319349a9b1141eb686f1e72b45929aa)) +* missing baseUrl call ([2040de9](https://github.com/Finch-API/finch-api-java/commit/2040de9e68d7b36faf74855e99b3e6d2d960cf7b)) + + +### Chores + +* **ci:** enable for pull requests ([d88d4b3](https://github.com/Finch-API/finch-api-java/commit/d88d4b39718a89f914aa89ad944d67eabb833f7a)) +* **ci:** only run for pushes and fork pull requests ([65d0eb9](https://github.com/Finch-API/finch-api-java/commit/65d0eb99b3b44fca36f3b1598911b242f1405ef0)) +* **docs:** grammar improvements ([ec2fe8b](https://github.com/Finch-API/finch-api-java/commit/ec2fe8b45c5898aee580617acbce9364802647be)) +* **internal:** codegen related update ([ec234c1](https://github.com/Finch-API/finch-api-java/commit/ec234c1c781c1453c7cea59e897420e0b820a15b)) +* **tests:** skip endpoints with basic auth ([6c2f07f](https://github.com/Finch-API/finch-api-java/commit/6c2f07f7ce293abdf78dd6584111eb1fcb6b7b52)) + + +### Refactors + +* **internal:** minor `ClientOptionsTest` change ([459de5c](https://github.com/Finch-API/finch-api-java/commit/459de5c5529c89b73febf0d0b30c12d46d314460)) + ## 7.2.0 (2025-05-16) Full Changelog: [v7.1.0...v7.2.0](https://github.com/Finch-API/finch-api-java/compare/v7.1.0...v7.2.0) diff --git a/README.md b/README.md index 44a5705e..54f2db3a 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.2.0) -[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.2.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.2.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/7.3.0) +[![javadoc](https://javadoc.io/badge2/com.tryfinch.api/finch-java/7.3.0/javadoc.svg)](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.3.0) @@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/). -The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.2.0). +The REST API documentation can be found on [developer.tryfinch.com](https://developer.tryfinch.com/). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.tryfinch.api/finch-java/7.3.0). @@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.tryfinch.com](https://deve ### Gradle ```kotlin -implementation("com.tryfinch.api:finch-java:7.2.0") +implementation("com.tryfinch.api:finch-java:7.3.0") ``` ### Maven @@ -35,7 +35,7 @@ implementation("com.tryfinch.api:finch-java:7.2.0") com.tryfinch.api finch-java - 7.2.0 + 7.3.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 003509c6..8faba707 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.tryfinch.api" - version = "7.2.0" // x-release-please-version + version = "7.3.0" // x-release-please-version } subprojects {