From 051f37d5ce901f5a05797d50dad3fc177a893012 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Tue, 7 Jan 2025 21:37:04 +0000 Subject: [PATCH 1/3] feat(client): add various convenience setters to models (#387) feat(client): allow setting arbitrary JSON for top-level body params feat(client): expose getters for `JsonField` of body params fix(client): consistently throw on omitting required fields fix(client): convert `JsonField` containing list type to mutable in builder style(internal): simplify existing convenience setters on params style(internal): move headers and query params setters below others style(internal): explicitly add some method return types --- .../com/tryfinch/api/core/ClientOptions.kt | 46 +- .../api/models/AccessTokenCreateParams.kt | 145 +++- .../api/models/AccountCreateResponse.kt | 68 +- .../tryfinch/api/models/AccountUpdateEvent.kt | 553 ++++++++---- .../api/models/AccountUpdateResponse.kt | 56 +- .../tryfinch/api/models/AutomatedAsyncJob.kt | 79 +- .../api/models/AutomatedCreateResponse.kt | 28 +- .../tryfinch/api/models/BaseWebhookEvent.kt | 16 +- .../api/models/BenefitContribution.kt | 18 +- .../models/BenefitFeaturesAndOperations.kt | 183 +++- .../tryfinch/api/models/BenefitsSupport.kt | 121 ++- .../kotlin/com/tryfinch/api/models/Company.kt | 258 ++++-- .../com/tryfinch/api/models/CompanyBenefit.kt | 39 +- .../com/tryfinch/api/models/CompanyEvent.kt | 24 +- .../api/models/CompanyUpdateResponse.kt | 252 ++++-- .../api/models/ConnectSessionNewParams.kt | 329 +++++-- .../ConnectSessionReauthenticateParams.kt | 191 ++++- .../api/models/ConnectionCreateResponse.kt | 70 +- .../api/models/CreateAccessTokenResponse.kt | 89 +- .../models/CreateCompanyBenefitsResponse.kt | 9 +- .../com/tryfinch/api/models/DirectoryEvent.kt | 24 +- .../tryfinch/api/models/DisconnectResponse.kt | 9 +- .../api/models/DocumentListResponse.kt | 32 +- .../tryfinch/api/models/DocumentResponse.kt | 29 +- .../com/tryfinch/api/models/EmploymentData.kt | 244 ++++-- .../api/models/EmploymentDataResponse.kt | 8 +- .../tryfinch/api/models/EmploymentEvent.kt | 24 +- .../api/models/EmploymentUpdateResponse.kt | 223 +++-- .../tryfinch/api/models/EnrolledIndividual.kt | 29 +- .../api/models/HrisBenefitCreateParams.kt | 131 ++- ...HrisBenefitIndividualUnenrollManyParams.kt | 104 ++- .../api/models/HrisBenefitUpdateParams.kt | 79 +- .../HrisEmploymentRetrieveManyParams.kt | 131 ++- .../HrisIndividualRetrieveManyParams.kt | 185 ++-- .../HrisPayStatementRetrieveManyParams.kt | 157 ++-- .../kotlin/com/tryfinch/api/models/Income.kt | 39 +- .../com/tryfinch/api/models/Individual.kt | 165 +++- .../tryfinch/api/models/IndividualBenefit.kt | 68 +- .../models/IndividualEnrolledIdsResponse.kt | 32 +- .../tryfinch/api/models/IndividualEvent.kt | 24 +- .../api/models/IndividualInDirectory.kt | 59 +- .../tryfinch/api/models/IndividualResponse.kt | 8 +- .../api/models/IndividualUpdateResponse.kt | 161 +++- .../com/tryfinch/api/models/Introspection.kt | 221 +++-- .../api/models/JobAutomatedCreateParams.kt | 68 +- .../tryfinch/api/models/JobCompletionEvent.kt | 32 +- .../tryfinch/api/models/JobCreateResponse.kt | 28 +- .../com/tryfinch/api/models/Location.kt | 54 +- .../com/tryfinch/api/models/ManualAsyncJob.kt | 44 +- .../kotlin/com/tryfinch/api/models/Money.kt | 13 +- .../api/models/OperationSupportMatrix.kt | 8 +- .../kotlin/com/tryfinch/api/models/Paging.kt | 4 +- .../api/models/PayGroupListResponse.kt | 30 +- .../api/models/PayGroupRetrieveResponse.kt | 65 +- .../com/tryfinch/api/models/PayStatement.kt | 337 ++++++-- .../tryfinch/api/models/PayStatementEvent.kt | 26 +- .../api/models/PayStatementResponse.kt | 6 +- .../api/models/PayStatementResponseBody.kt | 28 +- .../kotlin/com/tryfinch/api/models/Payment.kt | 171 +++- .../api/models/PaymentCreateResponse.kt | 12 +- .../com/tryfinch/api/models/PaymentEvent.kt | 32 +- .../com/tryfinch/api/models/Provider.kt | 566 +++++++++---- .../models/RequestForwardingForwardParams.kt | 194 +++-- .../RequestForwardingForwardResponse.kt | 102 ++- .../api/models/SandboxCompanyUpdateParams.kt | 558 +++++++++--- .../SandboxConnectionAccountCreateParams.kt | 176 ++-- .../SandboxConnectionAccountUpdateParams.kt | 83 +- .../models/SandboxConnectionCreateParams.kt | 200 +++-- .../models/SandboxDirectoryCreateParams.kt | 801 ++++++++++++++---- .../models/SandboxEmploymentUpdateParams.kt | 675 +++++++++++---- .../models/SandboxIndividualUpdateParams.kt | 473 ++++++++--- .../api/models/SandboxJobConfiguration.kt | 14 +- .../SandboxJobConfigurationUpdateParams.kt | 91 +- .../api/models/SandboxJobCreateParams.kt | 72 +- .../api/models/SandboxPaymentCreateParams.kt | 778 ++++++++++++----- .../tryfinch/api/models/SessionNewResponse.kt | 12 +- .../models/SessionReauthenticateResponse.kt | 12 +- .../api/models/SupportPerBenefitType.kt | 6 +- .../tryfinch/api/models/SupportedBenefit.kt | 179 +++- .../api/models/UnenrolledIndividual.kt | 29 +- .../models/UpdateCompanyBenefitResponse.kt | 9 +- .../kotlin/com/tryfinch/api/models/W42005.kt | 53 +- .../kotlin/com/tryfinch/api/models/W42020.kt | 122 ++- .../RequestForwardingForwardParamsTest.kt | 11 +- .../models/SandboxCompanyUpdateParamsTest.kt | 22 +- .../blocking/RequestForwardingServiceTest.kt | 1 + 86 files changed, 8047 insertions(+), 2910 deletions(-) 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 743402d6..b397c26c 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 @@ -79,6 +79,29 @@ private constructor( fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun accessToken(accessToken: String?) = apply { this.accessToken = accessToken } + + fun accessToken(accessToken: Optional) = accessToken(accessToken.orElse(null)) + + fun clientId(clientId: String?) = apply { this.clientId = clientId } + + fun clientId(clientId: Optional) = clientId(clientId.orElse(null)) + + fun clientSecret(clientSecret: String?) = apply { this.clientSecret = clientSecret } + + fun clientSecret(clientSecret: Optional) = clientSecret(clientSecret.orElse(null)) + + fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } + + fun webhookSecret(webhookSecret: Optional) = + webhookSecret(webhookSecret.orElse(null)) + fun headers(headers: Headers) = apply { this.headers.clear() putAllHeaders(headers) @@ -159,29 +182,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation - } - - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - - fun accessToken(accessToken: String?) = apply { this.accessToken = accessToken } - - fun accessToken(accessToken: Optional) = accessToken(accessToken.orElse(null)) - - fun clientId(clientId: String?) = apply { this.clientId = clientId } - - fun clientId(clientId: Optional) = clientId(clientId.orElse(null)) - - fun clientSecret(clientSecret: String?) = apply { this.clientSecret = clientSecret } - - fun clientSecret(clientSecret: Optional) = clientSecret(clientSecret.orElse(null)) - - fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } - - fun webhookSecret(webhookSecret: Optional) = - webhookSecret(webhookSecret.orElse(null)) - fun fromEnv() = apply { System.getenv("FINCH_CLIENT_ID")?.let { clientId(it) } System.getenv("FINCH_CLIENT_SECRET")?.let { clientSecret(it) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt index 1ea13c0a..726764c7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccessTokenCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -32,12 +34,20 @@ constructor( fun redirectUri(): Optional = body.redirectUri() - fun _additionalHeaders(): Headers = additionalHeaders + fun _code(): JsonField = body._code() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _clientId(): JsonField = body._clientId() + + fun _clientSecret(): JsonField = body._clientSecret() + + fun _redirectUri(): JsonField = body._redirectUri() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): AccessTokenCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -48,28 +58,60 @@ constructor( class AccessTokenCreateBody @JsonCreator internal constructor( - @JsonProperty("code") private val code: String, - @JsonProperty("client_id") private val clientId: String?, - @JsonProperty("client_secret") private val clientSecret: String?, - @JsonProperty("redirect_uri") private val redirectUri: String?, + @JsonProperty("code") + @ExcludeMissing + private val code: JsonField = JsonMissing.of(), + @JsonProperty("client_id") + @ExcludeMissing + private val clientId: JsonField = JsonMissing.of(), + @JsonProperty("client_secret") + @ExcludeMissing + private val clientSecret: JsonField = JsonMissing.of(), + @JsonProperty("redirect_uri") + @ExcludeMissing + private val redirectUri: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("code") fun code(): String = code + fun code(): String = code.getRequired("code") + + fun clientId(): Optional = Optional.ofNullable(clientId.getNullable("client_id")) + + fun clientSecret(): Optional = + Optional.ofNullable(clientSecret.getNullable("client_secret")) + + fun redirectUri(): Optional = + Optional.ofNullable(redirectUri.getNullable("redirect_uri")) - @JsonProperty("client_id") fun clientId(): Optional = Optional.ofNullable(clientId) + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code + + @JsonProperty("client_id") @ExcludeMissing fun _clientId(): JsonField = clientId @JsonProperty("client_secret") - fun clientSecret(): Optional = Optional.ofNullable(clientSecret) + @ExcludeMissing + fun _clientSecret(): JsonField = clientSecret @JsonProperty("redirect_uri") - fun redirectUri(): Optional = Optional.ofNullable(redirectUri) + @ExcludeMissing + fun _redirectUri(): JsonField = redirectUri @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccessTokenCreateBody = apply { + if (!validated) { + code() + clientId() + clientSecret() + redirectUri() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -79,10 +121,10 @@ constructor( class Builder { - private var code: String? = null - private var clientId: String? = null - private var clientSecret: String? = null - private var redirectUri: String? = null + private var code: JsonField? = null + private var clientId: JsonField = JsonMissing.of() + private var clientSecret: JsonField = JsonMissing.of() + private var redirectUri: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -94,20 +136,25 @@ constructor( additionalProperties = accessTokenCreateBody.additionalProperties.toMutableMap() } - fun code(code: String) = apply { this.code = code } + fun code(code: String) = code(JsonField.of(code)) - fun clientId(clientId: String?) = apply { this.clientId = clientId } + fun code(code: JsonField) = apply { this.code = code } - fun clientId(clientId: Optional) = clientId(clientId.orElse(null)) + fun clientId(clientId: String) = clientId(JsonField.of(clientId)) - fun clientSecret(clientSecret: String?) = apply { this.clientSecret = clientSecret } + fun clientId(clientId: JsonField) = apply { this.clientId = clientId } - fun clientSecret(clientSecret: Optional) = - clientSecret(clientSecret.orElse(null)) + fun clientSecret(clientSecret: String) = clientSecret(JsonField.of(clientSecret)) - fun redirectUri(redirectUri: String?) = apply { this.redirectUri = redirectUri } + fun clientSecret(clientSecret: JsonField) = apply { + this.clientSecret = clientSecret + } - fun redirectUri(redirectUri: Optional) = redirectUri(redirectUri.orElse(null)) + fun redirectUri(redirectUri: String) = redirectUri(JsonField.of(redirectUri)) + + fun redirectUri(redirectUri: JsonField) = apply { + this.redirectUri = redirectUri + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -179,17 +226,40 @@ constructor( fun code(code: String) = apply { body.code(code) } - fun clientId(clientId: String?) = apply { body.clientId(clientId) } + fun code(code: JsonField) = apply { body.code(code) } + + fun clientId(clientId: String) = apply { body.clientId(clientId) } - fun clientId(clientId: Optional) = clientId(clientId.orElse(null)) + fun clientId(clientId: JsonField) = apply { body.clientId(clientId) } - fun clientSecret(clientSecret: String?) = apply { body.clientSecret(clientSecret) } + fun clientSecret(clientSecret: String) = apply { body.clientSecret(clientSecret) } + + fun clientSecret(clientSecret: JsonField) = apply { + body.clientSecret(clientSecret) + } - fun clientSecret(clientSecret: Optional) = clientSecret(clientSecret.orElse(null)) + fun redirectUri(redirectUri: String) = apply { body.redirectUri(redirectUri) } - fun redirectUri(redirectUri: String?) = apply { body.redirectUri(redirectUri) } + fun redirectUri(redirectUri: JsonField) = apply { body.redirectUri(redirectUri) } - fun redirectUri(redirectUri: Optional) = redirectUri(redirectUri.orElse(null)) + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -289,25 +359,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): AccessTokenCreateParams = AccessTokenCreateParams( body.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt index 328ed3c2..253bb585 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountCreateResponse.kt @@ -64,25 +64,29 @@ private constructor( /** The ID of the provider associated with the `access_token` */ fun providerId(): String = providerId.getRequired("provider_id") - @JsonProperty("access_token") @ExcludeMissing fun _accessToken() = accessToken + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId @JsonProperty("authentication_type") @ExcludeMissing - fun _authenticationType() = authenticationType + fun _authenticationType(): JsonField = authenticationType /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** The ID of the new connection */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("products") @ExcludeMissing fun _products() = products + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products /** The ID of the provider associated with the `access_token` */ - @JsonProperty("provider_id") @ExcludeMissing fun _providerId() = providerId + @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField = providerId @JsonAnyGetter @ExcludeMissing @@ -112,13 +116,13 @@ private constructor( class Builder { - private var accessToken: JsonField = JsonMissing.of() - private var accountId: JsonField = JsonMissing.of() - private var authenticationType: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() - private var connectionId: JsonField = JsonMissing.of() - private var products: JsonField> = JsonMissing.of() - private var providerId: JsonField = JsonMissing.of() + private var accessToken: JsonField? = null + private var accountId: JsonField? = null + private var authenticationType: JsonField? = null + private var companyId: JsonField? = null + private var connectionId: JsonField? = null + private var products: JsonField>? = null + private var providerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -128,7 +132,7 @@ private constructor( authenticationType = accountCreateResponse.authenticationType companyId = accountCreateResponse.companyId connectionId = accountCreateResponse.connectionId - products = accountCreateResponse.products + products = accountCreateResponse.products.map { it.toMutableList() } providerId = accountCreateResponse.providerId additionalProperties = accountCreateResponse.additionalProperties.toMutableMap() } @@ -166,7 +170,22 @@ private constructor( fun products(products: List) = products(JsonField.of(products)) - fun products(products: JsonField>) = apply { this.products = products } + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } + } /** The ID of the provider associated with the `access_token` */ fun providerId(providerId: String) = providerId(JsonField.of(providerId)) @@ -195,13 +214,16 @@ private constructor( fun build(): AccountCreateResponse = AccountCreateResponse( - accessToken, - accountId, - authenticationType, - companyId, - connectionId, - products.map { it.toImmutable() }, - providerId, + checkNotNull(accessToken) { "`accessToken` is required but was not set" }, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(authenticationType) { + "`authenticationType` is required but was not set" + }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkNotNull(connectionId) { "`connectionId` is required but was not set" }, + checkNotNull(products) { "`products` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(providerId) { "`providerId` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateEvent.kt index cee081a2..c01ee175 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateEvent.kt @@ -62,20 +62,22 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing @@ -110,8 +112,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var data: JsonField = JsonMissing.of() private var eventType: JsonField = JsonMissing.of() @@ -188,8 +190,8 @@ private constructor( fun build(): AccountUpdateEvent = AccountUpdateEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, data, eventType, @@ -218,9 +220,11 @@ private constructor( @JsonProperty("authentication_method") @ExcludeMissing - fun _authenticationMethod() = authenticationMethod + fun _authenticationMethod(): JsonField = authenticationMethod - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -245,8 +249,8 @@ private constructor( class Builder { - private var authenticationMethod: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() + private var authenticationMethod: JsonField? = null + private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -289,8 +293,10 @@ private constructor( fun build(): Data = Data( - authenticationMethod, - status, + checkNotNull(authenticationMethod) { + "`authenticationMethod` is required but was not set" + }, + checkNotNull(status) { "`status` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -332,15 +338,15 @@ private constructor( */ @JsonProperty("benefits_support") @ExcludeMissing - fun _benefitsSupport() = benefitsSupport + fun _benefitsSupport(): JsonField = benefitsSupport /** The supported data fields returned by our HR and payroll endpoints */ @JsonProperty("supported_fields") @ExcludeMissing - fun _supportedFields() = supportedFields + fun _supportedFields(): JsonField = supportedFields /** The type of authentication method. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -383,8 +389,15 @@ private constructor( * Each benefit type and their supported features. If the benefit type is not * supported, the property will be null */ - fun benefitsSupport(benefitsSupport: BenefitsSupport) = - benefitsSupport(JsonField.of(benefitsSupport)) + fun benefitsSupport(benefitsSupport: BenefitsSupport?) = + benefitsSupport(JsonField.ofNullable(benefitsSupport)) + + /** + * Each benefit type and their supported features. If the benefit type is not + * supported, the property will be null + */ + fun benefitsSupport(benefitsSupport: Optional) = + benefitsSupport(benefitsSupport.orElse(null)) /** * Each benefit type and their supported features. If the benefit type is not @@ -395,8 +408,12 @@ private constructor( } /** The supported data fields returned by our HR and payroll endpoints */ - fun supportedFields(supportedFields: SupportedFields) = - supportedFields(JsonField.of(supportedFields)) + fun supportedFields(supportedFields: SupportedFields?) = + supportedFields(JsonField.ofNullable(supportedFields)) + + /** The supported data fields returned by our HR and payroll endpoints */ + fun supportedFields(supportedFields: Optional) = + supportedFields(supportedFields.orElse(null)) /** The supported data fields returned by our HR and payroll endpoints */ fun supportedFields(supportedFields: JsonField) = apply { @@ -491,19 +508,33 @@ private constructor( fun payment(): Optional = Optional.ofNullable(payment.getNullable("payment")) - @JsonProperty("company") @ExcludeMissing fun _company() = company + @JsonProperty("company") + @ExcludeMissing + fun _company(): JsonField = company - @JsonProperty("directory") @ExcludeMissing fun _directory() = directory + @JsonProperty("directory") + @ExcludeMissing + fun _directory(): JsonField = directory - @JsonProperty("employment") @ExcludeMissing fun _employment() = employment + @JsonProperty("employment") + @ExcludeMissing + fun _employment(): JsonField = employment - @JsonProperty("individual") @ExcludeMissing fun _individual() = individual + @JsonProperty("individual") + @ExcludeMissing + fun _individual(): JsonField = individual - @JsonProperty("pay_group") @ExcludeMissing fun _payGroup() = payGroup + @JsonProperty("pay_group") + @ExcludeMissing + fun _payGroup(): JsonField = payGroup - @JsonProperty("pay_statement") @ExcludeMissing fun _payStatement() = payStatement + @JsonProperty("pay_statement") + @ExcludeMissing + fun _payStatement(): JsonField = payStatement - @JsonProperty("payment") @ExcludeMissing fun _payment() = payment + @JsonProperty("payment") + @ExcludeMissing + fun _payment(): JsonField = payment @JsonAnyGetter @ExcludeMissing @@ -697,27 +728,37 @@ private constructor( fun primaryPhoneNumber(): Optional = Optional.ofNullable(primaryPhoneNumber.getNullable("primary_phone_number")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("accounts") @ExcludeMissing fun _accounts() = accounts + @JsonProperty("accounts") + @ExcludeMissing + fun _accounts(): JsonField = accounts - @JsonProperty("departments") @ExcludeMissing fun _departments() = departments + @JsonProperty("departments") + @ExcludeMissing + fun _departments(): JsonField = departments - @JsonProperty("ein") @ExcludeMissing fun _ein() = ein + @JsonProperty("ein") @ExcludeMissing fun _ein(): JsonField = ein - @JsonProperty("entity") @ExcludeMissing fun _entity() = entity + @JsonProperty("entity") + @ExcludeMissing + fun _entity(): JsonField = entity - @JsonProperty("legal_name") @ExcludeMissing fun _legalName() = legalName + @JsonProperty("legal_name") + @ExcludeMissing + fun _legalName(): JsonField = legalName - @JsonProperty("locations") @ExcludeMissing fun _locations() = locations + @JsonProperty("locations") + @ExcludeMissing + fun _locations(): JsonField = locations @JsonProperty("primary_email") @ExcludeMissing - fun _primaryEmail() = primaryEmail + fun _primaryEmail(): JsonField = primaryEmail @JsonProperty("primary_phone_number") @ExcludeMissing - fun _primaryPhoneNumber() = primaryPhoneNumber + fun _primaryPhoneNumber(): JsonField = primaryPhoneNumber @JsonAnyGetter @ExcludeMissing @@ -905,23 +946,23 @@ private constructor( @JsonProperty("account_name") @ExcludeMissing - fun _accountName() = accountName + fun _accountName(): JsonField = accountName @JsonProperty("account_number") @ExcludeMissing - fun _accountNumber() = accountNumber + fun _accountNumber(): JsonField = accountNumber @JsonProperty("account_type") @ExcludeMissing - fun _accountType() = accountType + fun _accountType(): JsonField = accountType @JsonProperty("institution_name") @ExcludeMissing - fun _institutionName() = institutionName + fun _institutionName(): JsonField = institutionName @JsonProperty("routing_number") @ExcludeMissing - fun _routingNumber() = routingNumber + fun _routingNumber(): JsonField = routingNumber @JsonAnyGetter @ExcludeMissing @@ -1074,9 +1115,11 @@ private constructor( fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("parent") + @ExcludeMissing + fun _parent(): JsonField = parent @JsonAnyGetter @ExcludeMissing @@ -1167,7 +1210,9 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1291,9 +1336,11 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") + @ExcludeMissing + fun _subtype(): JsonField = subtype - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1433,17 +1480,27 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") + @ExcludeMissing + fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") + @ExcludeMissing + fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") + @ExcludeMissing + fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") + @ExcludeMissing + fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -1611,9 +1668,13 @@ private constructor( fun paging(): Optional = Optional.ofNullable(paging.getNullable("paging")) - @JsonProperty("individuals") @ExcludeMissing fun _individuals() = individuals + @JsonProperty("individuals") + @ExcludeMissing + fun _individuals(): JsonField = individuals - @JsonProperty("paging") @ExcludeMissing fun _paging() = paging + @JsonProperty("paging") + @ExcludeMissing + fun _paging(): JsonField = paging @JsonAnyGetter @ExcludeMissing @@ -1743,19 +1804,31 @@ private constructor( fun middleName(): Optional = Optional.ofNullable(middleName.getNullable("middle_name")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("department") @ExcludeMissing fun _department() = department + @JsonProperty("department") + @ExcludeMissing + fun _department(): JsonField = department - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") + @ExcludeMissing + fun _isActive(): JsonField = isActive - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName - @JsonProperty("manager") @ExcludeMissing fun _manager() = manager + @JsonProperty("manager") + @ExcludeMissing + fun _manager(): JsonField = manager - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") + @ExcludeMissing + fun _middleName(): JsonField = middleName @JsonAnyGetter @ExcludeMissing @@ -1899,7 +1972,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -2023,9 +2096,13 @@ private constructor( fun offset(): Optional = Optional.ofNullable(offset.getNullable("offset")) - @JsonProperty("count") @ExcludeMissing fun _count() = count + @JsonProperty("count") + @ExcludeMissing + fun _count(): JsonField = count - @JsonProperty("offset") @ExcludeMissing fun _offset() = offset + @JsonProperty("offset") + @ExcludeMissing + fun _offset(): JsonField = offset @JsonAnyGetter @ExcludeMissing @@ -2244,45 +2321,69 @@ private constructor( fun title(): Optional = Optional.ofNullable(title.getNullable("title")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("class_code") @ExcludeMissing fun _classCode() = classCode + @JsonProperty("class_code") + @ExcludeMissing + fun _classCode(): JsonField = classCode @JsonProperty("custom_fields") @ExcludeMissing - fun _customFields() = customFields + fun _customFields(): JsonField = customFields - @JsonProperty("department") @ExcludeMissing fun _department() = department + @JsonProperty("department") + @ExcludeMissing + fun _department(): JsonField = department - @JsonProperty("employment") @ExcludeMissing fun _employment() = employment + @JsonProperty("employment") + @ExcludeMissing + fun _employment(): JsonField = employment @JsonProperty("employment_status") @ExcludeMissing - fun _employmentStatus() = employmentStatus + fun _employmentStatus(): JsonField = employmentStatus - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName - @JsonProperty("income") @ExcludeMissing fun _income() = income + @JsonProperty("income") + @ExcludeMissing + fun _income(): JsonField = income @JsonProperty("income_history") @ExcludeMissing - fun _incomeHistory() = incomeHistory + fun _incomeHistory(): JsonField = incomeHistory - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") + @ExcludeMissing + fun _isActive(): JsonField = isActive - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location - @JsonProperty("manager") @ExcludeMissing fun _manager() = manager + @JsonProperty("manager") + @ExcludeMissing + fun _manager(): JsonField = manager - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") + @ExcludeMissing + fun _middleName(): JsonField = middleName - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("title") @ExcludeMissing fun _title() = title + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title @JsonAnyGetter @ExcludeMissing @@ -2523,7 +2624,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2627,9 +2728,11 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") + @ExcludeMissing + fun _subtype(): JsonField = subtype - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2752,11 +2855,15 @@ private constructor( fun unit(): Optional = Optional.ofNullable(unit.getNullable("unit")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("unit") @ExcludeMissing fun _unit() = unit + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit @JsonAnyGetter @ExcludeMissing @@ -2904,17 +3011,27 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") + @ExcludeMissing + fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") + @ExcludeMissing + fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") + @ExcludeMissing + fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") + @ExcludeMissing + fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -3058,7 +3175,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -3240,37 +3357,51 @@ private constructor( fun ssn(): Optional = Optional.ofNullable(ssn.getNullable("ssn")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob - @JsonProperty("emails") @ExcludeMissing fun _emails() = emails + @JsonProperty("emails") + @ExcludeMissing + fun _emails(): JsonField = emails @JsonProperty("encrypted_ssn") @ExcludeMissing - fun _encryptedSsn() = encryptedSsn + fun _encryptedSsn(): JsonField = encryptedSsn - @JsonProperty("ethnicity") @ExcludeMissing fun _ethnicity() = ethnicity + @JsonProperty("ethnicity") + @ExcludeMissing + fun _ethnicity(): JsonField = ethnicity - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName - @JsonProperty("gender") @ExcludeMissing fun _gender() = gender + @JsonProperty("gender") + @ExcludeMissing + fun _gender(): JsonField = gender - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") + @ExcludeMissing + fun _middleName(): JsonField = middleName @JsonProperty("phone_numbers") @ExcludeMissing - fun _phoneNumbers() = phoneNumbers + fun _phoneNumbers(): JsonField = phoneNumbers @JsonProperty("preferred_name") @ExcludeMissing - fun _preferredName() = preferredName + fun _preferredName(): JsonField = preferredName - @JsonProperty("residence") @ExcludeMissing fun _residence() = residence + @JsonProperty("residence") + @ExcludeMissing + fun _residence(): JsonField = residence - @JsonProperty("ssn") @ExcludeMissing fun _ssn() = ssn + @JsonProperty("ssn") @ExcludeMissing fun _ssn(): JsonField = ssn @JsonAnyGetter @ExcludeMissing @@ -3475,9 +3606,9 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3591,9 +3722,9 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3732,17 +3863,27 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") + @ExcludeMissing + fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") + @ExcludeMissing + fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") + @ExcludeMissing + fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") + @ExcludeMissing + fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -3920,17 +4061,17 @@ private constructor( fun payFrequencies(): Optional = Optional.ofNullable(payFrequencies.getNullable("pay_frequencies")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("individual_ids") @ExcludeMissing - fun _individualIds() = individualIds + fun _individualIds(): JsonField = individualIds - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("pay_frequencies") @ExcludeMissing - fun _payFrequencies() = payFrequencies + fun _payFrequencies(): JsonField = payFrequencies @JsonAnyGetter @ExcludeMissing @@ -4067,11 +4208,13 @@ private constructor( fun payStatements(): Optional = Optional.ofNullable(payStatements.getNullable("pay_statements")) - @JsonProperty("paging") @ExcludeMissing fun _paging() = paging + @JsonProperty("paging") + @ExcludeMissing + fun _paging(): JsonField = paging @JsonProperty("pay_statements") @ExcludeMissing - fun _payStatements() = payStatements + fun _payStatements(): JsonField = payStatements @JsonAnyGetter @ExcludeMissing @@ -4171,9 +4314,13 @@ private constructor( fun offset(): Boolean = offset.getRequired("offset") - @JsonProperty("count") @ExcludeMissing fun _count() = count + @JsonProperty("count") + @ExcludeMissing + fun _count(): JsonField = count - @JsonProperty("offset") @ExcludeMissing fun _offset() = offset + @JsonProperty("offset") + @ExcludeMissing + fun _offset(): JsonField = offset @JsonAnyGetter @ExcludeMissing @@ -4198,8 +4345,8 @@ private constructor( class Builder { - private var count: JsonField = JsonMissing.of() - private var offset: JsonField = JsonMissing.of() + private var count: JsonField? = null + private var offset: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4242,8 +4389,8 @@ private constructor( fun build(): Paging = Paging( - count, - offset, + checkNotNull(count) { "`count` is required but was not set" }, + checkNotNull(offset) { "`offset` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4341,33 +4488,45 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("earnings") @ExcludeMissing fun _earnings() = earnings + @JsonProperty("earnings") + @ExcludeMissing + fun _earnings(): JsonField = earnings @JsonProperty("employee_deductions") @ExcludeMissing - fun _employeeDeductions() = employeeDeductions + fun _employeeDeductions(): JsonField = + employeeDeductions @JsonProperty("employer_contributions") @ExcludeMissing - fun _employerContributions() = employerContributions + fun _employerContributions(): JsonField = + employerContributions - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay() = grossPay + @JsonProperty("gross_pay") + @ExcludeMissing + fun _grossPay(): JsonField = grossPay @JsonProperty("individual_id") @ExcludeMissing - fun _individualId() = individualId + fun _individualId(): JsonField = individualId - @JsonProperty("net_pay") @ExcludeMissing fun _netPay() = netPay + @JsonProperty("net_pay") + @ExcludeMissing + fun _netPay(): JsonField = netPay @JsonProperty("payment_method") @ExcludeMissing - fun _paymentMethod() = paymentMethod + fun _paymentMethod(): JsonField = paymentMethod - @JsonProperty("taxes") @ExcludeMissing fun _taxes() = taxes + @JsonProperty("taxes") + @ExcludeMissing + fun _taxes(): JsonField = taxes - @JsonProperty("total_hours") @ExcludeMissing fun _totalHours() = totalHours + @JsonProperty("total_hours") + @ExcludeMissing + fun _totalHours(): JsonField = totalHours - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -4562,13 +4721,21 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -4723,15 +4890,25 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("pre_tax") @ExcludeMissing fun _preTax() = preTax + @JsonProperty("pre_tax") + @ExcludeMissing + fun _preTax(): JsonField = preTax - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -4884,11 +5061,17 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -5037,15 +5220,25 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("employer") @ExcludeMissing fun _employer() = employer + @JsonProperty("employer") + @ExcludeMissing + fun _employer(): JsonField = employer - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") + @ExcludeMissing + fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") + @ExcludeMissing + fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -5285,39 +5478,51 @@ private constructor( fun payPeriod(): Optional = Optional.ofNullable(payPeriod.getNullable("pay_period")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("company_debit") @ExcludeMissing - fun _companyDebit() = companyDebit + fun _companyDebit(): JsonField = companyDebit - @JsonProperty("debit_date") @ExcludeMissing fun _debitDate() = debitDate + @JsonProperty("debit_date") + @ExcludeMissing + fun _debitDate(): JsonField = debitDate @JsonProperty("employee_taxes") @ExcludeMissing - fun _employeeTaxes() = employeeTaxes + fun _employeeTaxes(): JsonField = employeeTaxes @JsonProperty("employer_taxes") @ExcludeMissing - fun _employerTaxes() = employerTaxes + fun _employerTaxes(): JsonField = employerTaxes - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay() = grossPay + @JsonProperty("gross_pay") + @ExcludeMissing + fun _grossPay(): JsonField = grossPay @JsonProperty("individual_ids") @ExcludeMissing - fun _individualIds() = individualIds + fun _individualIds(): JsonField = individualIds - @JsonProperty("net_pay") @ExcludeMissing fun _netPay() = netPay + @JsonProperty("net_pay") + @ExcludeMissing + fun _netPay(): JsonField = netPay - @JsonProperty("pay_date") @ExcludeMissing fun _payDate() = payDate + @JsonProperty("pay_date") + @ExcludeMissing + fun _payDate(): JsonField = payDate @JsonProperty("pay_frequencies") @ExcludeMissing - fun _payFrequencies() = payFrequencies + fun _payFrequencies(): JsonField = payFrequencies - @JsonProperty("pay_group_ids") @ExcludeMissing fun _payGroupIds() = payGroupIds + @JsonProperty("pay_group_ids") + @ExcludeMissing + fun _payGroupIds(): JsonField = payGroupIds - @JsonProperty("pay_period") @ExcludeMissing fun _payPeriod() = payPeriod + @JsonProperty("pay_period") + @ExcludeMissing + fun _payPeriod(): JsonField = payPeriod @JsonAnyGetter @ExcludeMissing @@ -5518,9 +5723,13 @@ private constructor( fun startDate(): Optional = Optional.ofNullable(startDate.getNullable("start_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateResponse.kt index c8b5162a..1883927b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AccountUpdateResponse.kt @@ -62,22 +62,24 @@ private constructor( Optional.ofNullable(connectionId.getNullable("connection_id")) /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId @JsonProperty("authentication_type") @ExcludeMissing - fun _authenticationType() = authenticationType + fun _authenticationType(): JsonField = authenticationType /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId - @JsonProperty("products") @ExcludeMissing fun _products() = products + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products /** The ID of the provider associated with the `access_token` */ - @JsonProperty("provider_id") @ExcludeMissing fun _providerId() = providerId + @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField = providerId /** The ID of the new connection */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId @JsonAnyGetter @ExcludeMissing @@ -106,11 +108,11 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var authenticationType: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() - private var products: JsonField> = JsonMissing.of() - private var providerId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var authenticationType: JsonField? = null + private var companyId: JsonField? = null + private var products: JsonField>? = null + private var providerId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -119,7 +121,7 @@ private constructor( accountId = accountUpdateResponse.accountId authenticationType = accountUpdateResponse.authenticationType companyId = accountUpdateResponse.companyId - products = accountUpdateResponse.products + products = accountUpdateResponse.products.map { it.toMutableList() } providerId = accountUpdateResponse.providerId connectionId = accountUpdateResponse.connectionId additionalProperties = accountUpdateResponse.additionalProperties.toMutableMap() @@ -146,7 +148,22 @@ private constructor( fun products(products: List) = products(JsonField.of(products)) - fun products(products: JsonField>) = apply { this.products = products } + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } + } /** The ID of the provider associated with the `access_token` */ fun providerId(providerId: String) = providerId(JsonField.of(providerId)) @@ -183,11 +200,14 @@ private constructor( fun build(): AccountUpdateResponse = AccountUpdateResponse( - accountId, - authenticationType, - companyId, - products.map { it.toImmutable() }, - providerId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(authenticationType) { + "`authenticationType` is required but was not set" + }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkNotNull(products) { "`products` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(providerId) { "`providerId` is required but was not set" }, connectionId, additionalProperties.toImmutable(), ) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedAsyncJob.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedAsyncJob.kt index 73d86867..64fb9241 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedAsyncJob.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedAsyncJob.kt @@ -79,33 +79,41 @@ private constructor( fun type(): Type = type.getRequired("type") /** The datetime the job completed. */ - @JsonProperty("completed_at") @ExcludeMissing fun _completedAt() = completedAt + @JsonProperty("completed_at") + @ExcludeMissing + fun _completedAt(): JsonField = completedAt /** * The datetime when the job was created. for scheduled jobs, this will be the initial * connection time. For ad-hoc jobs, this will be the time the creation request was received. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** The id of the job that has been created. */ - @JsonProperty("job_id") @ExcludeMissing fun _jobId() = jobId + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId /** The url that can be used to retrieve the job status */ - @JsonProperty("job_url") @ExcludeMissing fun _jobUrl() = jobUrl + @JsonProperty("job_url") @ExcludeMissing fun _jobUrl(): JsonField = jobUrl /** * The datetime a job is scheduled to be run. For scheduled jobs, this datetime can be in the * future if the job has not yet been enqueued. For ad-hoc jobs, this field will beĀ null. */ - @JsonProperty("scheduled_at") @ExcludeMissing fun _scheduledAt() = scheduledAt + @JsonProperty("scheduled_at") + @ExcludeMissing + fun _scheduledAt(): JsonField = scheduledAt /** The datetime a job entered into the job queue. */ - @JsonProperty("started_at") @ExcludeMissing fun _startedAt() = startedAt + @JsonProperty("started_at") + @ExcludeMissing + fun _startedAt(): JsonField = startedAt - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status /** Only `data_sync_all` currently supported */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -136,14 +144,14 @@ private constructor( class Builder { - private var completedAt: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var jobId: JsonField = JsonMissing.of() - private var jobUrl: JsonField = JsonMissing.of() - private var scheduledAt: JsonField = JsonMissing.of() - private var startedAt: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var completedAt: JsonField? = null + private var createdAt: JsonField? = null + private var jobId: JsonField? = null + private var jobUrl: JsonField? = null + private var scheduledAt: JsonField? = null + private var startedAt: JsonField? = null + private var status: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -160,7 +168,12 @@ private constructor( } /** The datetime the job completed. */ - fun completedAt(completedAt: OffsetDateTime) = completedAt(JsonField.of(completedAt)) + fun completedAt(completedAt: OffsetDateTime?) = + completedAt(JsonField.ofNullable(completedAt)) + + /** The datetime the job completed. */ + fun completedAt(completedAt: Optional) = + completedAt(completedAt.orElse(null)) /** The datetime the job completed. */ fun completedAt(completedAt: JsonField) = apply { @@ -198,7 +211,16 @@ private constructor( * the future if the job has not yet been enqueued. For ad-hoc jobs, this field will * beĀ null. */ - fun scheduledAt(scheduledAt: OffsetDateTime) = scheduledAt(JsonField.of(scheduledAt)) + fun scheduledAt(scheduledAt: OffsetDateTime?) = + scheduledAt(JsonField.ofNullable(scheduledAt)) + + /** + * The datetime a job is scheduled to be run. For scheduled jobs, this datetime can be in + * the future if the job has not yet been enqueued. For ad-hoc jobs, this field will + * beĀ null. + */ + fun scheduledAt(scheduledAt: Optional) = + scheduledAt(scheduledAt.orElse(null)) /** * The datetime a job is scheduled to be run. For scheduled jobs, this datetime can be in @@ -210,7 +232,10 @@ private constructor( } /** The datetime a job entered into the job queue. */ - fun startedAt(startedAt: OffsetDateTime) = startedAt(JsonField.of(startedAt)) + fun startedAt(startedAt: OffsetDateTime?) = startedAt(JsonField.ofNullable(startedAt)) + + /** The datetime a job entered into the job queue. */ + fun startedAt(startedAt: Optional) = startedAt(startedAt.orElse(null)) /** The datetime a job entered into the job queue. */ fun startedAt(startedAt: JsonField) = apply { this.startedAt = startedAt } @@ -246,14 +271,14 @@ private constructor( fun build(): AutomatedAsyncJob = AutomatedAsyncJob( - completedAt, - createdAt, - jobId, - jobUrl, - scheduledAt, - startedAt, - status, - type, + checkNotNull(completedAt) { "`completedAt` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(jobId) { "`jobId` is required but was not set" }, + checkNotNull(jobUrl) { "`jobUrl` is required but was not set" }, + checkNotNull(scheduledAt) { "`scheduledAt` is required but was not set" }, + checkNotNull(startedAt) { "`startedAt` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedCreateResponse.kt index 089deb06..ed868f17 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/AutomatedCreateResponse.kt @@ -45,18 +45,20 @@ private constructor( fun remainingRefreshes(): Long = remainingRefreshes.getRequired("remaining_refreshes") /** The number of allowed refreshes per hour (per hour, fixed window) */ - @JsonProperty("allowed_refreshes") @ExcludeMissing fun _allowedRefreshes() = allowedRefreshes + @JsonProperty("allowed_refreshes") + @ExcludeMissing + fun _allowedRefreshes(): JsonField = allowedRefreshes /** The id of the job that has been created. */ - @JsonProperty("job_id") @ExcludeMissing fun _jobId() = jobId + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId /** The url that can be used to retrieve the job status */ - @JsonProperty("job_url") @ExcludeMissing fun _jobUrl() = jobUrl + @JsonProperty("job_url") @ExcludeMissing fun _jobUrl(): JsonField = jobUrl /** The number of remaining refreshes available (per hour, fixed window) */ @JsonProperty("remaining_refreshes") @ExcludeMissing - fun _remainingRefreshes() = remainingRefreshes + fun _remainingRefreshes(): JsonField = remainingRefreshes @JsonAnyGetter @ExcludeMissing @@ -83,10 +85,10 @@ private constructor( class Builder { - private var allowedRefreshes: JsonField = JsonMissing.of() - private var jobId: JsonField = JsonMissing.of() - private var jobUrl: JsonField = JsonMissing.of() - private var remainingRefreshes: JsonField = JsonMissing.of() + private var allowedRefreshes: JsonField? = null + private var jobId: JsonField? = null + private var jobUrl: JsonField? = null + private var remainingRefreshes: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -149,10 +151,12 @@ private constructor( fun build(): AutomatedCreateResponse = AutomatedCreateResponse( - allowedRefreshes, - jobId, - jobUrl, - remainingRefreshes, + checkNotNull(allowedRefreshes) { "`allowedRefreshes` is required but was not set" }, + checkNotNull(jobId) { "`jobId` is required but was not set" }, + checkNotNull(jobUrl) { "`jobUrl` is required but was not set" }, + checkNotNull(remainingRefreshes) { + "`remainingRefreshes` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BaseWebhookEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BaseWebhookEvent.kt index 8fc57748..74d2e8aa 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BaseWebhookEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BaseWebhookEvent.kt @@ -52,16 +52,18 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId @JsonAnyGetter @ExcludeMissing @@ -87,8 +89,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -153,8 +155,8 @@ private constructor( fun build(): BaseWebhookEvent = BaseWebhookEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, additionalProperties.toImmutable(), ) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitContribution.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitContribution.kt index 2fa66770..60809abe 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitContribution.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitContribution.kt @@ -34,10 +34,10 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Contribution amount in cents (if `fixed`) or basis points (if `percent`). */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** Contribution type. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -74,13 +74,23 @@ private constructor( } /** Contribution amount in cents (if `fixed`) or basis points (if `percent`). */ - fun amount(amount: Long) = amount(JsonField.of(amount)) + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** Contribution amount in cents (if `fixed`) or basis points (if `percent`). */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Contribution amount in cents (if `fixed`) or basis points (if `percent`). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) /** Contribution amount in cents (if `fixed`) or basis points (if `percent`). */ fun amount(amount: JsonField) = apply { this.amount = amount } /** Contribution type. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** Contribution type. */ + fun type(type: Optional) = type(type.orElse(null)) /** Contribution type. */ fun type(type: JsonField) = apply { this.type = type } 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 9f4489fe..f09e3ce1 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 @@ -37,11 +37,13 @@ private constructor( fun supportedOperations(): Optional = Optional.ofNullable(supportedOperations.getNullable("supported_operations")) - @JsonProperty("supported_features") @ExcludeMissing fun _supportedFeatures() = supportedFeatures + @JsonProperty("supported_features") + @ExcludeMissing + fun _supportedFeatures(): JsonField = supportedFeatures @JsonProperty("supported_operations") @ExcludeMissing - fun _supportedOperations() = supportedOperations + fun _supportedOperations(): JsonField = supportedOperations @JsonAnyGetter @ExcludeMissing @@ -182,30 +184,36 @@ private constructor( Optional.ofNullable(hsaContributionLimit.getNullable("hsa_contribution_limit")) /** Whether the provider supports an annual maximum for this benefit. */ - @JsonProperty("annual_maximum") @ExcludeMissing fun _annualMaximum() = annualMaximum + @JsonProperty("annual_maximum") + @ExcludeMissing + fun _annualMaximum(): JsonField = annualMaximum /** * Whether the provider supports catch up for this benefit. This field will only be true for * retirement benefits. */ - @JsonProperty("catch_up") @ExcludeMissing fun _catchUp() = catchUp + @JsonProperty("catch_up") @ExcludeMissing fun _catchUp(): JsonField = catchUp /** * Supported contribution types. An empty array indicates contributions are not supported. */ @JsonProperty("company_contribution") @ExcludeMissing - fun _companyContribution() = companyContribution + fun _companyContribution(): JsonField> = companyContribution - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** Supported deduction types. An empty array indicates deductions are not supported. */ @JsonProperty("employee_deduction") @ExcludeMissing - fun _employeeDeduction() = employeeDeduction + fun _employeeDeduction(): JsonField> = employeeDeduction /** The list of frequencies supported by the provider for this benefit */ - @JsonProperty("frequencies") @ExcludeMissing fun _frequencies() = frequencies + @JsonProperty("frequencies") + @ExcludeMissing + fun _frequencies(): JsonField> = frequencies /** * Whether the provider supports HSA contribution limits. Empty if this feature is not @@ -213,7 +221,7 @@ private constructor( */ @JsonProperty("hsa_contribution_limit") @ExcludeMissing - fun _hsaContributionLimit() = hsaContributionLimit + fun _hsaContributionLimit(): JsonField> = hsaContributionLimit @JsonAnyGetter @ExcludeMissing @@ -245,29 +253,37 @@ private constructor( private var annualMaximum: JsonField = JsonMissing.of() private var catchUp: JsonField = JsonMissing.of() - private var companyContribution: JsonField> = - JsonMissing.of() + private var companyContribution: JsonField>? = null private var description: JsonField = JsonMissing.of() - private var employeeDeduction: JsonField> = JsonMissing.of() - private var frequencies: JsonField> = JsonMissing.of() - private var hsaContributionLimit: 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 + companyContribution = benefitFeature.companyContribution.map { it.toMutableList() } description = benefitFeature.description - employeeDeduction = benefitFeature.employeeDeduction - frequencies = benefitFeature.frequencies - hsaContributionLimit = benefitFeature.hsaContributionLimit + 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.of(annualMaximum)) + fun annualMaximum(annualMaximum: Boolean?) = + annualMaximum(JsonField.ofNullable(annualMaximum)) + + /** Whether the provider supports an annual maximum for this benefit. */ + fun annualMaximum(annualMaximum: Boolean) = annualMaximum(annualMaximum as Boolean?) + + /** Whether the provider supports an annual maximum for this benefit. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun annualMaximum(annualMaximum: Optional) = + annualMaximum(annualMaximum.orElse(null) as Boolean?) /** Whether the provider supports an annual maximum for this benefit. */ fun annualMaximum(annualMaximum: JsonField) = apply { @@ -278,7 +294,20 @@ private constructor( * Whether the provider supports catch up for this benefit. This field will only be true * for retirement benefits. */ - fun catchUp(catchUp: Boolean) = catchUp(JsonField.of(catchUp)) + fun catchUp(catchUp: Boolean?) = catchUp(JsonField.ofNullable(catchUp)) + + /** + * Whether the provider supports catch up for this benefit. This field will only be true + * for retirement benefits. + */ + fun catchUp(catchUp: Boolean) = catchUp(catchUp as Boolean?) + + /** + * Whether the provider supports catch up for this benefit. This field will only be true + * for retirement benefits. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun catchUp(catchUp: Optional) = catchUp(catchUp.orElse(null) as Boolean?) /** * Whether the provider supports catch up for this benefit. This field will only be true @@ -290,8 +319,15 @@ private constructor( * Supported contribution types. An empty array indicates contributions are not * supported. */ - fun companyContribution(companyContribution: List) = - companyContribution(JsonField.of(companyContribution)) + fun companyContribution(companyContribution: List?) = + companyContribution(JsonField.ofNullable(companyContribution)) + + /** + * Supported contribution types. An empty array indicates contributions are not + * supported. + */ + fun companyContribution(companyContribution: Optional>) = + companyContribution(companyContribution.orElse(null)) /** * Supported contribution types. An empty array indicates contributions are not @@ -299,22 +335,59 @@ private constructor( */ fun companyContribution(companyContribution: JsonField>) = apply { - this.companyContribution = companyContribution + this.companyContribution = companyContribution.map { it.toMutableList() } } - fun description(description: String) = description(JsonField.of(description)) + /** + * Supported contribution types. An empty array indicates contributions are not + * supported. + */ + fun addCompanyContribution(companyContribution: CompanyContribution) = apply { + this.companyContribution = + (this.companyContribution ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(companyContribution) + } + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) 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.of(employeeDeduction)) + fun employeeDeduction(employeeDeduction: List?) = + employeeDeduction(JsonField.ofNullable(employeeDeduction)) + + /** Supported deduction types. An empty array indicates deductions are not supported. */ + fun employeeDeduction(employeeDeduction: Optional>) = + employeeDeduction(employeeDeduction.orElse(null)) /** Supported deduction types. An empty array indicates deductions are not supported. */ fun employeeDeduction(employeeDeduction: JsonField>) = apply { - this.employeeDeduction = employeeDeduction + this.employeeDeduction = employeeDeduction.map { it.toMutableList() } + } + + /** Supported deduction types. An empty array indicates deductions are not supported. */ + fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { + this.employeeDeduction = + (this.employeeDeduction ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(employeeDeduction) + } } /** The list of frequencies supported by the provider for this benefit */ @@ -323,15 +396,36 @@ private constructor( /** The list of frequencies supported by the provider for this benefit */ fun frequencies(frequencies: JsonField>) = apply { - this.frequencies = frequencies + this.frequencies = frequencies.map { it.toMutableList() } + } + + /** The list of frequencies supported by the provider for this benefit */ + fun addFrequency(frequency: BenefitFrequency) = apply { + frequencies = + (frequencies ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .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.of(hsaContributionLimit)) + fun hsaContributionLimit(hsaContributionLimit: List?) = + hsaContributionLimit(JsonField.ofNullable(hsaContributionLimit)) + + /** + * 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: Optional>) = + hsaContributionLimit(hsaContributionLimit.orElse(null)) /** * Whether the provider supports HSA contribution limits. Empty if this feature is not @@ -339,9 +433,26 @@ private constructor( */ fun hsaContributionLimit(hsaContributionLimit: JsonField>) = apply { - this.hsaContributionLimit = hsaContributionLimit + this.hsaContributionLimit = hsaContributionLimit.map { it.toMutableList() } } + /** + * 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 addHsaContributionLimit(hsaContributionLimit: HsaContributionLimit) = apply { + this.hsaContributionLimit = + (this.hsaContributionLimit ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(hsaContributionLimit) + } + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -365,11 +476,11 @@ private constructor( BenefitFeature( annualMaximum, catchUp, - companyContribution.map { it.toImmutable() }, + (companyContribution ?: JsonMissing.of()).map { it.toImmutable() }, description, - employeeDeduction.map { it.toImmutable() }, - frequencies.map { it.toImmutable() }, - hsaContributionLimit.map { it.toImmutable() }, + (employeeDeduction ?: JsonMissing.of()).map { it.toImmutable() }, + (frequencies ?: JsonMissing.of()).map { it.toImmutable() }, + (hsaContributionLimit ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitsSupport.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitsSupport.kt index 06e19af6..814f1c40 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitsSupport.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/BenefitsSupport.kt @@ -99,29 +99,53 @@ private constructor( fun simpleIra(): Optional = Optional.ofNullable(simpleIra.getNullable("simple_ira")) - @JsonProperty("commuter") @ExcludeMissing fun _commuter() = commuter + @JsonProperty("commuter") + @ExcludeMissing + fun _commuter(): JsonField = commuter - @JsonProperty("custom_post_tax") @ExcludeMissing fun _customPostTax() = customPostTax + @JsonProperty("custom_post_tax") + @ExcludeMissing + fun _customPostTax(): JsonField = customPostTax - @JsonProperty("custom_pre_tax") @ExcludeMissing fun _customPreTax() = customPreTax + @JsonProperty("custom_pre_tax") + @ExcludeMissing + fun _customPreTax(): JsonField = customPreTax - @JsonProperty("fsa_dependent_care") @ExcludeMissing fun _fsaDependentCare() = fsaDependentCare + @JsonProperty("fsa_dependent_care") + @ExcludeMissing + fun _fsaDependentCare(): JsonField = fsaDependentCare - @JsonProperty("fsa_medical") @ExcludeMissing fun _fsaMedical() = fsaMedical + @JsonProperty("fsa_medical") + @ExcludeMissing + fun _fsaMedical(): JsonField = fsaMedical - @JsonProperty("hsa_post") @ExcludeMissing fun _hsaPost() = hsaPost + @JsonProperty("hsa_post") + @ExcludeMissing + fun _hsaPost(): JsonField = hsaPost - @JsonProperty("hsa_pre") @ExcludeMissing fun _hsaPre() = hsaPre + @JsonProperty("hsa_pre") + @ExcludeMissing + fun _hsaPre(): JsonField = hsaPre - @JsonProperty("s125_dental") @ExcludeMissing fun _s125Dental() = s125Dental + @JsonProperty("s125_dental") + @ExcludeMissing + fun _s125Dental(): JsonField = s125Dental - @JsonProperty("s125_medical") @ExcludeMissing fun _s125Medical() = s125Medical + @JsonProperty("s125_medical") + @ExcludeMissing + fun _s125Medical(): JsonField = s125Medical - @JsonProperty("s125_vision") @ExcludeMissing fun _s125Vision() = s125Vision + @JsonProperty("s125_vision") + @ExcludeMissing + fun _s125Vision(): JsonField = s125Vision - @JsonProperty("simple") @ExcludeMissing fun _simple() = simple + @JsonProperty("simple") + @ExcludeMissing + fun _simple(): JsonField = simple - @JsonProperty("simple_ira") @ExcludeMissing fun _simpleIra() = simpleIra + @JsonProperty("simple_ira") + @ExcludeMissing + fun _simpleIra(): JsonField = simpleIra @JsonAnyGetter @ExcludeMissing @@ -187,76 +211,111 @@ private constructor( additionalProperties = benefitsSupport.additionalProperties.toMutableMap() } - fun commuter(commuter: BenefitFeaturesAndOperations) = commuter(JsonField.of(commuter)) + fun commuter(commuter: BenefitFeaturesAndOperations?) = + commuter(JsonField.ofNullable(commuter)) + + fun commuter(commuter: Optional) = + commuter(commuter.orElse(null)) fun commuter(commuter: JsonField) = apply { this.commuter = commuter } - fun customPostTax(customPostTax: BenefitFeaturesAndOperations) = - customPostTax(JsonField.of(customPostTax)) + fun customPostTax(customPostTax: BenefitFeaturesAndOperations?) = + customPostTax(JsonField.ofNullable(customPostTax)) + + fun customPostTax(customPostTax: Optional) = + customPostTax(customPostTax.orElse(null)) fun customPostTax(customPostTax: JsonField) = apply { this.customPostTax = customPostTax } - fun customPreTax(customPreTax: BenefitFeaturesAndOperations) = - customPreTax(JsonField.of(customPreTax)) + fun customPreTax(customPreTax: BenefitFeaturesAndOperations?) = + customPreTax(JsonField.ofNullable(customPreTax)) + + fun customPreTax(customPreTax: Optional) = + customPreTax(customPreTax.orElse(null)) fun customPreTax(customPreTax: JsonField) = apply { this.customPreTax = customPreTax } - fun fsaDependentCare(fsaDependentCare: BenefitFeaturesAndOperations) = - fsaDependentCare(JsonField.of(fsaDependentCare)) + fun fsaDependentCare(fsaDependentCare: BenefitFeaturesAndOperations?) = + fsaDependentCare(JsonField.ofNullable(fsaDependentCare)) + + fun fsaDependentCare(fsaDependentCare: Optional) = + fsaDependentCare(fsaDependentCare.orElse(null)) fun fsaDependentCare(fsaDependentCare: JsonField) = apply { this.fsaDependentCare = fsaDependentCare } - fun fsaMedical(fsaMedical: BenefitFeaturesAndOperations) = - fsaMedical(JsonField.of(fsaMedical)) + fun fsaMedical(fsaMedical: BenefitFeaturesAndOperations?) = + fsaMedical(JsonField.ofNullable(fsaMedical)) + + fun fsaMedical(fsaMedical: Optional) = + fsaMedical(fsaMedical.orElse(null)) fun fsaMedical(fsaMedical: JsonField) = apply { this.fsaMedical = fsaMedical } - fun hsaPost(hsaPost: BenefitFeaturesAndOperations) = hsaPost(JsonField.of(hsaPost)) + fun hsaPost(hsaPost: BenefitFeaturesAndOperations?) = hsaPost(JsonField.ofNullable(hsaPost)) + + fun hsaPost(hsaPost: Optional) = hsaPost(hsaPost.orElse(null)) fun hsaPost(hsaPost: JsonField) = apply { this.hsaPost = hsaPost } - fun hsaPre(hsaPre: BenefitFeaturesAndOperations) = hsaPre(JsonField.of(hsaPre)) + fun hsaPre(hsaPre: BenefitFeaturesAndOperations?) = hsaPre(JsonField.ofNullable(hsaPre)) + + fun hsaPre(hsaPre: Optional) = hsaPre(hsaPre.orElse(null)) fun hsaPre(hsaPre: JsonField) = apply { this.hsaPre = hsaPre } - fun s125Dental(s125Dental: BenefitFeaturesAndOperations) = - s125Dental(JsonField.of(s125Dental)) + fun s125Dental(s125Dental: BenefitFeaturesAndOperations?) = + s125Dental(JsonField.ofNullable(s125Dental)) + + fun s125Dental(s125Dental: Optional) = + s125Dental(s125Dental.orElse(null)) fun s125Dental(s125Dental: JsonField) = apply { this.s125Dental = s125Dental } - fun s125Medical(s125Medical: BenefitFeaturesAndOperations) = - s125Medical(JsonField.of(s125Medical)) + fun s125Medical(s125Medical: BenefitFeaturesAndOperations?) = + s125Medical(JsonField.ofNullable(s125Medical)) + + fun s125Medical(s125Medical: Optional) = + s125Medical(s125Medical.orElse(null)) fun s125Medical(s125Medical: JsonField) = apply { this.s125Medical = s125Medical } - fun s125Vision(s125Vision: BenefitFeaturesAndOperations) = - s125Vision(JsonField.of(s125Vision)) + fun s125Vision(s125Vision: BenefitFeaturesAndOperations?) = + s125Vision(JsonField.ofNullable(s125Vision)) + + fun s125Vision(s125Vision: Optional) = + s125Vision(s125Vision.orElse(null)) fun s125Vision(s125Vision: JsonField) = apply { this.s125Vision = s125Vision } - fun simple(simple: BenefitFeaturesAndOperations) = simple(JsonField.of(simple)) + fun simple(simple: BenefitFeaturesAndOperations?) = simple(JsonField.ofNullable(simple)) + + fun simple(simple: Optional) = simple(simple.orElse(null)) fun simple(simple: JsonField) = apply { this.simple = simple } - fun simpleIra(simpleIra: BenefitFeaturesAndOperations) = simpleIra(JsonField.of(simpleIra)) + fun simpleIra(simpleIra: BenefitFeaturesAndOperations?) = + simpleIra(JsonField.ofNullable(simpleIra)) + + fun simpleIra(simpleIra: Optional) = + simpleIra(simpleIra.orElse(null)) fun simpleIra(simpleIra: JsonField) = apply { this.simpleIra = simpleIra diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Company.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Company.kt index bca50d5c..a1cdba5f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Company.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Company.kt @@ -79,32 +79,38 @@ private constructor( Optional.ofNullable(primaryPhoneNumber.getNullable("primary_phone_number")) /** A stable Finch `id` (UUID v4) for the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** An array of bank account objects associated with the payroll/HRIS system. */ - @JsonProperty("accounts") @ExcludeMissing fun _accounts() = accounts + @JsonProperty("accounts") @ExcludeMissing fun _accounts(): JsonField> = accounts /** The array of company departments. */ - @JsonProperty("departments") @ExcludeMissing fun _departments() = departments + @JsonProperty("departments") + @ExcludeMissing + fun _departments(): JsonField> = departments /** The employer identification number. */ - @JsonProperty("ein") @ExcludeMissing fun _ein() = ein + @JsonProperty("ein") @ExcludeMissing fun _ein(): JsonField = ein /** The entity type object. */ - @JsonProperty("entity") @ExcludeMissing fun _entity() = entity + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity /** The legal name of the company. */ - @JsonProperty("legal_name") @ExcludeMissing fun _legalName() = legalName + @JsonProperty("legal_name") @ExcludeMissing fun _legalName(): JsonField = legalName - @JsonProperty("locations") @ExcludeMissing fun _locations() = locations + @JsonProperty("locations") + @ExcludeMissing + fun _locations(): JsonField> = locations /** The email of the main administrator on the account. */ - @JsonProperty("primary_email") @ExcludeMissing fun _primaryEmail() = primaryEmail + @JsonProperty("primary_email") + @ExcludeMissing + fun _primaryEmail(): JsonField = primaryEmail /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ @JsonProperty("primary_phone_number") @ExcludeMissing - fun _primaryPhoneNumber() = primaryPhoneNumber + fun _primaryPhoneNumber(): JsonField = primaryPhoneNumber @JsonAnyGetter @ExcludeMissing @@ -136,26 +142,26 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var accounts: JsonField> = JsonMissing.of() - private var departments: JsonField> = JsonMissing.of() - private var ein: JsonField = JsonMissing.of() - private var entity: JsonField = JsonMissing.of() - private var legalName: JsonField = JsonMissing.of() - private var locations: JsonField> = JsonMissing.of() - private var primaryEmail: JsonField = JsonMissing.of() - private var primaryPhoneNumber: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var accounts: JsonField>? = null + private var departments: JsonField>? = null + private var ein: JsonField? = null + private var entity: JsonField? = null + private var legalName: JsonField? = null + private var locations: JsonField>? = null + private var primaryEmail: JsonField? = null + private var primaryPhoneNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(company: Company) = apply { id = company.id - accounts = company.accounts - departments = company.departments + accounts = company.accounts.map { it.toMutableList() } + departments = company.departments.map { it.toMutableList() } ein = company.ein entity = company.entity legalName = company.legalName - locations = company.locations + locations = company.locations.map { it.toMutableList() } primaryEmail = company.primaryEmail primaryPhoneNumber = company.primaryPhoneNumber additionalProperties = company.additionalProperties.toMutableMap() @@ -168,43 +174,110 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** An array of bank account objects associated with the payroll/HRIS system. */ - fun accounts(accounts: List) = accounts(JsonField.of(accounts)) + fun accounts(accounts: List?) = accounts(JsonField.ofNullable(accounts)) + + /** An array of bank account objects associated with the payroll/HRIS system. */ + fun accounts(accounts: Optional>) = accounts(accounts.orElse(null)) /** An array of bank account objects associated with the payroll/HRIS system. */ - fun accounts(accounts: JsonField>) = apply { this.accounts = accounts } + fun accounts(accounts: JsonField>) = apply { + this.accounts = accounts.map { it.toMutableList() } + } + + /** An array of bank account objects associated with the payroll/HRIS system. */ + fun addAccount(account: Account) = apply { + accounts = + (accounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(account) + } + } /** The array of company departments. */ - fun departments(departments: List) = departments(JsonField.of(departments)) + fun departments(departments: List?) = + departments(JsonField.ofNullable(departments)) + + /** The array of company departments. */ + fun departments(departments: Optional>) = + departments(departments.orElse(null)) /** The array of company departments. */ fun departments(departments: JsonField>) = apply { - this.departments = departments + this.departments = departments.map { it.toMutableList() } + } + + /** The array of company departments. */ + fun addDepartment(department: Department) = apply { + departments = + (departments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(department) + } } /** The employer identification number. */ - fun ein(ein: String) = ein(JsonField.of(ein)) + fun ein(ein: String?) = ein(JsonField.ofNullable(ein)) + + /** The employer identification number. */ + fun ein(ein: Optional) = ein(ein.orElse(null)) /** The employer identification number. */ fun ein(ein: JsonField) = apply { this.ein = ein } /** The entity type object. */ - fun entity(entity: Entity) = entity(JsonField.of(entity)) + fun entity(entity: Entity?) = entity(JsonField.ofNullable(entity)) + + /** The entity type object. */ + fun entity(entity: Optional) = entity(entity.orElse(null)) /** The entity type object. */ fun entity(entity: JsonField) = apply { this.entity = entity } /** The legal name of the company. */ - fun legalName(legalName: String) = legalName(JsonField.of(legalName)) + fun legalName(legalName: String?) = legalName(JsonField.ofNullable(legalName)) + + /** The legal name of the company. */ + fun legalName(legalName: Optional) = legalName(legalName.orElse(null)) /** The legal name of the company. */ fun legalName(legalName: JsonField) = apply { this.legalName = legalName } - fun locations(locations: List) = locations(JsonField.of(locations)) + fun locations(locations: List?) = locations(JsonField.ofNullable(locations)) - fun locations(locations: JsonField>) = apply { this.locations = locations } + fun locations(locations: Optional>) = locations(locations.orElse(null)) + + fun locations(locations: JsonField>) = apply { + this.locations = locations.map { it.toMutableList() } + } + + fun addLocation(location: Location) = apply { + locations = + (locations ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(location) + } + } /** The email of the main administrator on the account. */ - fun primaryEmail(primaryEmail: String) = primaryEmail(JsonField.of(primaryEmail)) + fun primaryEmail(primaryEmail: String?) = primaryEmail(JsonField.ofNullable(primaryEmail)) + + /** The email of the main administrator on the account. */ + fun primaryEmail(primaryEmail: Optional) = primaryEmail(primaryEmail.orElse(null)) /** The email of the main administrator on the account. */ fun primaryEmail(primaryEmail: JsonField) = apply { @@ -212,8 +285,12 @@ private constructor( } /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ - fun primaryPhoneNumber(primaryPhoneNumber: String) = - primaryPhoneNumber(JsonField.of(primaryPhoneNumber)) + fun primaryPhoneNumber(primaryPhoneNumber: String?) = + primaryPhoneNumber(JsonField.ofNullable(primaryPhoneNumber)) + + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ + fun primaryPhoneNumber(primaryPhoneNumber: Optional) = + primaryPhoneNumber(primaryPhoneNumber.orElse(null)) /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ fun primaryPhoneNumber(primaryPhoneNumber: JsonField) = apply { @@ -241,15 +318,20 @@ private constructor( fun build(): Company = Company( - id, - accounts.map { it.toImmutable() }, - departments.map { it.toImmutable() }, - ein, - entity, - legalName, - locations.map { it.toImmutable() }, - primaryEmail, - primaryPhoneNumber, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(accounts) { "`accounts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(departments) { "`departments` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(ein) { "`ein` is required but was not set" }, + checkNotNull(entity) { "`entity` is required but was not set" }, + checkNotNull(legalName) { "`legalName` is required but was not set" }, + checkNotNull(locations) { "`locations` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(primaryEmail) { "`primaryEmail` is required but was not set" }, + checkNotNull(primaryPhoneNumber) { + "`primaryPhoneNumber` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -300,21 +382,31 @@ private constructor( Optional.ofNullable(routingNumber.getNullable("routing_number")) /** The name of the bank associated in the payroll/HRIS system. */ - @JsonProperty("account_name") @ExcludeMissing fun _accountName() = accountName + @JsonProperty("account_name") + @ExcludeMissing + fun _accountName(): JsonField = accountName /** 10-12 digit number to specify the bank account */ - @JsonProperty("account_number") @ExcludeMissing fun _accountNumber() = accountNumber + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber /** The type of bank account. */ - @JsonProperty("account_type") @ExcludeMissing fun _accountType() = accountType + @JsonProperty("account_type") + @ExcludeMissing + fun _accountType(): JsonField = accountType /** Name of the banking institution. */ - @JsonProperty("institution_name") @ExcludeMissing fun _institutionName() = institutionName + @JsonProperty("institution_name") + @ExcludeMissing + fun _institutionName(): JsonField = institutionName /** * A nine-digit code that's based on the U.S. Bank location where your account was opened. */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber @JsonAnyGetter @ExcludeMissing @@ -360,7 +452,10 @@ private constructor( } /** The name of the bank associated in the payroll/HRIS system. */ - fun accountName(accountName: String) = accountName(JsonField.of(accountName)) + fun accountName(accountName: String?) = accountName(JsonField.ofNullable(accountName)) + + /** The name of the bank associated in the payroll/HRIS system. */ + fun accountName(accountName: Optional) = accountName(accountName.orElse(null)) /** The name of the bank associated in the payroll/HRIS system. */ fun accountName(accountName: JsonField) = apply { @@ -368,7 +463,12 @@ private constructor( } /** 10-12 digit number to specify the bank account */ - fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) + fun accountNumber(accountNumber: String?) = + accountNumber(JsonField.ofNullable(accountNumber)) + + /** 10-12 digit number to specify the bank account */ + fun accountNumber(accountNumber: Optional) = + accountNumber(accountNumber.orElse(null)) /** 10-12 digit number to specify the bank account */ fun accountNumber(accountNumber: JsonField) = apply { @@ -376,7 +476,12 @@ private constructor( } /** The type of bank account. */ - fun accountType(accountType: AccountType) = accountType(JsonField.of(accountType)) + fun accountType(accountType: AccountType?) = + accountType(JsonField.ofNullable(accountType)) + + /** The type of bank account. */ + fun accountType(accountType: Optional) = + accountType(accountType.orElse(null)) /** The type of bank account. */ fun accountType(accountType: JsonField) = apply { @@ -384,8 +489,12 @@ private constructor( } /** Name of the banking institution. */ - fun institutionName(institutionName: String) = - institutionName(JsonField.of(institutionName)) + fun institutionName(institutionName: String?) = + institutionName(JsonField.ofNullable(institutionName)) + + /** Name of the banking institution. */ + fun institutionName(institutionName: Optional) = + institutionName(institutionName.orElse(null)) /** Name of the banking institution. */ fun institutionName(institutionName: JsonField) = apply { @@ -396,7 +505,15 @@ private constructor( * A nine-digit code that's based on the U.S. Bank location where your account was * opened. */ - fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) + fun routingNumber(routingNumber: String?) = + routingNumber(JsonField.ofNullable(routingNumber)) + + /** + * A nine-digit code that's based on the U.S. Bank location where your account was + * opened. + */ + fun routingNumber(routingNumber: Optional) = + routingNumber(routingNumber.orElse(null)) /** * A nine-digit code that's based on the U.S. Bank location where your account was @@ -532,10 +649,10 @@ private constructor( fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) /** The department name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The parent department, if present. */ - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent @JsonAnyGetter @ExcludeMissing @@ -572,13 +689,19 @@ private constructor( } /** The department name. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The department name. */ + fun name(name: Optional) = name(name.orElse(null)) /** The department name. */ fun name(name: JsonField) = apply { this.name = name } /** The parent department, if present. */ - fun parent(parent: Parent) = parent(JsonField.of(parent)) + fun parent(parent: Parent?) = parent(JsonField.ofNullable(parent)) + + /** The parent department, if present. */ + fun parent(parent: Optional) = parent(parent.orElse(null)) /** The parent department, if present. */ fun parent(parent: JsonField) = apply { this.parent = parent } @@ -626,7 +749,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The parent department's name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -660,7 +783,10 @@ private constructor( } /** The parent department's name. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The parent department's name. */ + fun name(name: Optional) = name(name.orElse(null)) /** The parent department's name. */ fun name(name: JsonField) = apply { this.name = name } @@ -746,10 +872,10 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** The tax payer subtype of the company. */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** The tax payer type of the company. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -786,13 +912,19 @@ private constructor( } /** The tax payer subtype of the company. */ - fun subtype(subtype: Subtype) = subtype(JsonField.of(subtype)) + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) + + /** The tax payer subtype of the company. */ + fun subtype(subtype: Optional) = subtype(subtype.orElse(null)) /** The tax payer subtype of the company. */ fun subtype(subtype: JsonField) = apply { this.subtype = subtype } /** The tax payer type of the company. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** The tax payer type of the company. */ + fun type(type: Optional) = type(type.orElse(null)) /** The tax payer type of the company. */ fun type(type: JsonField) = apply { this.type = type } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt index d1ba1f43..b7d1a27e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyBenefit.kt @@ -46,14 +46,16 @@ private constructor( /** Type of benefit. */ fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId() = benefitId + @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId(): JsonField = benefitId - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - @JsonProperty("frequency") @ExcludeMissing fun _frequency() = frequency + @JsonProperty("frequency") + @ExcludeMissing + fun _frequency(): JsonField = frequency /** Type of benefit. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -80,10 +82,10 @@ private constructor( class Builder { - private var benefitId: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var frequency: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var benefitId: JsonField? = null + private var description: JsonField? = null + private var frequency: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -99,16 +101,23 @@ private constructor( fun benefitId(benefitId: JsonField) = apply { this.benefitId = benefitId } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description } - fun frequency(frequency: BenefitFrequency) = frequency(JsonField.of(frequency)) + fun frequency(frequency: BenefitFrequency?) = frequency(JsonField.ofNullable(frequency)) + + fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) fun frequency(frequency: JsonField) = apply { this.frequency = frequency } /** Type of benefit. */ - fun type(type: BenefitType) = type(JsonField.of(type)) + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + + /** Type of benefit. */ + fun type(type: Optional) = type(type.orElse(null)) /** Type of benefit. */ fun type(type: JsonField) = apply { this.type = type } @@ -134,10 +143,10 @@ private constructor( fun build(): CompanyBenefit = CompanyBenefit( - benefitId, - description, - frequency, - type, + checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(frequency) { "`frequency` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyEvent.kt index db775844..e411a503 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyEvent.kt @@ -62,20 +62,22 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing @@ -110,8 +112,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var data: JsonField = JsonMissing.of() private var eventType: JsonField = JsonMissing.of() @@ -159,7 +161,9 @@ private constructor( this.connectionId = connectionId } - fun data(data: Data) = data(JsonField.of(data)) + fun data(data: Data?) = data(JsonField.ofNullable(data)) + + fun data(data: Optional) = data(data.orElse(null)) fun data(data: JsonField) = apply { this.data = data } @@ -188,8 +192,8 @@ private constructor( fun build(): CompanyEvent = CompanyEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, data, eventType, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyUpdateResponse.kt index d73e6600..50137d22 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CompanyUpdateResponse.kt @@ -75,29 +75,35 @@ private constructor( Optional.ofNullable(primaryPhoneNumber.getNullable("primary_phone_number")) /** An array of bank account objects associated with the payroll/HRIS system. */ - @JsonProperty("accounts") @ExcludeMissing fun _accounts() = accounts + @JsonProperty("accounts") @ExcludeMissing fun _accounts(): JsonField> = accounts /** The array of company departments. */ - @JsonProperty("departments") @ExcludeMissing fun _departments() = departments + @JsonProperty("departments") + @ExcludeMissing + fun _departments(): JsonField> = departments /** The employer identification number. */ - @JsonProperty("ein") @ExcludeMissing fun _ein() = ein + @JsonProperty("ein") @ExcludeMissing fun _ein(): JsonField = ein /** The entity type object. */ - @JsonProperty("entity") @ExcludeMissing fun _entity() = entity + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity /** The legal name of the company. */ - @JsonProperty("legal_name") @ExcludeMissing fun _legalName() = legalName + @JsonProperty("legal_name") @ExcludeMissing fun _legalName(): JsonField = legalName - @JsonProperty("locations") @ExcludeMissing fun _locations() = locations + @JsonProperty("locations") + @ExcludeMissing + fun _locations(): JsonField> = locations /** The email of the main administrator on the account. */ - @JsonProperty("primary_email") @ExcludeMissing fun _primaryEmail() = primaryEmail + @JsonProperty("primary_email") + @ExcludeMissing + fun _primaryEmail(): JsonField = primaryEmail /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ @JsonProperty("primary_phone_number") @ExcludeMissing - fun _primaryPhoneNumber() = primaryPhoneNumber + fun _primaryPhoneNumber(): JsonField = primaryPhoneNumber @JsonAnyGetter @ExcludeMissing @@ -128,67 +134,134 @@ private constructor( class Builder { - private var accounts: JsonField> = JsonMissing.of() - private var departments: JsonField> = JsonMissing.of() - private var ein: JsonField = JsonMissing.of() - private var entity: JsonField = JsonMissing.of() - private var legalName: JsonField = JsonMissing.of() - private var locations: JsonField> = JsonMissing.of() - private var primaryEmail: JsonField = JsonMissing.of() - private var primaryPhoneNumber: JsonField = JsonMissing.of() + private var accounts: JsonField>? = null + private var departments: JsonField>? = null + private var ein: JsonField? = null + private var entity: JsonField? = null + private var legalName: JsonField? = null + private var locations: JsonField>? = null + private var primaryEmail: JsonField? = null + private var primaryPhoneNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(companyUpdateResponse: CompanyUpdateResponse) = apply { - accounts = companyUpdateResponse.accounts - departments = companyUpdateResponse.departments + accounts = companyUpdateResponse.accounts.map { it.toMutableList() } + departments = companyUpdateResponse.departments.map { it.toMutableList() } ein = companyUpdateResponse.ein entity = companyUpdateResponse.entity legalName = companyUpdateResponse.legalName - locations = companyUpdateResponse.locations + locations = companyUpdateResponse.locations.map { it.toMutableList() } primaryEmail = companyUpdateResponse.primaryEmail primaryPhoneNumber = companyUpdateResponse.primaryPhoneNumber additionalProperties = companyUpdateResponse.additionalProperties.toMutableMap() } /** An array of bank account objects associated with the payroll/HRIS system. */ - fun accounts(accounts: List) = accounts(JsonField.of(accounts)) + fun accounts(accounts: List?) = accounts(JsonField.ofNullable(accounts)) + + /** An array of bank account objects associated with the payroll/HRIS system. */ + fun accounts(accounts: Optional>) = accounts(accounts.orElse(null)) /** An array of bank account objects associated with the payroll/HRIS system. */ - fun accounts(accounts: JsonField>) = apply { this.accounts = accounts } + fun accounts(accounts: JsonField>) = apply { + this.accounts = accounts.map { it.toMutableList() } + } + + /** An array of bank account objects associated with the payroll/HRIS system. */ + fun addAccount(account: Account) = apply { + accounts = + (accounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(account) + } + } /** The array of company departments. */ - fun departments(departments: List) = departments(JsonField.of(departments)) + fun departments(departments: List?) = + departments(JsonField.ofNullable(departments)) + + /** The array of company departments. */ + fun departments(departments: Optional>) = + departments(departments.orElse(null)) /** The array of company departments. */ fun departments(departments: JsonField>) = apply { - this.departments = departments + this.departments = departments.map { it.toMutableList() } + } + + /** The array of company departments. */ + fun addDepartment(department: Department) = apply { + departments = + (departments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(department) + } } /** The employer identification number. */ - fun ein(ein: String) = ein(JsonField.of(ein)) + fun ein(ein: String?) = ein(JsonField.ofNullable(ein)) + + /** The employer identification number. */ + fun ein(ein: Optional) = ein(ein.orElse(null)) /** The employer identification number. */ fun ein(ein: JsonField) = apply { this.ein = ein } /** The entity type object. */ - fun entity(entity: Entity) = entity(JsonField.of(entity)) + fun entity(entity: Entity?) = entity(JsonField.ofNullable(entity)) + + /** The entity type object. */ + fun entity(entity: Optional) = entity(entity.orElse(null)) /** The entity type object. */ fun entity(entity: JsonField) = apply { this.entity = entity } /** The legal name of the company. */ - fun legalName(legalName: String) = legalName(JsonField.of(legalName)) + fun legalName(legalName: String?) = legalName(JsonField.ofNullable(legalName)) + + /** The legal name of the company. */ + fun legalName(legalName: Optional) = legalName(legalName.orElse(null)) /** The legal name of the company. */ fun legalName(legalName: JsonField) = apply { this.legalName = legalName } - fun locations(locations: List) = locations(JsonField.of(locations)) + fun locations(locations: List?) = locations(JsonField.ofNullable(locations)) - fun locations(locations: JsonField>) = apply { this.locations = locations } + fun locations(locations: Optional>) = locations(locations.orElse(null)) + + fun locations(locations: JsonField>) = apply { + this.locations = locations.map { it.toMutableList() } + } + + fun addLocation(location: Location) = apply { + locations = + (locations ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(location) + } + } /** The email of the main administrator on the account. */ - fun primaryEmail(primaryEmail: String) = primaryEmail(JsonField.of(primaryEmail)) + fun primaryEmail(primaryEmail: String?) = primaryEmail(JsonField.ofNullable(primaryEmail)) + + /** The email of the main administrator on the account. */ + fun primaryEmail(primaryEmail: Optional) = primaryEmail(primaryEmail.orElse(null)) /** The email of the main administrator on the account. */ fun primaryEmail(primaryEmail: JsonField) = apply { @@ -196,8 +269,12 @@ private constructor( } /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ - fun primaryPhoneNumber(primaryPhoneNumber: String) = - primaryPhoneNumber(JsonField.of(primaryPhoneNumber)) + fun primaryPhoneNumber(primaryPhoneNumber: String?) = + primaryPhoneNumber(JsonField.ofNullable(primaryPhoneNumber)) + + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ + fun primaryPhoneNumber(primaryPhoneNumber: Optional) = + primaryPhoneNumber(primaryPhoneNumber.orElse(null)) /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ fun primaryPhoneNumber(primaryPhoneNumber: JsonField) = apply { @@ -225,14 +302,19 @@ private constructor( fun build(): CompanyUpdateResponse = CompanyUpdateResponse( - accounts.map { it.toImmutable() }, - departments.map { it.toImmutable() }, - ein, - entity, - legalName, - locations.map { it.toImmutable() }, - primaryEmail, - primaryPhoneNumber, + checkNotNull(accounts) { "`accounts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(departments) { "`departments` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(ein) { "`ein` is required but was not set" }, + checkNotNull(entity) { "`entity` is required but was not set" }, + checkNotNull(legalName) { "`legalName` is required but was not set" }, + checkNotNull(locations) { "`locations` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(primaryEmail) { "`primaryEmail` is required but was not set" }, + checkNotNull(primaryPhoneNumber) { + "`primaryPhoneNumber` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -283,21 +365,31 @@ private constructor( Optional.ofNullable(routingNumber.getNullable("routing_number")) /** The name of the bank associated in the payroll/HRIS system. */ - @JsonProperty("account_name") @ExcludeMissing fun _accountName() = accountName + @JsonProperty("account_name") + @ExcludeMissing + fun _accountName(): JsonField = accountName /** 10-12 digit number to specify the bank account */ - @JsonProperty("account_number") @ExcludeMissing fun _accountNumber() = accountNumber + @JsonProperty("account_number") + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber /** The type of bank account. */ - @JsonProperty("account_type") @ExcludeMissing fun _accountType() = accountType + @JsonProperty("account_type") + @ExcludeMissing + fun _accountType(): JsonField = accountType /** Name of the banking institution. */ - @JsonProperty("institution_name") @ExcludeMissing fun _institutionName() = institutionName + @JsonProperty("institution_name") + @ExcludeMissing + fun _institutionName(): JsonField = institutionName /** * A nine-digit code that's based on the U.S. Bank location where your account was opened. */ - @JsonProperty("routing_number") @ExcludeMissing fun _routingNumber() = routingNumber + @JsonProperty("routing_number") + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber @JsonAnyGetter @ExcludeMissing @@ -343,7 +435,10 @@ private constructor( } /** The name of the bank associated in the payroll/HRIS system. */ - fun accountName(accountName: String) = accountName(JsonField.of(accountName)) + fun accountName(accountName: String?) = accountName(JsonField.ofNullable(accountName)) + + /** The name of the bank associated in the payroll/HRIS system. */ + fun accountName(accountName: Optional) = accountName(accountName.orElse(null)) /** The name of the bank associated in the payroll/HRIS system. */ fun accountName(accountName: JsonField) = apply { @@ -351,7 +446,12 @@ private constructor( } /** 10-12 digit number to specify the bank account */ - fun accountNumber(accountNumber: String) = accountNumber(JsonField.of(accountNumber)) + fun accountNumber(accountNumber: String?) = + accountNumber(JsonField.ofNullable(accountNumber)) + + /** 10-12 digit number to specify the bank account */ + fun accountNumber(accountNumber: Optional) = + accountNumber(accountNumber.orElse(null)) /** 10-12 digit number to specify the bank account */ fun accountNumber(accountNumber: JsonField) = apply { @@ -359,7 +459,12 @@ private constructor( } /** The type of bank account. */ - fun accountType(accountType: AccountType) = accountType(JsonField.of(accountType)) + fun accountType(accountType: AccountType?) = + accountType(JsonField.ofNullable(accountType)) + + /** The type of bank account. */ + fun accountType(accountType: Optional) = + accountType(accountType.orElse(null)) /** The type of bank account. */ fun accountType(accountType: JsonField) = apply { @@ -367,8 +472,12 @@ private constructor( } /** Name of the banking institution. */ - fun institutionName(institutionName: String) = - institutionName(JsonField.of(institutionName)) + fun institutionName(institutionName: String?) = + institutionName(JsonField.ofNullable(institutionName)) + + /** Name of the banking institution. */ + fun institutionName(institutionName: Optional) = + institutionName(institutionName.orElse(null)) /** Name of the banking institution. */ fun institutionName(institutionName: JsonField) = apply { @@ -379,7 +488,15 @@ private constructor( * A nine-digit code that's based on the U.S. Bank location where your account was * opened. */ - fun routingNumber(routingNumber: String) = routingNumber(JsonField.of(routingNumber)) + fun routingNumber(routingNumber: String?) = + routingNumber(JsonField.ofNullable(routingNumber)) + + /** + * A nine-digit code that's based on the U.S. Bank location where your account was + * opened. + */ + fun routingNumber(routingNumber: Optional) = + routingNumber(routingNumber.orElse(null)) /** * A nine-digit code that's based on the U.S. Bank location where your account was @@ -515,10 +632,10 @@ private constructor( fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) /** The department name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The parent department, if present. */ - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent @JsonAnyGetter @ExcludeMissing @@ -555,13 +672,19 @@ private constructor( } /** The department name. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The department name. */ + fun name(name: Optional) = name(name.orElse(null)) /** The department name. */ fun name(name: JsonField) = apply { this.name = name } /** The parent department, if present. */ - fun parent(parent: Parent) = parent(JsonField.of(parent)) + fun parent(parent: Parent?) = parent(JsonField.ofNullable(parent)) + + /** The parent department, if present. */ + fun parent(parent: Optional) = parent(parent.orElse(null)) /** The parent department, if present. */ fun parent(parent: JsonField) = apply { this.parent = parent } @@ -609,7 +732,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The parent department's name. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -643,7 +766,10 @@ private constructor( } /** The parent department's name. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The parent department's name. */ + fun name(name: Optional) = name(name.orElse(null)) /** The parent department's name. */ fun name(name: JsonField) = apply { this.name = name } @@ -729,10 +855,10 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** The tax payer subtype of the company. */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** The tax payer type of the company. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -769,13 +895,19 @@ private constructor( } /** The tax payer subtype of the company. */ - fun subtype(subtype: Subtype) = subtype(JsonField.of(subtype)) + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) + + /** The tax payer subtype of the company. */ + fun subtype(subtype: Optional) = subtype(subtype.orElse(null)) /** The tax payer subtype of the company. */ fun subtype(subtype: JsonField) = apply { this.subtype = subtype } /** The tax payer type of the company. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** The tax payer type of the company. */ + fun type(type: Optional) = type(type.orElse(null)) /** The tax payer type of the company. */ fun type(type: JsonField) = apply { this.type = type } 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 47a87edd..98dd4ae6 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 @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -46,12 +47,31 @@ constructor( fun sandbox(): Optional = body.sandbox() - fun _additionalHeaders(): Headers = additionalHeaders + fun _customerId(): JsonField = body._customerId() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _customerName(): JsonField = body._customerName() + + fun _products(): JsonField> = body._products() + + fun _customerEmail(): JsonField = body._customerEmail() + + fun _integration(): JsonField = body._integration() + + fun _manual(): JsonField = body._manual() + + /** The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ + fun _minutesToExpire(): JsonField = body._minutesToExpire() + + fun _redirectUri(): JsonField = body._redirectUri() + + fun _sandbox(): JsonField = body._sandbox() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): ConnectSessionNewBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -62,48 +82,118 @@ constructor( class ConnectSessionNewBody @JsonCreator internal constructor( - @JsonProperty("customer_id") private val customerId: String, - @JsonProperty("customer_name") private val customerName: String, - @JsonProperty("products") private val products: List, - @JsonProperty("customer_email") private val customerEmail: String?, - @JsonProperty("integration") private val integration: Integration?, - @JsonProperty("manual") private val manual: Boolean?, - @JsonProperty("minutes_to_expire") private val minutesToExpire: Double?, - @JsonProperty("redirect_uri") private val redirectUri: String?, - @JsonProperty("sandbox") private val sandbox: Sandbox?, + @JsonProperty("customer_id") + @ExcludeMissing + private val customerId: JsonField = JsonMissing.of(), + @JsonProperty("customer_name") + @ExcludeMissing + private val customerName: JsonField = JsonMissing.of(), + @JsonProperty("products") + @ExcludeMissing + private val products: JsonField> = JsonMissing.of(), + @JsonProperty("customer_email") + @ExcludeMissing + private val customerEmail: JsonField = JsonMissing.of(), + @JsonProperty("integration") + @ExcludeMissing + private val integration: JsonField = JsonMissing.of(), + @JsonProperty("manual") + @ExcludeMissing + private val manual: JsonField = JsonMissing.of(), + @JsonProperty("minutes_to_expire") + @ExcludeMissing + private val minutesToExpire: JsonField = JsonMissing.of(), + @JsonProperty("redirect_uri") + @ExcludeMissing + private val redirectUri: JsonField = JsonMissing.of(), + @JsonProperty("sandbox") + @ExcludeMissing + private val sandbox: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("customer_id") fun customerId(): String = customerId + fun customerId(): String = customerId.getRequired("customer_id") - @JsonProperty("customer_name") fun customerName(): String = customerName + fun customerName(): String = customerName.getRequired("customer_name") + + fun products(): List = products.getRequired("products") + + fun customerEmail(): Optional = + Optional.ofNullable(customerEmail.getNullable("customer_email")) + + fun integration(): Optional = + Optional.ofNullable(integration.getNullable("integration")) + + fun manual(): Optional = Optional.ofNullable(manual.getNullable("manual")) + + /** + * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + */ + fun minutesToExpire(): Optional = + Optional.ofNullable(minutesToExpire.getNullable("minutes_to_expire")) - @JsonProperty("products") fun products(): List = products + fun redirectUri(): Optional = + Optional.ofNullable(redirectUri.getNullable("redirect_uri")) + + fun sandbox(): Optional = Optional.ofNullable(sandbox.getNullable("sandbox")) + + @JsonProperty("customer_id") + @ExcludeMissing + fun _customerId(): JsonField = customerId + + @JsonProperty("customer_name") + @ExcludeMissing + fun _customerName(): JsonField = customerName + + @JsonProperty("products") + @ExcludeMissing + fun _products(): JsonField> = products @JsonProperty("customer_email") - fun customerEmail(): Optional = Optional.ofNullable(customerEmail) + @ExcludeMissing + fun _customerEmail(): JsonField = customerEmail @JsonProperty("integration") - fun integration(): Optional = Optional.ofNullable(integration) + @ExcludeMissing + fun _integration(): JsonField = integration - @JsonProperty("manual") fun manual(): Optional = Optional.ofNullable(manual) + @JsonProperty("manual") @ExcludeMissing fun _manual(): JsonField = manual /** * The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ @JsonProperty("minutes_to_expire") - fun minutesToExpire(): Optional = Optional.ofNullable(minutesToExpire) + @ExcludeMissing + fun _minutesToExpire(): JsonField = minutesToExpire @JsonProperty("redirect_uri") - fun redirectUri(): Optional = Optional.ofNullable(redirectUri) + @ExcludeMissing + fun _redirectUri(): JsonField = redirectUri - @JsonProperty("sandbox") fun sandbox(): Optional = Optional.ofNullable(sandbox) + @JsonProperty("sandbox") @ExcludeMissing fun _sandbox(): JsonField = sandbox @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ConnectSessionNewBody = apply { + if (!validated) { + customerId() + customerName() + products() + customerEmail() + integration().map { it.validate() } + manual() + minutesToExpire() + redirectUri() + sandbox() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -113,22 +203,22 @@ constructor( class Builder { - private var customerId: String? = null - private var customerName: String? = null - private var products: MutableList? = null - private var customerEmail: String? = null - private var integration: Integration? = null - private var manual: Boolean? = null - private var minutesToExpire: Double? = null - private var redirectUri: String? = null - private var sandbox: Sandbox? = null + private var customerId: JsonField? = null + private var customerName: JsonField? = null + private var products: JsonField>? = null + private var customerEmail: JsonField = JsonMissing.of() + private var integration: JsonField = JsonMissing.of() + private var manual: JsonField = JsonMissing.of() + private var minutesToExpire: JsonField = JsonMissing.of() + private var redirectUri: JsonField = JsonMissing.of() + private var sandbox: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(connectSessionNewBody: ConnectSessionNewBody) = apply { customerId = connectSessionNewBody.customerId customerName = connectSessionNewBody.customerName - products = connectSessionNewBody.products.toMutableList() + products = connectSessionNewBody.products.map { it.toMutableList() } customerEmail = connectSessionNewBody.customerEmail integration = connectSessionNewBody.integration manual = connectSessionNewBody.manual @@ -138,42 +228,70 @@ constructor( additionalProperties = connectSessionNewBody.additionalProperties.toMutableMap() } - fun customerId(customerId: String) = apply { this.customerId = customerId } + fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + + fun customerName(customerName: String) = customerName(JsonField.of(customerName)) + + fun customerName(customerName: JsonField) = apply { + this.customerName = customerName + } - fun customerName(customerName: String) = apply { this.customerName = customerName } + fun products(products: List) = products(JsonField.of(products)) - fun products(products: List) = apply { - this.products = products.toMutableList() + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } } fun addProduct(product: ConnectProducts) = apply { - products = (products ?: mutableListOf()).apply { add(product) } + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } } - fun customerEmail(customerEmail: String?) = apply { this.customerEmail = customerEmail } + fun customerEmail(customerEmail: String?) = + customerEmail(JsonField.ofNullable(customerEmail)) fun customerEmail(customerEmail: Optional) = customerEmail(customerEmail.orElse(null)) - fun integration(integration: Integration?) = apply { this.integration = integration } + fun customerEmail(customerEmail: JsonField) = apply { + this.customerEmail = customerEmail + } + + fun integration(integration: Integration?) = + integration(JsonField.ofNullable(integration)) fun integration(integration: Optional) = integration(integration.orElse(null)) - fun manual(manual: Boolean?) = apply { this.manual = manual } + fun integration(integration: JsonField) = apply { + this.integration = integration + } + + fun manual(manual: Boolean?) = manual(JsonField.ofNullable(manual)) fun manual(manual: Boolean) = manual(manual as Boolean?) @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun manual(manual: Optional) = manual(manual.orElse(null) as Boolean?) + fun manual(manual: JsonField) = apply { this.manual = manual } + /** * The number of minutes until the session expires (defaults to 20,160, which is 14 * days) */ - fun minutesToExpire(minutesToExpire: Double?) = apply { - this.minutesToExpire = minutesToExpire - } + fun minutesToExpire(minutesToExpire: Double?) = + minutesToExpire(JsonField.ofNullable(minutesToExpire)) /** * The number of minutes until the session expires (defaults to 20,160, which is 14 @@ -190,14 +308,28 @@ constructor( fun minutesToExpire(minutesToExpire: Optional) = minutesToExpire(minutesToExpire.orElse(null) as Double?) - fun redirectUri(redirectUri: String?) = apply { this.redirectUri = redirectUri } + /** + * The number of minutes until the session expires (defaults to 20,160, which is 14 + * days) + */ + fun minutesToExpire(minutesToExpire: JsonField) = apply { + this.minutesToExpire = minutesToExpire + } + + fun redirectUri(redirectUri: String?) = redirectUri(JsonField.ofNullable(redirectUri)) fun redirectUri(redirectUri: Optional) = redirectUri(redirectUri.orElse(null)) - fun sandbox(sandbox: Sandbox?) = apply { this.sandbox = sandbox } + fun redirectUri(redirectUri: JsonField) = apply { + this.redirectUri = redirectUri + } + + fun sandbox(sandbox: Sandbox?) = sandbox(JsonField.ofNullable(sandbox)) fun sandbox(sandbox: Optional) = sandbox(sandbox.orElse(null)) + fun sandbox(sandbox: JsonField) = apply { this.sandbox = sandbox } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -222,7 +354,7 @@ constructor( checkNotNull(customerId) { "`customerId` is required but was not set" }, checkNotNull(customerName) { "`customerName` is required but was not set" }, checkNotNull(products) { "`products` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, customerEmail, integration, manual, @@ -274,10 +406,18 @@ constructor( fun customerId(customerId: String) = apply { body.customerId(customerId) } + fun customerId(customerId: JsonField) = apply { body.customerId(customerId) } + fun customerName(customerName: String) = apply { body.customerName(customerName) } + fun customerName(customerName: JsonField) = apply { + body.customerName(customerName) + } + fun products(products: List) = apply { body.products(products) } + fun products(products: JsonField>) = apply { body.products(products) } + fun addProduct(product: ConnectProducts) = apply { body.addProduct(product) } fun customerEmail(customerEmail: String?) = apply { body.customerEmail(customerEmail) } @@ -285,10 +425,18 @@ constructor( fun customerEmail(customerEmail: Optional) = customerEmail(customerEmail.orElse(null)) + fun customerEmail(customerEmail: JsonField) = apply { + body.customerEmail(customerEmail) + } + fun integration(integration: Integration?) = apply { body.integration(integration) } fun integration(integration: Optional) = integration(integration.orElse(null)) + fun integration(integration: JsonField) = apply { + body.integration(integration) + } + fun manual(manual: Boolean?) = apply { body.manual(manual) } fun manual(manual: Boolean) = manual(manual as Boolean?) @@ -296,6 +444,8 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun manual(manual: Optional) = manual(manual.orElse(null) as Boolean?) + fun manual(manual: JsonField) = apply { body.manual(manual) } + /** * The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ @@ -315,14 +465,44 @@ constructor( fun minutesToExpire(minutesToExpire: Optional) = minutesToExpire(minutesToExpire.orElse(null) as Double?) + /** + * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + */ + fun minutesToExpire(minutesToExpire: JsonField) = apply { + body.minutesToExpire(minutesToExpire) + } + fun redirectUri(redirectUri: String?) = apply { body.redirectUri(redirectUri) } fun redirectUri(redirectUri: Optional) = redirectUri(redirectUri.orElse(null)) + fun redirectUri(redirectUri: JsonField) = apply { body.redirectUri(redirectUri) } + fun sandbox(sandbox: Sandbox?) = apply { body.sandbox(sandbox) } fun sandbox(sandbox: Optional) = sandbox(sandbox.orElse(null)) + fun sandbox(sandbox: JsonField) = apply { body.sandbox(sandbox) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -421,25 +601,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): ConnectSessionNewParams = ConnectSessionNewParams( body.build(), @@ -545,21 +706,41 @@ constructor( class Integration @JsonCreator private constructor( - @JsonProperty("auth_method") private val authMethod: AuthMethod?, - @JsonProperty("provider") private val provider: String?, + @JsonProperty("auth_method") + @ExcludeMissing + private val authMethod: JsonField = JsonMissing.of(), + @JsonProperty("provider") + @ExcludeMissing + private val provider: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun authMethod(): Optional = + Optional.ofNullable(authMethod.getNullable("auth_method")) + + fun provider(): Optional = Optional.ofNullable(provider.getNullable("provider")) + @JsonProperty("auth_method") - fun authMethod(): Optional = Optional.ofNullable(authMethod) + @ExcludeMissing + fun _authMethod(): JsonField = authMethod - @JsonProperty("provider") fun provider(): Optional = Optional.ofNullable(provider) + @JsonProperty("provider") @ExcludeMissing fun _provider(): JsonField = provider @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Integration = apply { + if (!validated) { + authMethod() + provider() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -569,8 +750,8 @@ constructor( class Builder { - private var authMethod: AuthMethod? = null - private var provider: String? = null + private var authMethod: JsonField = JsonMissing.of() + private var provider: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -580,14 +761,20 @@ constructor( additionalProperties = integration.additionalProperties.toMutableMap() } - fun authMethod(authMethod: AuthMethod?) = apply { this.authMethod = authMethod } + fun authMethod(authMethod: AuthMethod?) = authMethod(JsonField.ofNullable(authMethod)) fun authMethod(authMethod: Optional) = authMethod(authMethod.orElse(null)) - fun provider(provider: String?) = apply { this.provider = provider } + fun authMethod(authMethod: JsonField) = apply { + this.authMethod = authMethod + } + + fun provider(provider: String?) = provider(JsonField.ofNullable(provider)) fun provider(provider: Optional) = provider(provider.orElse(null)) + fun provider(provider: JsonField) = apply { this.provider = provider } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParams.kt index 29fccb13..6698afa5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectSessionReauthenticateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -39,12 +40,24 @@ constructor( /** The URI to redirect to after the Connect flow is completed */ fun redirectUri(): Optional = body.redirectUri() - fun _additionalHeaders(): Headers = additionalHeaders + /** The ID of the existing connection to reauthenticate */ + fun _connectionId(): JsonField = body._connectionId() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ + fun _minutesToExpire(): JsonField = body._minutesToExpire() + + /** The products to request access to (optional for reauthentication) */ + fun _products(): JsonField> = body._products() + + /** The URI to redirect to after the Connect flow is completed */ + fun _redirectUri(): JsonField = body._redirectUri() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): ConnectSessionReauthenticateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -55,35 +68,77 @@ constructor( class ConnectSessionReauthenticateBody @JsonCreator internal constructor( - @JsonProperty("connection_id") private val connectionId: String, - @JsonProperty("minutes_to_expire") private val minutesToExpire: Long?, - @JsonProperty("products") private val products: List?, - @JsonProperty("redirect_uri") private val redirectUri: String?, + @JsonProperty("connection_id") + @ExcludeMissing + private val connectionId: JsonField = JsonMissing.of(), + @JsonProperty("minutes_to_expire") + @ExcludeMissing + private val minutesToExpire: JsonField = JsonMissing.of(), + @JsonProperty("products") + @ExcludeMissing + private val products: JsonField> = JsonMissing.of(), + @JsonProperty("redirect_uri") + @ExcludeMissing + private val redirectUri: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The ID of the existing connection to reauthenticate */ - @JsonProperty("connection_id") fun connectionId(): String = connectionId + fun connectionId(): String = connectionId.getRequired("connection_id") + + /** + * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + */ + fun minutesToExpire(): Optional = + Optional.ofNullable(minutesToExpire.getNullable("minutes_to_expire")) + + /** The products to request access to (optional for reauthentication) */ + fun products(): Optional> = + Optional.ofNullable(products.getNullable("products")) + + /** The URI to redirect to after the Connect flow is completed */ + fun redirectUri(): Optional = + Optional.ofNullable(redirectUri.getNullable("redirect_uri")) + + /** The ID of the existing connection to reauthenticate */ + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId /** * The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ @JsonProperty("minutes_to_expire") - fun minutesToExpire(): Optional = Optional.ofNullable(minutesToExpire) + @ExcludeMissing + fun _minutesToExpire(): JsonField = minutesToExpire /** The products to request access to (optional for reauthentication) */ @JsonProperty("products") - fun products(): Optional> = Optional.ofNullable(products) + @ExcludeMissing + fun _products(): JsonField> = products /** The URI to redirect to after the Connect flow is completed */ @JsonProperty("redirect_uri") - fun redirectUri(): Optional = Optional.ofNullable(redirectUri) + @ExcludeMissing + fun _redirectUri(): JsonField = redirectUri @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ConnectSessionReauthenticateBody = apply { + if (!validated) { + connectionId() + minutesToExpire() + products() + redirectUri() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -93,10 +148,10 @@ constructor( class Builder { - private var connectionId: String? = null - private var minutesToExpire: Long? = null - private var products: MutableList? = null - private var redirectUri: String? = null + private var connectionId: JsonField? = null + private var minutesToExpire: JsonField = JsonMissing.of() + private var products: JsonField>? = null + private var redirectUri: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -104,22 +159,26 @@ constructor( apply { connectionId = connectSessionReauthenticateBody.connectionId minutesToExpire = connectSessionReauthenticateBody.minutesToExpire - products = connectSessionReauthenticateBody.products?.toMutableList() + products = connectSessionReauthenticateBody.products.map { it.toMutableList() } redirectUri = connectSessionReauthenticateBody.redirectUri additionalProperties = connectSessionReauthenticateBody.additionalProperties.toMutableMap() } /** The ID of the existing connection to reauthenticate */ - fun connectionId(connectionId: String) = apply { this.connectionId = connectionId } + fun connectionId(connectionId: String) = connectionId(JsonField.of(connectionId)) + + /** The ID of the existing connection to reauthenticate */ + fun connectionId(connectionId: JsonField) = apply { + this.connectionId = connectionId + } /** * The number of minutes until the session expires (defaults to 20,160, which is 14 * days) */ - fun minutesToExpire(minutesToExpire: Long?) = apply { - this.minutesToExpire = minutesToExpire - } + fun minutesToExpire(minutesToExpire: Long?) = + minutesToExpire(JsonField.ofNullable(minutesToExpire)) /** * The number of minutes until the session expires (defaults to 20,160, which is 14 @@ -135,26 +194,52 @@ constructor( fun minutesToExpire(minutesToExpire: Optional) = minutesToExpire(minutesToExpire.orElse(null) as Long?) - /** The products to request access to (optional for reauthentication) */ - fun products(products: List?) = apply { - this.products = products?.toMutableList() + /** + * The number of minutes until the session expires (defaults to 20,160, which is 14 + * days) + */ + fun minutesToExpire(minutesToExpire: JsonField) = apply { + this.minutesToExpire = minutesToExpire } + /** The products to request access to (optional for reauthentication) */ + fun products(products: List?) = + products(JsonField.ofNullable(products)) + /** The products to request access to (optional for reauthentication) */ fun products(products: Optional>) = products(products.orElse(null)) + /** The products to request access to (optional for reauthentication) */ + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + /** The products to request access to (optional for reauthentication) */ fun addProduct(product: ConnectProducts) = apply { - products = (products ?: mutableListOf()).apply { add(product) } + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } } /** The URI to redirect to after the Connect flow is completed */ - fun redirectUri(redirectUri: String?) = apply { this.redirectUri = redirectUri } + fun redirectUri(redirectUri: String?) = redirectUri(JsonField.ofNullable(redirectUri)) /** The URI to redirect to after the Connect flow is completed */ fun redirectUri(redirectUri: Optional) = redirectUri(redirectUri.orElse(null)) + /** The URI to redirect to after the Connect flow is completed */ + fun redirectUri(redirectUri: JsonField) = apply { + this.redirectUri = redirectUri + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -178,7 +263,7 @@ constructor( ConnectSessionReauthenticateBody( checkNotNull(connectionId) { "`connectionId` is required but was not set" }, minutesToExpire, - products?.toImmutable(), + (products ?: JsonMissing.of()).map { it.toImmutable() }, redirectUri, additionalProperties.toImmutable(), ) @@ -229,6 +314,11 @@ constructor( /** The ID of the existing connection to reauthenticate */ fun connectionId(connectionId: String) = apply { body.connectionId(connectionId) } + /** The ID of the existing connection to reauthenticate */ + fun connectionId(connectionId: JsonField) = apply { + body.connectionId(connectionId) + } + /** * The number of minutes until the session expires (defaults to 20,160, which is 14 days) */ @@ -248,12 +338,22 @@ constructor( fun minutesToExpire(minutesToExpire: Optional) = minutesToExpire(minutesToExpire.orElse(null) as Long?) + /** + * The number of minutes until the session expires (defaults to 20,160, which is 14 days) + */ + fun minutesToExpire(minutesToExpire: JsonField) = apply { + body.minutesToExpire(minutesToExpire) + } + /** The products to request access to (optional for reauthentication) */ fun products(products: List?) = apply { body.products(products) } /** The products to request access to (optional for reauthentication) */ fun products(products: Optional>) = products(products.orElse(null)) + /** The products to request access to (optional for reauthentication) */ + fun products(products: JsonField>) = apply { body.products(products) } + /** The products to request access to (optional for reauthentication) */ fun addProduct(product: ConnectProducts) = apply { body.addProduct(product) } @@ -263,6 +363,28 @@ constructor( /** The URI to redirect to after the Connect flow is completed */ fun redirectUri(redirectUri: Optional) = redirectUri(redirectUri.orElse(null)) + /** The URI to redirect to after the Connect flow is completed */ + fun redirectUri(redirectUri: JsonField) = apply { body.redirectUri(redirectUri) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -361,25 +483,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): ConnectSessionReauthenticateParams = ConnectSessionReauthenticateParams( body.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionCreateResponse.kt index 45a15e15..3917b3e3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ConnectionCreateResponse.kt @@ -70,27 +70,31 @@ private constructor( fun tokenType(): Optional = Optional.ofNullable(tokenType.getNullable("token_type")) - @JsonProperty("access_token") @ExcludeMissing fun _accessToken() = accessToken + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId @JsonProperty("authentication_type") @ExcludeMissing - fun _authenticationType() = authenticationType + fun _authenticationType(): JsonField = authenticationType /** [DEPRECATED] Use `connection_id` to associate a connection with an access token */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** The ID of the new connection */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("products") @ExcludeMissing fun _products() = products + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products /** The ID of the provider associated with the `access_token`. */ - @JsonProperty("provider_id") @ExcludeMissing fun _providerId() = providerId + @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField = providerId - @JsonProperty("token_type") @ExcludeMissing fun _tokenType() = tokenType + @JsonProperty("token_type") @ExcludeMissing fun _tokenType(): JsonField = tokenType @JsonAnyGetter @ExcludeMissing @@ -121,13 +125,13 @@ private constructor( class Builder { - private var accessToken: JsonField = JsonMissing.of() - private var accountId: JsonField = JsonMissing.of() - private var authenticationType: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() - private var connectionId: JsonField = JsonMissing.of() - private var products: JsonField> = JsonMissing.of() - private var providerId: JsonField = JsonMissing.of() + private var accessToken: JsonField? = null + private var accountId: JsonField? = null + private var authenticationType: JsonField? = null + private var companyId: JsonField? = null + private var connectionId: JsonField? = null + private var products: JsonField>? = null + private var providerId: JsonField? = null private var tokenType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -138,7 +142,7 @@ private constructor( authenticationType = connectionCreateResponse.authenticationType companyId = connectionCreateResponse.companyId connectionId = connectionCreateResponse.connectionId - products = connectionCreateResponse.products + products = connectionCreateResponse.products.map { it.toMutableList() } providerId = connectionCreateResponse.providerId tokenType = connectionCreateResponse.tokenType additionalProperties = connectionCreateResponse.additionalProperties.toMutableMap() @@ -177,7 +181,22 @@ private constructor( fun products(products: List) = products(JsonField.of(products)) - fun products(products: JsonField>) = apply { this.products = products } + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } + } /** The ID of the provider associated with the `access_token`. */ fun providerId(providerId: String) = providerId(JsonField.of(providerId)) @@ -210,13 +229,16 @@ private constructor( fun build(): ConnectionCreateResponse = ConnectionCreateResponse( - accessToken, - accountId, - authenticationType, - companyId, - connectionId, - products.map { it.toImmutable() }, - providerId, + checkNotNull(accessToken) { "`accessToken` is required but was not set" }, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(authenticationType) { + "`authenticationType` is required but was not set" + }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkNotNull(connectionId) { "`connectionId` is required but was not set" }, + checkNotNull(products) { "`products` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(providerId) { "`providerId` is required but was not set" }, tokenType, additionalProperties.toImmutable(), ) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateAccessTokenResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateAccessTokenResponse.kt index 95b4087a..35b8d58a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateAccessTokenResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateAccessTokenResponse.kt @@ -93,41 +93,49 @@ private constructor( fun tokenType(): Optional = Optional.ofNullable(tokenType.getNullable("token_type")) /** The access token for the connection. */ - @JsonProperty("access_token") @ExcludeMissing fun _accessToken() = accessToken + @JsonProperty("access_token") + @ExcludeMissing + fun _accessToken(): JsonField = accessToken /** [DEPRECATED] Use `connection_id` to identify the connection instead of this account ID. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** The type of application associated with a token. */ - @JsonProperty("client_type") @ExcludeMissing fun _clientType() = clientType + @JsonProperty("client_type") + @ExcludeMissing + fun _clientType(): JsonField = clientType /** [DEPRECATED] Use `connection_id` to identify the connection instead of this company ID. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** The Finch UUID of the connection associated with the `access_token`. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId /** * The type of the connection associated with the token. * - `provider` - connection to an external provider * - `finch` - finch-generated data. */ - @JsonProperty("connection_type") @ExcludeMissing fun _connectionType() = connectionType + @JsonProperty("connection_type") + @ExcludeMissing + fun _connectionType(): JsonField = connectionType /** An array of the authorized products associated with the `access_token`. */ - @JsonProperty("products") @ExcludeMissing fun _products() = products + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products /** The ID of the provider associated with the `access_token`. */ - @JsonProperty("provider_id") @ExcludeMissing fun _providerId() = providerId + @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField = providerId /** * The ID of your customer you provided to Finch when a connect session was created for this * connection. */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId() = customerId + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId /** The RFC 8693 token type (Finch uses `bearer` tokens) */ - @JsonProperty("token_type") @ExcludeMissing fun _tokenType() = tokenType + @JsonProperty("token_type") @ExcludeMissing fun _tokenType(): JsonField = tokenType @JsonAnyGetter @ExcludeMissing @@ -160,14 +168,14 @@ private constructor( class Builder { - private var accessToken: JsonField = JsonMissing.of() - private var accountId: JsonField = JsonMissing.of() - private var clientType: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() - private var connectionId: JsonField = JsonMissing.of() - private var connectionType: JsonField = JsonMissing.of() - private var products: JsonField> = JsonMissing.of() - private var providerId: JsonField = JsonMissing.of() + private var accessToken: JsonField? = null + private var accountId: JsonField? = null + private var clientType: JsonField? = null + private var companyId: JsonField? = null + private var connectionId: JsonField? = null + private var connectionType: JsonField? = null + private var products: JsonField>? = null + private var providerId: JsonField? = null private var customerId: JsonField = JsonMissing.of() private var tokenType: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -180,7 +188,7 @@ private constructor( companyId = createAccessTokenResponse.companyId connectionId = createAccessTokenResponse.connectionId connectionType = createAccessTokenResponse.connectionType - products = createAccessTokenResponse.products + products = createAccessTokenResponse.products.map { it.toMutableList() } providerId = createAccessTokenResponse.providerId customerId = createAccessTokenResponse.customerId tokenType = createAccessTokenResponse.tokenType @@ -248,7 +256,23 @@ private constructor( fun products(products: List) = products(JsonField.of(products)) /** An array of the authorized products associated with the `access_token`. */ - fun products(products: JsonField>) = apply { this.products = products } + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + /** An array of the authorized products associated with the `access_token`. */ + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } + } /** The ID of the provider associated with the `access_token`. */ fun providerId(providerId: String) = providerId(JsonField.of(providerId)) @@ -260,7 +284,13 @@ private constructor( * The ID of your customer you provided to Finch when a connect session was created for this * connection. */ - fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** + * The ID of your customer you provided to Finch when a connect session was created for this + * connection. + */ + fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) /** * The ID of your customer you provided to Finch when a connect session was created for this @@ -295,14 +325,15 @@ private constructor( fun build(): CreateAccessTokenResponse = CreateAccessTokenResponse( - accessToken, - accountId, - clientType, - companyId, - connectionId, - connectionType, - products.map { it.toImmutable() }, - providerId, + checkNotNull(accessToken) { "`accessToken` is required but was not set" }, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(clientType) { "`clientType` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkNotNull(connectionId) { "`connectionId` is required but was not set" }, + checkNotNull(connectionType) { "`connectionType` is required but was not set" }, + checkNotNull(products) { "`products` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(providerId) { "`providerId` is required but was not set" }, customerId, tokenType, additionalProperties.toImmutable(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt index 88528a19..afd35fe1 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/CreateCompanyBenefitsResponse.kt @@ -27,7 +27,7 @@ private constructor( fun benefitId(): String = benefitId.getRequired("benefit_id") - @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId() = benefitId + @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId(): JsonField = benefitId @JsonAnyGetter @ExcludeMissing @@ -51,7 +51,7 @@ private constructor( class Builder { - private var benefitId: JsonField = JsonMissing.of() + private var benefitId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,7 +84,10 @@ private constructor( } fun build(): CreateCompanyBenefitsResponse = - CreateCompanyBenefitsResponse(benefitId, additionalProperties.toImmutable()) + CreateCompanyBenefitsResponse( + checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryEvent.kt index 4790f6c0..32f700e5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DirectoryEvent.kt @@ -62,20 +62,22 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing @@ -110,8 +112,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var data: JsonField = JsonMissing.of() private var eventType: JsonField = JsonMissing.of() @@ -188,8 +190,8 @@ private constructor( fun build(): DirectoryEvent = DirectoryEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, data, eventType, @@ -213,7 +215,9 @@ private constructor( Optional.ofNullable(individualId.getNullable("individual_id")) /** The ID of the individual related to the event. */ - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectResponse.kt index 17507790..4759deb3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DisconnectResponse.kt @@ -29,7 +29,7 @@ private constructor( fun status(): String = status.getRequired("status") /** If the request is successful, Finch will return ā€œsuccessā€ (HTTP 200 status). */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -53,7 +53,7 @@ private constructor( class Builder { - private var status: JsonField = JsonMissing.of() + private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -88,7 +88,10 @@ private constructor( } fun build(): DisconnectResponse = - DisconnectResponse(status, additionalProperties.toImmutable()) + DisconnectResponse( + checkNotNull(status) { "`status` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentListResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentListResponse.kt index 20fbf58f..3e21e436 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentListResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentListResponse.kt @@ -32,9 +32,11 @@ private constructor( fun paging(): Paging = paging.getRequired("paging") - @JsonProperty("documents") @ExcludeMissing fun _documents() = documents + @JsonProperty("documents") + @ExcludeMissing + fun _documents(): JsonField> = documents - @JsonProperty("paging") @ExcludeMissing fun _paging() = paging + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging @JsonAnyGetter @ExcludeMissing @@ -59,13 +61,13 @@ private constructor( class Builder { - private var documents: JsonField> = JsonMissing.of() - private var paging: JsonField = JsonMissing.of() + private var documents: JsonField>? = null + private var paging: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(documentListResponse: DocumentListResponse) = apply { - documents = documentListResponse.documents + documents = documentListResponse.documents.map { it.toMutableList() } paging = documentListResponse.paging additionalProperties = documentListResponse.additionalProperties.toMutableMap() } @@ -73,7 +75,20 @@ private constructor( fun documents(documents: List) = documents(JsonField.of(documents)) fun documents(documents: JsonField>) = apply { - this.documents = documents + this.documents = documents.map { it.toMutableList() } + } + + fun addDocument(document: DocumentResponse) = apply { + documents = + (documents ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(document) + } } fun paging(paging: Paging) = paging(JsonField.of(paging)) @@ -101,8 +116,9 @@ private constructor( fun build(): DocumentListResponse = DocumentListResponse( - documents.map { it.toImmutable() }, - paging, + checkNotNull(documents) { "`documents` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(paging) { "`paging` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.kt index 727052b2..005d03a8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/DocumentResponse.kt @@ -55,25 +55,27 @@ private constructor( fun year(): Optional = Optional.ofNullable(year.getNullable("year")) /** A stable Finch id for the document. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The ID of the individual associated with the document. This will be null for employer-level * documents. */ - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId /** The type of document. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * A URL to access the document. Format: * `https://api.tryfinch.com/employer/documents/:document_id`. */ - @JsonProperty("url") @ExcludeMissing fun _url() = url + @JsonProperty("url") @ExcludeMissing fun _url(): JsonField = url /** The year the document applies to, if available. */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -128,7 +130,13 @@ private constructor( * The ID of the individual associated with the document. This will be null for * employer-level documents. */ - fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + fun individualId(individualId: String?) = individualId(JsonField.ofNullable(individualId)) + + /** + * The ID of the individual associated with the document. This will be null for + * employer-level documents. + */ + fun individualId(individualId: Optional) = individualId(individualId.orElse(null)) /** * The ID of the individual associated with the document. This will be null for @@ -157,7 +165,14 @@ private constructor( fun url(url: JsonField) = apply { this.url = url } /** The year the document applies to, if available. */ - fun year(year: Double) = year(JsonField.of(year)) + fun year(year: Double?) = year(JsonField.ofNullable(year)) + + /** The year the document applies to, if available. */ + fun year(year: Double) = year(year as Double?) + + /** The year the document applies to, if available. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Double?) /** The year the document applies to, if available. */ fun year(year: JsonField) = apply { this.year = year } 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 9bff5116..108cf3c6 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 @@ -154,70 +154,82 @@ private constructor( fun workId(): Optional = Optional.ofNullable(workId.getNullable("work_id")) /** string A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Worker's compensation classification code for this employee */ - @JsonProperty("class_code") @ExcludeMissing fun _classCode() = classCode + @JsonProperty("class_code") @ExcludeMissing fun _classCode(): JsonField = classCode /** * Custom fields for the individual. These are fields which are defined by the employer in the * system. */ - @JsonProperty("custom_fields") @ExcludeMissing fun _customFields() = customFields + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField> = customFields /** The department object. */ - @JsonProperty("department") @ExcludeMissing fun _department() = department + @JsonProperty("department") + @ExcludeMissing + fun _department(): JsonField = department /** The employment object. */ - @JsonProperty("employment") @ExcludeMissing fun _employment() = employment + @JsonProperty("employment") + @ExcludeMissing + fun _employment(): JsonField = employment /** * The detailed employment status of the individual. Available options: `active`, `deceased`, * `leave`, `onboarding`, `prehire`, `retired`, `terminated`. */ - @JsonProperty("employment_status") @ExcludeMissing fun _employmentStatus() = employmentStatus + @JsonProperty("employment_status") + @ExcludeMissing + fun _employmentStatus(): JsonField = employmentStatus - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** The legal first name of the individual. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** * The employee's income as reported by the provider. This may not always be annualized income, * but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what information the * provider returns. */ - @JsonProperty("income") @ExcludeMissing fun _income() = income + @JsonProperty("income") @ExcludeMissing fun _income(): JsonField = income /** The array of income history. */ - @JsonProperty("income_history") @ExcludeMissing fun _incomeHistory() = incomeHistory + @JsonProperty("income_history") + @ExcludeMissing + fun _incomeHistory(): JsonField> = incomeHistory /** `true` if the individual an an active employee or contractor at the company. */ - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") @ExcludeMissing fun _isActive(): JsonField = isActive /** The legal last name of the individual. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName - @JsonProperty("latest_rehire_date") @ExcludeMissing fun _latestRehireDate() = latestRehireDate + @JsonProperty("latest_rehire_date") + @ExcludeMissing + fun _latestRehireDate(): JsonField = latestRehireDate - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location /** The manager object representing the manager of the individual within the org. */ - @JsonProperty("manager") @ExcludeMissing fun _manager() = manager + @JsonProperty("manager") @ExcludeMissing fun _manager(): JsonField = manager /** The legal middle name of the individual. */ - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") @ExcludeMissing fun _middleName(): JsonField = middleName /** The source system's unique employment identifier for this individual */ - @JsonProperty("source_id") @ExcludeMissing fun _sourceId() = sourceId + @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate /** The current title of the individual. */ - @JsonProperty("title") @ExcludeMissing fun _title() = title + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title /** This field is deprecated in favour of `source_id` */ - @JsonProperty("work_id") @ExcludeMissing fun _workId() = workId + @JsonProperty("work_id") @ExcludeMissing fun _workId(): JsonField = workId @JsonAnyGetter @ExcludeMissing @@ -262,14 +274,14 @@ private constructor( private var id: JsonField = JsonMissing.of() private var classCode: JsonField = JsonMissing.of() - private var customFields: JsonField> = JsonMissing.of() + private var customFields: JsonField>? = null private var department: JsonField = JsonMissing.of() private var employment: JsonField = JsonMissing.of() private var employmentStatus: JsonField = JsonMissing.of() private var endDate: JsonField = JsonMissing.of() private var firstName: JsonField = JsonMissing.of() private var income: JsonField = JsonMissing.of() - private var incomeHistory: JsonField> = JsonMissing.of() + private var incomeHistory: JsonField>? = null private var isActive: JsonField = JsonMissing.of() private var lastName: JsonField = JsonMissing.of() private var latestRehireDate: JsonField = JsonMissing.of() @@ -286,14 +298,14 @@ private constructor( internal fun from(employmentData: EmploymentData) = apply { id = employmentData.id classCode = employmentData.classCode - customFields = employmentData.customFields + customFields = employmentData.customFields.map { it.toMutableList() } department = employmentData.department employment = employmentData.employment employmentStatus = employmentData.employmentStatus endDate = employmentData.endDate firstName = employmentData.firstName income = employmentData.income - incomeHistory = employmentData.incomeHistory + incomeHistory = employmentData.incomeHistory.map { it.toMutableList() } isActive = employmentData.isActive lastName = employmentData.lastName latestRehireDate = employmentData.latestRehireDate @@ -314,7 +326,10 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Worker's compensation classification code for this employee */ - fun classCode(classCode: String) = classCode(JsonField.of(classCode)) + fun classCode(classCode: String?) = classCode(JsonField.ofNullable(classCode)) + + /** Worker's compensation classification code for this employee */ + fun classCode(classCode: Optional) = classCode(classCode.orElse(null)) /** Worker's compensation classification code for this employee */ fun classCode(classCode: JsonField) = apply { this.classCode = classCode } @@ -323,24 +338,55 @@ private constructor( * Custom fields for the individual. These are fields which are defined by the employer in * the system. */ - fun customFields(customFields: List) = customFields(JsonField.of(customFields)) + fun customFields(customFields: List?) = + customFields(JsonField.ofNullable(customFields)) + + /** + * Custom fields for the individual. These are fields which are defined by the employer in + * the system. + */ + fun customFields(customFields: Optional>) = + customFields(customFields.orElse(null)) /** * Custom fields for the individual. These are fields which are defined by the employer in * the system. */ fun customFields(customFields: JsonField>) = apply { - this.customFields = customFields + this.customFields = customFields.map { it.toMutableList() } + } + + /** + * Custom fields for the individual. These are fields which are defined by the employer in + * the system. + */ + fun addCustomField(customField: CustomField) = apply { + customFields = + (customFields ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(customField) + } } /** The department object. */ - fun department(department: Department) = department(JsonField.of(department)) + fun department(department: Department?) = department(JsonField.ofNullable(department)) + + /** The department object. */ + fun department(department: Optional) = department(department.orElse(null)) /** The department object. */ fun department(department: JsonField) = apply { this.department = department } /** The employment object. */ - fun employment(employment: Employment) = employment(JsonField.of(employment)) + fun employment(employment: Employment?) = employment(JsonField.ofNullable(employment)) + + /** The employment object. */ + fun employment(employment: Optional) = employment(employment.orElse(null)) /** The employment object. */ fun employment(employment: JsonField) = apply { this.employment = employment } @@ -349,8 +395,15 @@ private constructor( * The detailed employment status of the individual. Available options: `active`, * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. */ - fun employmentStatus(employmentStatus: EmploymentStatus) = - employmentStatus(JsonField.of(employmentStatus)) + fun employmentStatus(employmentStatus: EmploymentStatus?) = + employmentStatus(JsonField.ofNullable(employmentStatus)) + + /** + * The detailed employment status of the individual. Available options: `active`, + * `deceased`, `leave`, `onboarding`, `prehire`, `retired`, `terminated`. + */ + fun employmentStatus(employmentStatus: Optional) = + employmentStatus(employmentStatus.orElse(null)) /** * The detailed employment status of the individual. Available options: `active`, @@ -360,12 +413,17 @@ private constructor( this.employmentStatus = employmentStatus } - fun endDate(endDate: String) = endDate(JsonField.of(endDate)) + fun endDate(endDate: String?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } /** The legal first name of the individual. */ - fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) + + /** The legal first name of the individual. */ + fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) /** The legal first name of the individual. */ fun firstName(firstName: JsonField) = apply { this.firstName = firstName } @@ -375,7 +433,14 @@ private constructor( * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what * information the provider returns. */ - fun income(income: Income) = income(JsonField.of(income)) + fun income(income: Income?) = income(JsonField.ofNullable(income)) + + /** + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. + */ + fun income(income: Optional) = income(income.orElse(null)) /** * The employee's income as reported by the provider. This may not always be annualized @@ -385,66 +450,117 @@ private constructor( fun income(income: JsonField) = apply { this.income = income } /** The array of income history. */ - fun incomeHistory(incomeHistory: List) = incomeHistory(JsonField.of(incomeHistory)) + fun incomeHistory(incomeHistory: List?) = + incomeHistory(JsonField.ofNullable(incomeHistory)) + + /** The array of income history. */ + fun incomeHistory(incomeHistory: Optional>) = + incomeHistory(incomeHistory.orElse(null)) /** The array of income history. */ fun incomeHistory(incomeHistory: JsonField>) = apply { - this.incomeHistory = incomeHistory + this.incomeHistory = incomeHistory.map { it.toMutableList() } + } + + /** The array of income history. */ + fun addIncomeHistory(incomeHistory: Income) = apply { + this.incomeHistory = + (this.incomeHistory ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(incomeHistory) + } } /** `true` if the individual an an active employee or contractor at the company. */ - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) + fun isActive(isActive: Boolean?) = isActive(JsonField.ofNullable(isActive)) + + /** `true` if the individual an an active employee or contractor at the company. */ + fun isActive(isActive: Boolean) = isActive(isActive as Boolean?) + + /** `true` if the individual an an active employee or contractor at the company. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isActive(isActive: Optional) = isActive(isActive.orElse(null) as Boolean?) /** `true` if the individual an an active employee or contractor at the company. */ fun isActive(isActive: JsonField) = apply { this.isActive = isActive } /** The legal last name of the individual. */ - fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) + + /** The legal last name of the individual. */ + fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) /** The legal last name of the individual. */ fun lastName(lastName: JsonField) = apply { this.lastName = lastName } - fun latestRehireDate(latestRehireDate: String) = - latestRehireDate(JsonField.of(latestRehireDate)) + fun latestRehireDate(latestRehireDate: String?) = + latestRehireDate(JsonField.ofNullable(latestRehireDate)) + + fun latestRehireDate(latestRehireDate: Optional) = + latestRehireDate(latestRehireDate.orElse(null)) fun latestRehireDate(latestRehireDate: JsonField) = apply { this.latestRehireDate = latestRehireDate } - fun location(location: Location) = location(JsonField.of(location)) + fun location(location: Location?) = location(JsonField.ofNullable(location)) + + fun location(location: Optional) = location(location.orElse(null)) fun location(location: JsonField) = apply { this.location = location } /** The manager object representing the manager of the individual within the org. */ - fun manager(manager: Manager) = manager(JsonField.of(manager)) + fun manager(manager: Manager?) = manager(JsonField.ofNullable(manager)) + + /** The manager object representing the manager of the individual within the org. */ + fun manager(manager: Optional) = manager(manager.orElse(null)) /** The manager object representing the manager of the individual within the org. */ fun manager(manager: JsonField) = apply { this.manager = manager } /** The legal middle name of the individual. */ - fun middleName(middleName: String) = middleName(JsonField.of(middleName)) + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) + + /** The legal middle name of the individual. */ + fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) /** The legal middle name of the individual. */ fun middleName(middleName: JsonField) = apply { this.middleName = middleName } /** The source system's unique employment identifier for this individual */ - fun sourceId(sourceId: String) = sourceId(JsonField.of(sourceId)) + fun sourceId(sourceId: String?) = sourceId(JsonField.ofNullable(sourceId)) + + /** The source system's unique employment identifier for this individual */ + fun sourceId(sourceId: Optional) = sourceId(sourceId.orElse(null)) /** The source system's unique employment identifier for this individual */ fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } - fun startDate(startDate: String) = startDate(JsonField.of(startDate)) + fun startDate(startDate: String?) = startDate(JsonField.ofNullable(startDate)) + + fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) fun startDate(startDate: JsonField) = apply { this.startDate = startDate } /** The current title of the individual. */ - fun title(title: String) = title(JsonField.of(title)) + fun title(title: String?) = title(JsonField.ofNullable(title)) + + /** The current title of the individual. */ + fun title(title: Optional) = title(title.orElse(null)) /** The current title of the individual. */ fun title(title: JsonField) = apply { this.title = title } /** This field is deprecated in favour of `source_id` */ - fun workId(workId: String) = workId(JsonField.of(workId)) + fun workId(workId: String?) = workId(JsonField.ofNullable(workId)) + + /** This field is deprecated in favour of `source_id` */ + fun workId(workId: Optional) = workId(workId.orElse(null)) /** This field is deprecated in favour of `source_id` */ fun workId(workId: JsonField) = apply { this.workId = workId } @@ -472,14 +588,14 @@ private constructor( EmploymentData( id, classCode, - customFields.map { it.toImmutable() }, + (customFields ?: JsonMissing.of()).map { it.toImmutable() }, department, employment, employmentStatus, endDate, firstName, income, - incomeHistory.map { it.toImmutable() }, + (incomeHistory ?: JsonMissing.of()).map { it.toImmutable() }, isActive, lastName, latestRehireDate, @@ -508,9 +624,9 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("value") @ExcludeMissing fun _value(): JsonValue = value - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -612,7 +728,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The name of the department associated with the individual. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -646,7 +762,10 @@ private constructor( } /** The name of the department associated with the individual. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The name of the department associated with the individual. */ + fun name(name: Optional) = name(name.orElse(null)) /** The name of the department associated with the individual. */ fun name(name: JsonField) = apply { this.name = name } @@ -717,10 +836,10 @@ private constructor( * The secondary employment type of the individual. Options: `full_time`, `part_time`, * `intern`, `temp`, `seasonal` and `individual_contractor`. */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** The main employment type of the individual. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -760,7 +879,13 @@ private constructor( * The secondary employment type of the individual. Options: `full_time`, `part_time`, * `intern`, `temp`, `seasonal` and `individual_contractor`. */ - fun subtype(subtype: Subtype) = subtype(JsonField.of(subtype)) + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) + + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ + fun subtype(subtype: Optional) = subtype(subtype.orElse(null)) /** * The secondary employment type of the individual. Options: `full_time`, `part_time`, @@ -769,7 +894,10 @@ private constructor( fun subtype(subtype: JsonField) = apply { this.subtype = subtype } /** The main employment type of the individual. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** The main employment type of the individual. */ + fun type(type: Optional) = type(type.orElse(null)) /** The main employment type of the individual. */ fun type(type: JsonField) = apply { this.type = type } @@ -1058,7 +1186,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentDataResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentDataResponse.kt index dd49c42f..6c9887d2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentDataResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentDataResponse.kt @@ -37,11 +37,13 @@ private constructor( fun individualId(): Optional = Optional.ofNullable(individualId.getNullable("individual_id")) - @JsonProperty("body") @ExcludeMissing fun _body() = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentEvent.kt index fa684380..9921898c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentEvent.kt @@ -62,20 +62,22 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing @@ -110,8 +112,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var data: JsonField = JsonMissing.of() private var eventType: JsonField = JsonMissing.of() @@ -188,8 +190,8 @@ private constructor( fun build(): EmploymentEvent = EmploymentEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, data, eventType, @@ -213,7 +215,9 @@ private constructor( Optional.ofNullable(individualId.getNullable("individual_id")) /** The ID of the individual related to the event. */ - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentUpdateResponse.kt index 8ba37024..e5f2aca3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EmploymentUpdateResponse.kt @@ -145,64 +145,76 @@ private constructor( fun title(): Optional = Optional.ofNullable(title.getNullable("title")) /** A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Worker's compensation classification code for this employee */ - @JsonProperty("class_code") @ExcludeMissing fun _classCode() = classCode + @JsonProperty("class_code") @ExcludeMissing fun _classCode(): JsonField = 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. */ - @JsonProperty("custom_fields") @ExcludeMissing fun _customFields() = customFields + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField> = customFields /** The department object. */ - @JsonProperty("department") @ExcludeMissing fun _department() = department + @JsonProperty("department") + @ExcludeMissing + fun _department(): JsonField = department /** The employment object. */ - @JsonProperty("employment") @ExcludeMissing fun _employment() = employment + @JsonProperty("employment") + @ExcludeMissing + fun _employment(): JsonField = employment /** The detailed employment status of the individual. */ - @JsonProperty("employment_status") @ExcludeMissing fun _employmentStatus() = employmentStatus + @JsonProperty("employment_status") + @ExcludeMissing + fun _employmentStatus(): JsonField = employmentStatus - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** The legal first name of the individual. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** * The employee's income as reported by the provider. This may not always be annualized income, * but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what information the * provider returns. */ - @JsonProperty("income") @ExcludeMissing fun _income() = income + @JsonProperty("income") @ExcludeMissing fun _income(): JsonField = income /** The array of income history. */ - @JsonProperty("income_history") @ExcludeMissing fun _incomeHistory() = incomeHistory + @JsonProperty("income_history") + @ExcludeMissing + fun _incomeHistory(): JsonField> = incomeHistory /** `true` if the individual an an active employee or contractor at the company. */ - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") @ExcludeMissing fun _isActive(): JsonField = isActive /** The legal last name of the individual. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName - @JsonProperty("latest_rehire_date") @ExcludeMissing fun _latestRehireDate() = latestRehireDate + @JsonProperty("latest_rehire_date") + @ExcludeMissing + fun _latestRehireDate(): JsonField = latestRehireDate - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location /** The manager object representing the manager of the individual within the org. */ - @JsonProperty("manager") @ExcludeMissing fun _manager() = manager + @JsonProperty("manager") @ExcludeMissing fun _manager(): JsonField = manager /** The legal middle name of the individual. */ - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") @ExcludeMissing fun _middleName(): JsonField = middleName /** The source system's unique employment identifier for this individual */ - @JsonProperty("source_id") @ExcludeMissing fun _sourceId() = sourceId + @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate /** The current title of the individual. */ - @JsonProperty("title") @ExcludeMissing fun _title() = title + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title @JsonAnyGetter @ExcludeMissing @@ -246,14 +258,14 @@ private constructor( private var id: JsonField = JsonMissing.of() private var classCode: JsonField = JsonMissing.of() - private var customFields: JsonField> = JsonMissing.of() + private var customFields: JsonField>? = null private var department: JsonField = JsonMissing.of() private var employment: JsonField = JsonMissing.of() private var employmentStatus: JsonField = JsonMissing.of() private var endDate: JsonField = JsonMissing.of() private var firstName: JsonField = JsonMissing.of() private var income: JsonField = JsonMissing.of() - private var incomeHistory: JsonField> = JsonMissing.of() + private var incomeHistory: JsonField>? = null private var isActive: JsonField = JsonMissing.of() private var lastName: JsonField = JsonMissing.of() private var latestRehireDate: JsonField = JsonMissing.of() @@ -269,14 +281,14 @@ private constructor( internal fun from(employmentUpdateResponse: EmploymentUpdateResponse) = apply { id = employmentUpdateResponse.id classCode = employmentUpdateResponse.classCode - customFields = employmentUpdateResponse.customFields + customFields = employmentUpdateResponse.customFields.map { it.toMutableList() } department = employmentUpdateResponse.department employment = employmentUpdateResponse.employment employmentStatus = employmentUpdateResponse.employmentStatus endDate = employmentUpdateResponse.endDate firstName = employmentUpdateResponse.firstName income = employmentUpdateResponse.income - incomeHistory = employmentUpdateResponse.incomeHistory + incomeHistory = employmentUpdateResponse.incomeHistory.map { it.toMutableList() } isActive = employmentUpdateResponse.isActive lastName = employmentUpdateResponse.lastName latestRehireDate = employmentUpdateResponse.latestRehireDate @@ -296,7 +308,10 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** Worker's compensation classification code for this employee */ - fun classCode(classCode: String) = classCode(JsonField.of(classCode)) + fun classCode(classCode: String?) = classCode(JsonField.ofNullable(classCode)) + + /** Worker's compensation classification code for this employee */ + fun classCode(classCode: Optional) = classCode(classCode.orElse(null)) /** Worker's compensation classification code for this employee */ fun classCode(classCode: JsonField) = apply { this.classCode = classCode } @@ -312,36 +327,68 @@ private constructor( * the system. Custom fields are not currently supported for assisted connections. */ fun customFields(customFields: JsonField>) = apply { - this.customFields = customFields + this.customFields = customFields.map { it.toMutableList() } + } + + /** + * 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 addCustomField(customField: CustomField) = apply { + customFields = + (customFields ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(customField) + } } /** The department object. */ - fun department(department: Department) = department(JsonField.of(department)) + fun department(department: Department?) = department(JsonField.ofNullable(department)) + + /** The department object. */ + fun department(department: Optional) = department(department.orElse(null)) /** The department object. */ fun department(department: JsonField) = apply { this.department = department } /** The employment object. */ - fun employment(employment: Employment) = employment(JsonField.of(employment)) + fun employment(employment: Employment?) = employment(JsonField.ofNullable(employment)) + + /** The employment object. */ + fun employment(employment: Optional) = employment(employment.orElse(null)) /** The employment object. */ fun employment(employment: JsonField) = apply { this.employment = employment } /** The detailed employment status of the individual. */ - fun employmentStatus(employmentStatus: EmploymentStatus) = - employmentStatus(JsonField.of(employmentStatus)) + fun employmentStatus(employmentStatus: EmploymentStatus?) = + employmentStatus(JsonField.ofNullable(employmentStatus)) + + /** The detailed employment status of the individual. */ + fun employmentStatus(employmentStatus: Optional) = + employmentStatus(employmentStatus.orElse(null)) /** The detailed employment status of the individual. */ fun employmentStatus(employmentStatus: JsonField) = apply { this.employmentStatus = employmentStatus } - fun endDate(endDate: String) = endDate(JsonField.of(endDate)) + fun endDate(endDate: String?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } /** The legal first name of the individual. */ - fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) + + /** The legal first name of the individual. */ + fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) /** The legal first name of the individual. */ fun firstName(firstName: JsonField) = apply { this.firstName = firstName } @@ -351,7 +398,14 @@ private constructor( * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what * information the provider returns. */ - fun income(income: Income) = income(JsonField.of(income)) + fun income(income: Income?) = income(JsonField.ofNullable(income)) + + /** + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. + */ + fun income(income: Optional) = income(income.orElse(null)) /** * The employee's income as reported by the provider. This may not always be annualized @@ -361,44 +415,84 @@ private constructor( fun income(income: JsonField) = apply { this.income = income } /** The array of income history. */ - fun incomeHistory(incomeHistory: List) = incomeHistory(JsonField.of(incomeHistory)) + fun incomeHistory(incomeHistory: List?) = + incomeHistory(JsonField.ofNullable(incomeHistory)) + + /** The array of income history. */ + fun incomeHistory(incomeHistory: Optional>) = + incomeHistory(incomeHistory.orElse(null)) /** The array of income history. */ fun incomeHistory(incomeHistory: JsonField>) = apply { - this.incomeHistory = incomeHistory + this.incomeHistory = incomeHistory.map { it.toMutableList() } + } + + /** The array of income history. */ + fun addIncomeHistory(incomeHistory: Income) = apply { + this.incomeHistory = + (this.incomeHistory ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(incomeHistory) + } } /** `true` if the individual an an active employee or contractor at the company. */ - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) + fun isActive(isActive: Boolean?) = isActive(JsonField.ofNullable(isActive)) + + /** `true` if the individual an an active employee or contractor at the company. */ + fun isActive(isActive: Boolean) = isActive(isActive as Boolean?) + + /** `true` if the individual an an active employee or contractor at the company. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isActive(isActive: Optional) = isActive(isActive.orElse(null) as Boolean?) /** `true` if the individual an an active employee or contractor at the company. */ fun isActive(isActive: JsonField) = apply { this.isActive = isActive } /** The legal last name of the individual. */ - fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) + + /** The legal last name of the individual. */ + fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) /** The legal last name of the individual. */ fun lastName(lastName: JsonField) = apply { this.lastName = lastName } - fun latestRehireDate(latestRehireDate: String) = - latestRehireDate(JsonField.of(latestRehireDate)) + fun latestRehireDate(latestRehireDate: String?) = + latestRehireDate(JsonField.ofNullable(latestRehireDate)) + + fun latestRehireDate(latestRehireDate: Optional) = + latestRehireDate(latestRehireDate.orElse(null)) fun latestRehireDate(latestRehireDate: JsonField) = apply { this.latestRehireDate = latestRehireDate } - fun location(location: Location) = location(JsonField.of(location)) + fun location(location: Location?) = location(JsonField.ofNullable(location)) + + fun location(location: Optional) = location(location.orElse(null)) fun location(location: JsonField) = apply { this.location = location } /** The manager object representing the manager of the individual within the org. */ - fun manager(manager: Manager) = manager(JsonField.of(manager)) + fun manager(manager: Manager?) = manager(JsonField.ofNullable(manager)) + + /** The manager object representing the manager of the individual within the org. */ + fun manager(manager: Optional) = manager(manager.orElse(null)) /** The manager object representing the manager of the individual within the org. */ fun manager(manager: JsonField) = apply { this.manager = manager } /** The legal middle name of the individual. */ - fun middleName(middleName: String) = middleName(JsonField.of(middleName)) + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) + + /** The legal middle name of the individual. */ + fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) /** The legal middle name of the individual. */ fun middleName(middleName: JsonField) = apply { this.middleName = middleName } @@ -409,12 +503,17 @@ private constructor( /** The source system's unique employment identifier for this individual */ fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } - fun startDate(startDate: String) = startDate(JsonField.of(startDate)) + fun startDate(startDate: String?) = startDate(JsonField.ofNullable(startDate)) + + fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) fun startDate(startDate: JsonField) = apply { this.startDate = startDate } /** The current title of the individual. */ - fun title(title: String) = title(JsonField.of(title)) + fun title(title: String?) = title(JsonField.ofNullable(title)) + + /** The current title of the individual. */ + fun title(title: Optional) = title(title.orElse(null)) /** The current title of the individual. */ fun title(title: JsonField) = apply { this.title = title } @@ -442,14 +541,14 @@ private constructor( EmploymentUpdateResponse( id, classCode, - customFields.map { it.toImmutable() }, + (customFields ?: JsonMissing.of()).map { it.toImmutable() }, department, employment, employmentStatus, endDate, firstName, income, - incomeHistory.map { it.toImmutable() }, + (incomeHistory ?: JsonMissing.of()).map { it.toImmutable() }, isActive, lastName, latestRehireDate, @@ -477,9 +576,9 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("value") @ExcludeMissing fun _value(): JsonValue = value - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -514,7 +613,9 @@ private constructor( additionalProperties = customField.additionalProperties.toMutableMap() } - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) fun name(name: JsonField) = apply { this.name = name } @@ -581,7 +682,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The name of the department associated with the individual. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -615,7 +716,10 @@ private constructor( } /** The name of the department associated with the individual. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The name of the department associated with the individual. */ + fun name(name: Optional) = name(name.orElse(null)) /** The name of the department associated with the individual. */ fun name(name: JsonField) = apply { this.name = name } @@ -686,10 +790,10 @@ private constructor( * The secondary employment type of the individual. Options: `full_time`, `part_time`, * `intern`, `temp`, `seasonal` and `individual_contractor`. */ - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** The main employment type of the individual. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -729,7 +833,13 @@ private constructor( * The secondary employment type of the individual. Options: `full_time`, `part_time`, * `intern`, `temp`, `seasonal` and `individual_contractor`. */ - fun subtype(subtype: Subtype) = subtype(JsonField.of(subtype)) + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) + + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ + fun subtype(subtype: Optional) = subtype(subtype.orElse(null)) /** * The secondary employment type of the individual. Options: `full_time`, `part_time`, @@ -738,7 +848,10 @@ private constructor( fun subtype(subtype: JsonField) = apply { this.subtype = subtype } /** The main employment type of the individual. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** The main employment type of the individual. */ + fun type(type: Optional) = type(type.orElse(null)) /** The main employment type of the individual. */ fun type(type: JsonField) = apply { this.type = type } @@ -1027,7 +1140,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt index 03465d99..6ee1fa49 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/EnrolledIndividual.kt @@ -38,12 +38,14 @@ private constructor( fun individualId(): Optional = Optional.ofNullable(individualId.getNullable("individual_id")) - @JsonProperty("body") @ExcludeMissing fun _body() = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body /** HTTP status code. Either 201 or 200 */ - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing @@ -153,13 +155,13 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** A descriptive identifier for the response */ - @JsonProperty("finch_code") @ExcludeMissing fun _finchCode() = finchCode + @JsonProperty("finch_code") @ExcludeMissing fun _finchCode(): JsonField = finchCode /** Short description in English that provides more information about the response. */ - @JsonProperty("message") @ExcludeMissing fun _message() = message + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message /** Identifier indicating whether the benefit was newly enrolled or updated. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -199,19 +201,28 @@ private constructor( } /** A descriptive identifier for the response */ - fun finchCode(finchCode: String) = finchCode(JsonField.of(finchCode)) + fun finchCode(finchCode: String?) = finchCode(JsonField.ofNullable(finchCode)) + + /** A descriptive identifier for the response */ + fun finchCode(finchCode: Optional) = finchCode(finchCode.orElse(null)) /** A descriptive identifier for the response */ fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } /** Short description in English that provides more information about the response. */ - fun message(message: String) = message(JsonField.of(message)) + fun message(message: String?) = message(JsonField.ofNullable(message)) + + /** Short description in English that provides more information about the response. */ + fun message(message: Optional) = message(message.orElse(null)) /** Short description in English that provides more information about the response. */ fun message(message: JsonField) = apply { this.message = message } /** Identifier indicating whether the benefit was newly enrolled or updated. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Identifier indicating whether the benefit was newly enrolled or updated. */ + fun name(name: Optional) = name(name.orElse(null)) /** Identifier indicating whether the benefit was newly enrolled or updated. */ fun name(name: JsonField) = apply { this.name = name } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitCreateParams.kt index 9d8ffed7..9ff08b1c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -38,12 +40,23 @@ constructor( /** Type of benefit. */ fun type(): Optional = body.type() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Name of the benefit as it appears in the provider and pay statements. Recommend limiting this + * to <30 characters due to limitations in specific providers (e.g. Justworks). + */ + fun _description(): JsonField = body._description() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _frequency(): JsonField = body._frequency() + + /** Type of benefit. */ + fun _type(): JsonField = body._type() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): HrisBenefitCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -54,30 +67,62 @@ constructor( class HrisBenefitCreateBody @JsonCreator internal constructor( - @JsonProperty("description") private val description: String?, - @JsonProperty("frequency") private val frequency: BenefitFrequency?, - @JsonProperty("type") private val type: BenefitType?, + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("frequency") + @ExcludeMissing + private val frequency: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Name of the benefit as it appears in the provider and pay statements. Recommend limiting + * this to <30 characters due to limitations in specific providers (e.g. Justworks). + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + fun frequency(): Optional = + Optional.ofNullable(frequency.getNullable("frequency")) + + /** Type of benefit. */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + /** * Name of the benefit as it appears in the provider and pay statements. Recommend limiting * this to <30 characters due to limitations in specific providers (e.g. Justworks). */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description @JsonProperty("frequency") - fun frequency(): Optional = Optional.ofNullable(frequency) + @ExcludeMissing + fun _frequency(): JsonField = frequency /** Type of benefit. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): HrisBenefitCreateBody = apply { + if (!validated) { + description() + frequency() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -87,9 +132,9 @@ constructor( class Builder { - private var description: String? = null - private var frequency: BenefitFrequency? = null - private var type: BenefitType? = null + private var description: JsonField = JsonMissing.of() + private var frequency: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -105,25 +150,34 @@ constructor( * limiting this to <30 characters due to limitations in specific providers (e.g. * Justworks). */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String) = description(JsonField.of(description)) /** * Name of the benefit as it appears in the provider and pay statements. Recommend * limiting this to <30 characters due to limitations in specific providers (e.g. * Justworks). */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: JsonField) = apply { + this.description = description + } - fun frequency(frequency: BenefitFrequency?) = apply { this.frequency = frequency } + fun frequency(frequency: BenefitFrequency?) = frequency(JsonField.ofNullable(frequency)) fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) + fun frequency(frequency: JsonField) = apply { + this.frequency = frequency + } + /** Type of benefit. */ - fun type(type: BenefitType?) = apply { this.type = type } + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) /** Type of benefit. */ fun type(type: Optional) = type(type.orElse(null)) + /** Type of benefit. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -195,24 +249,48 @@ constructor( * Name of the benefit as it appears in the provider and pay statements. Recommend limiting * this to <30 characters due to limitations in specific providers (e.g. Justworks). */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String) = apply { body.description(description) } /** * Name of the benefit as it appears in the provider and pay statements. Recommend limiting * this to <30 characters due to limitations in specific providers (e.g. Justworks). */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: JsonField) = apply { body.description(description) } fun frequency(frequency: BenefitFrequency?) = apply { body.frequency(frequency) } fun frequency(frequency: Optional) = frequency(frequency.orElse(null)) + fun frequency(frequency: JsonField) = apply { body.frequency(frequency) } + /** Type of benefit. */ fun type(type: BenefitType?) = apply { body.type(type) } /** Type of benefit. */ fun type(type: Optional) = type(type.orElse(null)) + /** Type of benefit. */ + fun type(type: JsonField) = apply { body.type(type) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -311,25 +389,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): HrisBenefitCreateParams = HrisBenefitCreateParams( body.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParams.kt index 29601728..f1b1b5ac 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitIndividualUnenrollManyParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -30,12 +32,15 @@ constructor( /** Array of individual_ids to unenroll. */ fun individualIds(): Optional> = body.individualIds() + /** Array of individual_ids to unenroll. */ + fun _individualIds(): JsonField> = body._individualIds() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): HrisBenefitIndividualUnenrollManyBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -53,19 +58,35 @@ constructor( class HrisBenefitIndividualUnenrollManyBody @JsonCreator internal constructor( - @JsonProperty("individual_ids") private val individualIds: List?, + @JsonProperty("individual_ids") + @ExcludeMissing + private val individualIds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** Array of individual_ids to unenroll. */ + fun individualIds(): Optional> = + Optional.ofNullable(individualIds.getNullable("individual_ids")) + /** Array of individual_ids to unenroll. */ @JsonProperty("individual_ids") - fun individualIds(): Optional> = Optional.ofNullable(individualIds) + @ExcludeMissing + fun _individualIds(): JsonField> = individualIds @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): HrisBenefitIndividualUnenrollManyBody = apply { + if (!validated) { + individualIds() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -75,30 +96,40 @@ constructor( class Builder { - private var individualIds: MutableList? = null + private var individualIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( hrisBenefitIndividualUnenrollManyBody: HrisBenefitIndividualUnenrollManyBody ) = apply { - individualIds = hrisBenefitIndividualUnenrollManyBody.individualIds?.toMutableList() + individualIds = + hrisBenefitIndividualUnenrollManyBody.individualIds.map { it.toMutableList() } additionalProperties = hrisBenefitIndividualUnenrollManyBody.additionalProperties.toMutableMap() } /** Array of individual_ids to unenroll. */ - fun individualIds(individualIds: List?) = apply { - this.individualIds = individualIds?.toMutableList() - } + fun individualIds(individualIds: List) = + individualIds(JsonField.of(individualIds)) /** Array of individual_ids to unenroll. */ - fun individualIds(individualIds: Optional>) = - individualIds(individualIds.orElse(null)) + fun individualIds(individualIds: JsonField>) = apply { + this.individualIds = individualIds.map { it.toMutableList() } + } /** Array of individual_ids to unenroll. */ fun addIndividualId(individualId: String) = apply { - individualIds = (individualIds ?: mutableListOf()).apply { add(individualId) } + individualIds = + (individualIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(individualId) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -122,7 +153,7 @@ constructor( fun build(): HrisBenefitIndividualUnenrollManyBody = HrisBenefitIndividualUnenrollManyBody( - individualIds?.toImmutable(), + (individualIds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -176,17 +207,35 @@ constructor( fun benefitId(benefitId: String) = apply { this.benefitId = benefitId } /** Array of individual_ids to unenroll. */ - fun individualIds(individualIds: List?) = apply { - body.individualIds(individualIds) - } + fun individualIds(individualIds: List) = apply { body.individualIds(individualIds) } /** Array of individual_ids to unenroll. */ - fun individualIds(individualIds: Optional>) = - individualIds(individualIds.orElse(null)) + fun individualIds(individualIds: JsonField>) = apply { + body.individualIds(individualIds) + } /** Array of individual_ids to unenroll. */ fun addIndividualId(individualId: String) = apply { body.addIndividualId(individualId) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -285,25 +334,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): HrisBenefitIndividualUnenrollManyParams = HrisBenefitIndividualUnenrollManyParams( checkNotNull(benefitId) { "`benefitId` is required but was not set" }, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParams.kt index e1dd4805..e42c44da 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisBenefitUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -30,12 +32,15 @@ constructor( /** Updated name or description. */ fun description(): Optional = body.description() + /** Updated name or description. */ + fun _description(): JsonField = body._description() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): HrisBenefitUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -53,19 +58,35 @@ constructor( class HrisBenefitUpdateBody @JsonCreator internal constructor( - @JsonProperty("description") private val description: String?, + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** Updated name or description. */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + /** Updated name or description. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): HrisBenefitUpdateBody = apply { + if (!validated) { + description() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -75,7 +96,7 @@ constructor( class Builder { - private var description: String? = null + private var description: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -85,10 +106,12 @@ constructor( } /** Updated name or description. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String) = description(JsonField.of(description)) /** Updated name or description. */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: JsonField) = apply { + this.description = description + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -157,10 +180,29 @@ constructor( fun benefitId(benefitId: String) = apply { this.benefitId = benefitId } /** Updated name or description. */ - fun description(description: String?) = apply { body.description(description) } + fun description(description: String) = apply { body.description(description) } /** Updated name or description. */ - fun description(description: Optional) = description(description.orElse(null)) + fun description(description: JsonField) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -260,25 +302,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): HrisBenefitUpdateParams = HrisBenefitUpdateParams( checkNotNull(benefitId) { "`benefitId` is required but was not set" }, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParams.kt index 1ba1d76c..2e9a4b87 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisEmploymentRetrieveManyParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -26,12 +28,15 @@ constructor( /** The array of batch requests. */ fun requests(): List = body.requests() + /** The array of batch requests. */ + fun _requests(): JsonField> = body._requests() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): HrisEmploymentRetrieveManyBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -43,18 +48,34 @@ constructor( class HrisEmploymentRetrieveManyBody @JsonCreator internal constructor( - @JsonProperty("requests") private val requests: List, + @JsonProperty("requests") + @ExcludeMissing + private val requests: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The array of batch requests. */ - @JsonProperty("requests") fun requests(): List = requests + fun requests(): List = requests.getRequired("requests") + + /** The array of batch requests. */ + @JsonProperty("requests") + @ExcludeMissing + fun _requests(): JsonField> = requests @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): HrisEmploymentRetrieveManyBody = apply { + if (!validated) { + requests().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -64,25 +85,37 @@ constructor( class Builder { - private var requests: MutableList? = null + private var requests: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(hrisEmploymentRetrieveManyBody: HrisEmploymentRetrieveManyBody) = apply { - requests = hrisEmploymentRetrieveManyBody.requests.toMutableList() + requests = hrisEmploymentRetrieveManyBody.requests.map { it.toMutableList() } additionalProperties = hrisEmploymentRetrieveManyBody.additionalProperties.toMutableMap() } /** The array of batch requests. */ - fun requests(requests: List) = apply { - this.requests = requests.toMutableList() + fun requests(requests: List) = requests(JsonField.of(requests)) + + /** The array of batch requests. */ + fun requests(requests: JsonField>) = apply { + this.requests = requests.map { it.toMutableList() } } /** The array of batch requests. */ fun addRequest(request: Request) = apply { - requests = (requests ?: mutableListOf()).apply { add(request) } + requests = + (requests ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(request) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -107,7 +140,7 @@ constructor( fun build(): HrisEmploymentRetrieveManyBody = HrisEmploymentRetrieveManyBody( checkNotNull(requests) { "`requests` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -157,9 +190,31 @@ constructor( /** The array of batch requests. */ fun requests(requests: List) = apply { body.requests(requests) } + /** The array of batch requests. */ + fun requests(requests: JsonField>) = apply { body.requests(requests) } + /** The array of batch requests. */ fun addRequest(request: Request) = apply { body.addRequest(request) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -258,25 +313,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): HrisEmploymentRetrieveManyParams = HrisEmploymentRetrieveManyParams( body.build(), @@ -289,7 +325,9 @@ constructor( class Request @JsonCreator private constructor( - @JsonProperty("individual_id") private val individualId: String, + @JsonProperty("individual_id") + @ExcludeMissing + private val individualId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -299,12 +337,30 @@ constructor( * number of `individual_id` to send per request. It is preferantial to send all ids in a * single request for Finch to optimize provider rate-limits. */ - @JsonProperty("individual_id") fun individualId(): String = individualId + fun individualId(): String = individualId.getRequired("individual_id") + + /** + * A stable Finch `id` (UUID v4) for an individual in the company. There is no limit to the + * number of `individual_id` to send per request. It is preferantial to send all ids in a + * single request for Finch to optimize provider rate-limits. + */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Request = apply { + if (!validated) { + individualId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -314,7 +370,7 @@ constructor( class Builder { - private var individualId: String? = null + private var individualId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -328,7 +384,16 @@ constructor( * the number of `individual_id` to send per request. It is preferantial to send all ids * in a single request for Finch to optimize provider rate-limits. */ - fun individualId(individualId: String) = apply { this.individualId = individualId } + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** + * A stable Finch `id` (UUID v4) for an individual in the company. There is no limit to + * the number of `individual_id` to send per request. It is preferantial to send all ids + * in a single request for Finch to optimize provider rate-limits. + */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParams.kt index 7ff5de37..2aca8f6e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisIndividualRetrieveManyParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -28,12 +30,16 @@ constructor( fun requests(): Optional> = body.requests() - fun _additionalHeaders(): Headers = additionalHeaders + fun _options(): JsonField = body._options() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _requests(): JsonField> = body._requests() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): HrisIndividualRetrieveManyBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -44,21 +50,41 @@ constructor( class HrisIndividualRetrieveManyBody @JsonCreator internal constructor( - @JsonProperty("options") private val options: Options?, - @JsonProperty("requests") private val requests: List?, + @JsonProperty("options") + @ExcludeMissing + private val options: JsonField = JsonMissing.of(), + @JsonProperty("requests") + @ExcludeMissing + private val requests: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("options") fun options(): Optional = Optional.ofNullable(options) + fun options(): Optional = Optional.ofNullable(options.getNullable("options")) + + fun requests(): Optional> = + Optional.ofNullable(requests.getNullable("requests")) + + @JsonProperty("options") @ExcludeMissing fun _options(): JsonField = options @JsonProperty("requests") - fun requests(): Optional> = Optional.ofNullable(requests) + @ExcludeMissing + fun _requests(): JsonField> = requests @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): HrisIndividualRetrieveManyBody = apply { + if (!validated) { + options().map { it.validate() } + requests().map { it.forEach { it.validate() } } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -68,31 +94,42 @@ constructor( class Builder { - private var options: Options? = null - private var requests: MutableList? = null + private var options: JsonField = JsonMissing.of() + private var requests: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(hrisIndividualRetrieveManyBody: HrisIndividualRetrieveManyBody) = apply { options = hrisIndividualRetrieveManyBody.options - requests = hrisIndividualRetrieveManyBody.requests?.toMutableList() + requests = hrisIndividualRetrieveManyBody.requests.map { it.toMutableList() } additionalProperties = hrisIndividualRetrieveManyBody.additionalProperties.toMutableMap() } - fun options(options: Options?) = apply { this.options = options } + fun options(options: Options?) = options(JsonField.ofNullable(options)) fun options(options: Optional) = options(options.orElse(null)) - fun requests(requests: List?) = apply { - this.requests = requests?.toMutableList() - } + fun options(options: JsonField) = apply { this.options = options } - fun requests(requests: Optional>) = requests(requests.orElse(null)) + fun requests(requests: List) = requests(JsonField.of(requests)) + + fun requests(requests: JsonField>) = apply { + this.requests = requests.map { it.toMutableList() } + } fun addRequest(request: Request) = apply { - requests = (requests ?: mutableListOf()).apply { add(request) } + requests = + (requests ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(request) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -117,7 +154,7 @@ constructor( fun build(): HrisIndividualRetrieveManyBody = HrisIndividualRetrieveManyBody( options, - requests?.toImmutable(), + (requests ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -168,12 +205,33 @@ constructor( fun options(options: Optional) = options(options.orElse(null)) - fun requests(requests: List?) = apply { body.requests(requests) } + fun options(options: JsonField) = apply { body.options(options) } + + fun requests(requests: List) = apply { body.requests(requests) } - fun requests(requests: Optional>) = requests(requests.orElse(null)) + fun requests(requests: JsonField>) = apply { body.requests(requests) } fun addRequest(request: Request) = apply { body.addRequest(request) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -272,25 +330,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): HrisIndividualRetrieveManyParams = HrisIndividualRetrieveManyParams( body.build(), @@ -303,18 +342,30 @@ constructor( class Options @JsonCreator private constructor( - @JsonProperty("include") private val include: List?, + @JsonProperty("include") + @ExcludeMissing + private val include: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("include") - fun include(): Optional> = Optional.ofNullable(include) + fun include(): Optional> = Optional.ofNullable(include.getNullable("include")) + + @JsonProperty("include") @ExcludeMissing fun _include(): JsonField> = include @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Options = apply { + if (!validated) { + include() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -324,21 +375,32 @@ constructor( class Builder { - private var include: MutableList? = null + private var include: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(options: Options) = apply { - include = options.include?.toMutableList() + include = options.include.map { it.toMutableList() } additionalProperties = options.additionalProperties.toMutableMap() } - fun include(include: List?) = apply { this.include = include?.toMutableList() } + fun include(include: List) = include(JsonField.of(include)) - fun include(include: Optional>) = include(include.orElse(null)) + fun include(include: JsonField>) = apply { + this.include = include.map { it.toMutableList() } + } fun addInclude(include: String) = apply { - this.include = (this.include ?: mutableListOf()).apply { add(include) } + this.include = + (this.include ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(include) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -361,7 +423,10 @@ constructor( } fun build(): Options = - Options(include?.toImmutable(), additionalProperties.toImmutable()) + Options( + (include ?: JsonMissing.of()).map { it.toImmutable() }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -386,18 +451,33 @@ constructor( class Request @JsonCreator private constructor( - @JsonProperty("individual_id") private val individualId: String?, + @JsonProperty("individual_id") + @ExcludeMissing + private val individualId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun individualId(): Optional = + Optional.ofNullable(individualId.getNullable("individual_id")) + @JsonProperty("individual_id") - fun individualId(): Optional = Optional.ofNullable(individualId) + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Request = apply { + if (!validated) { + individualId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -407,7 +487,7 @@ constructor( class Builder { - private var individualId: String? = null + private var individualId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -416,10 +496,11 @@ constructor( additionalProperties = request.additionalProperties.toMutableMap() } - fun individualId(individualId: String?) = apply { this.individualId = individualId } + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) - fun individualId(individualId: Optional) = - individualId(individualId.orElse(null)) + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParams.kt index d6968cae..a3e8ac70 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/HrisPayStatementRetrieveManyParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -31,12 +33,15 @@ constructor( /** The array of batch requests. */ fun requests(): List = body.requests() + /** The array of batch requests. */ + fun _requests(): JsonField> = body._requests() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): HrisPayStatementRetrieveManyBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -47,18 +52,34 @@ constructor( class HrisPayStatementRetrieveManyBody @JsonCreator internal constructor( - @JsonProperty("requests") private val requests: List, + @JsonProperty("requests") + @ExcludeMissing + private val requests: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The array of batch requests. */ - @JsonProperty("requests") fun requests(): List = requests + fun requests(): List = requests.getRequired("requests") + + /** The array of batch requests. */ + @JsonProperty("requests") + @ExcludeMissing + fun _requests(): JsonField> = requests @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): HrisPayStatementRetrieveManyBody = apply { + if (!validated) { + requests().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -68,25 +89,37 @@ constructor( class Builder { - private var requests: MutableList? = null + private var requests: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(hrisPayStatementRetrieveManyBody: HrisPayStatementRetrieveManyBody) = apply { - requests = hrisPayStatementRetrieveManyBody.requests.toMutableList() + requests = hrisPayStatementRetrieveManyBody.requests.map { it.toMutableList() } additionalProperties = hrisPayStatementRetrieveManyBody.additionalProperties.toMutableMap() } /** The array of batch requests. */ - fun requests(requests: List) = apply { - this.requests = requests.toMutableList() + fun requests(requests: List) = requests(JsonField.of(requests)) + + /** The array of batch requests. */ + fun requests(requests: JsonField>) = apply { + this.requests = requests.map { it.toMutableList() } } /** The array of batch requests. */ fun addRequest(request: Request) = apply { - requests = (requests ?: mutableListOf()).apply { add(request) } + requests = + (requests ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(request) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -111,7 +144,7 @@ constructor( fun build(): HrisPayStatementRetrieveManyBody = HrisPayStatementRetrieveManyBody( checkNotNull(requests) { "`requests` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -161,9 +194,31 @@ constructor( /** The array of batch requests. */ fun requests(requests: List) = apply { body.requests(requests) } + /** The array of batch requests. */ + fun requests(requests: JsonField>) = apply { body.requests(requests) } + /** The array of batch requests. */ fun addRequest(request: Request) = apply { body.addRequest(request) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -262,25 +317,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): HrisPayStatementRetrieveManyParams = HrisPayStatementRetrieveManyParams( body.build(), @@ -293,26 +329,52 @@ constructor( class Request @JsonCreator private constructor( - @JsonProperty("payment_id") private val paymentId: String, - @JsonProperty("limit") private val limit: Long?, - @JsonProperty("offset") private val offset: Long?, + @JsonProperty("payment_id") + @ExcludeMissing + private val paymentId: JsonField = JsonMissing.of(), + @JsonProperty("limit") + @ExcludeMissing + private val limit: JsonField = JsonMissing.of(), + @JsonProperty("offset") + @ExcludeMissing + private val offset: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A stable Finch `id` (UUID v4) for a payment. */ - @JsonProperty("payment_id") fun paymentId(): String = paymentId + fun paymentId(): String = paymentId.getRequired("payment_id") + + /** Number of pay statements to return (defaults to all). */ + fun limit(): Optional = Optional.ofNullable(limit.getNullable("limit")) + + /** Index to start from. */ + fun offset(): Optional = Optional.ofNullable(offset.getNullable("offset")) + + /** A stable Finch `id` (UUID v4) for a payment. */ + @JsonProperty("payment_id") @ExcludeMissing fun _paymentId(): JsonField = paymentId /** Number of pay statements to return (defaults to all). */ - @JsonProperty("limit") fun limit(): Optional = Optional.ofNullable(limit) + @JsonProperty("limit") @ExcludeMissing fun _limit(): JsonField = limit /** Index to start from. */ - @JsonProperty("offset") fun offset(): Optional = Optional.ofNullable(offset) + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Request = apply { + if (!validated) { + paymentId() + limit() + offset() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -322,9 +384,9 @@ constructor( class Builder { - private var paymentId: String? = null - private var limit: Long? = null - private var offset: Long? = null + private var paymentId: JsonField? = null + private var limit: JsonField = JsonMissing.of() + private var offset: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -336,27 +398,22 @@ constructor( } /** A stable Finch `id` (UUID v4) for a payment. */ - fun paymentId(paymentId: String) = apply { this.paymentId = paymentId } + fun paymentId(paymentId: String) = paymentId(JsonField.of(paymentId)) - /** Number of pay statements to return (defaults to all). */ - fun limit(limit: Long?) = apply { this.limit = limit } + /** A stable Finch `id` (UUID v4) for a payment. */ + fun paymentId(paymentId: JsonField) = apply { this.paymentId = paymentId } /** Number of pay statements to return (defaults to all). */ - fun limit(limit: Long) = limit(limit as Long?) + fun limit(limit: Long) = limit(JsonField.of(limit)) /** Number of pay statements to return (defaults to all). */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun limit(limit: Optional) = limit(limit.orElse(null) as Long?) - - /** Index to start from. */ - fun offset(offset: Long?) = apply { this.offset = offset } + fun limit(limit: JsonField) = apply { this.limit = limit } /** Index to start from. */ - fun offset(offset: Long) = offset(offset as Long?) + fun offset(offset: Long) = offset(JsonField.of(offset)) /** Index to start from. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun offset(offset: Optional) = offset(offset.orElse(null) as Long?) + fun offset(offset: JsonField) = apply { this.offset = offset } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() 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 e646a11b..302b43e2 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 @@ -55,19 +55,21 @@ private constructor( fun unit(): Optional = Optional.ofNullable(unit.getNullable("unit")) /** The income amount in cents. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The currency code. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The date the income amount went into effect. */ - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate /** * The income unit of payment. Options: `yearly`, `quarterly`, `monthly`, `semi_monthly`, * `bi_weekly`, `weekly`, `daily`, `hourly`, and `fixed`. */ - @JsonProperty("unit") @ExcludeMissing fun _unit() = unit + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit @JsonAnyGetter @ExcludeMissing @@ -110,19 +112,34 @@ private constructor( } /** The income amount in cents. */ - fun amount(amount: Long) = amount(JsonField.of(amount)) + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** The income amount in cents. */ + fun amount(amount: Long) = amount(amount as Long?) + + /** The income amount in cents. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) /** The income amount in cents. */ fun amount(amount: JsonField) = apply { this.amount = amount } /** The currency code. */ - fun currency(currency: String) = currency(JsonField.of(currency)) + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** The currency code. */ + fun currency(currency: Optional) = currency(currency.orElse(null)) /** The currency code. */ fun currency(currency: JsonField) = apply { this.currency = currency } /** The date the income amount went into effect. */ - fun effectiveDate(effectiveDate: String) = effectiveDate(JsonField.of(effectiveDate)) + fun effectiveDate(effectiveDate: String?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + /** The date the income amount went into effect. */ + fun effectiveDate(effectiveDate: Optional) = + effectiveDate(effectiveDate.orElse(null)) /** The date the income amount went into effect. */ fun effectiveDate(effectiveDate: JsonField) = apply { @@ -133,7 +150,13 @@ private constructor( * The income unit of payment. Options: `yearly`, `quarterly`, `monthly`, `semi_monthly`, * `bi_weekly`, `weekly`, `daily`, `hourly`, and `fixed`. */ - fun unit(unit: Unit) = unit(JsonField.of(unit)) + fun unit(unit: Unit?) = unit(JsonField.ofNullable(unit)) + + /** + * The income unit of payment. Options: `yearly`, `quarterly`, `monthly`, `semi_monthly`, + * `bi_weekly`, `weekly`, `daily`, `hourly`, and `fixed`. + */ + fun unit(unit: Optional) = unit(unit.orElse(null)) /** * The income unit of payment. Options: `yearly`, `quarterly`, `monthly`, `semi_monthly`, diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt index da66f032..12cf5231 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Individual.kt @@ -105,47 +105,53 @@ private constructor( fun ssn(): Optional = Optional.ofNullable(ssn.getNullable("ssn")) /** A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob - @JsonProperty("emails") @ExcludeMissing fun _emails() = emails + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails /** * Social Security Number of the individual in **encrypted** format. This field is only * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set in * the body. */ - @JsonProperty("encrypted_ssn") @ExcludeMissing fun _encryptedSsn() = encryptedSsn + @JsonProperty("encrypted_ssn") + @ExcludeMissing + fun _encryptedSsn(): JsonField = encryptedSsn /** The EEOC-defined ethnicity of the individual. */ - @JsonProperty("ethnicity") @ExcludeMissing fun _ethnicity() = ethnicity + @JsonProperty("ethnicity") @ExcludeMissing fun _ethnicity(): JsonField = ethnicity /** The legal first name of the individual. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** The gender of the individual. */ - @JsonProperty("gender") @ExcludeMissing fun _gender() = gender + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender /** The legal last name of the individual. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** The legal middle name of the individual. */ - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") @ExcludeMissing fun _middleName(): JsonField = middleName - @JsonProperty("phone_numbers") @ExcludeMissing fun _phoneNumbers() = phoneNumbers + @JsonProperty("phone_numbers") + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers /** The preferred name of the individual. */ - @JsonProperty("preferred_name") @ExcludeMissing fun _preferredName() = preferredName + @JsonProperty("preferred_name") + @ExcludeMissing + fun _preferredName(): JsonField = preferredName - @JsonProperty("residence") @ExcludeMissing fun _residence() = residence + @JsonProperty("residence") @ExcludeMissing fun _residence(): JsonField = residence /** * Social Security Number of the individual. This field is only available with the `ssn` scope * enabled and the `options: { include: ['ssn'] }` param set in the body. * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). */ - @JsonProperty("ssn") @ExcludeMissing fun _ssn() = ssn + @JsonProperty("ssn") @ExcludeMissing fun _ssn(): JsonField = ssn @JsonAnyGetter @ExcludeMissing @@ -183,14 +189,14 @@ private constructor( private var id: JsonField = JsonMissing.of() private var dob: JsonField = JsonMissing.of() - private var emails: JsonField> = JsonMissing.of() + private var emails: JsonField>? = null private var encryptedSsn: JsonField = JsonMissing.of() private var ethnicity: JsonField = JsonMissing.of() private var firstName: JsonField = JsonMissing.of() private var gender: JsonField = JsonMissing.of() private var lastName: JsonField = JsonMissing.of() private var middleName: JsonField = JsonMissing.of() - private var phoneNumbers: JsonField> = JsonMissing.of() + private var phoneNumbers: JsonField>? = null private var preferredName: JsonField = JsonMissing.of() private var residence: JsonField = JsonMissing.of() private var ssn: JsonField = JsonMissing.of() @@ -200,14 +206,14 @@ private constructor( internal fun from(individual: Individual) = apply { id = individual.id dob = individual.dob - emails = individual.emails + emails = individual.emails.map { it.toMutableList() } encryptedSsn = individual.encryptedSsn ethnicity = individual.ethnicity firstName = individual.firstName gender = individual.gender lastName = individual.lastName middleName = individual.middleName - phoneNumbers = individual.phoneNumbers + phoneNumbers = individual.phoneNumbers.map { it.toMutableList() } preferredName = individual.preferredName residence = individual.residence ssn = individual.ssn @@ -220,20 +226,46 @@ private constructor( /** A stable Finch `id` (UUID v4) for an individual in the company. */ fun id(id: JsonField) = apply { this.id = id } - fun dob(dob: String) = dob(JsonField.of(dob)) + fun dob(dob: String?) = dob(JsonField.ofNullable(dob)) + + fun dob(dob: Optional) = dob(dob.orElse(null)) fun dob(dob: JsonField) = apply { this.dob = dob } - fun emails(emails: List) = emails(JsonField.of(emails)) + fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) + + fun emails(emails: Optional>) = emails(emails.orElse(null)) + + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } - fun emails(emails: JsonField>) = apply { this.emails = emails } + fun addEmail(email: Email) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(email) + } + } /** * Social Security Number of the individual in **encrypted** format. This field is only * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set * in the body. */ - fun encryptedSsn(encryptedSsn: String) = encryptedSsn(JsonField.of(encryptedSsn)) + fun encryptedSsn(encryptedSsn: String?) = encryptedSsn(JsonField.ofNullable(encryptedSsn)) + + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set + * in the body. + */ + fun encryptedSsn(encryptedSsn: Optional) = encryptedSsn(encryptedSsn.orElse(null)) /** * Social Security Number of the individual in **encrypted** format. This field is only @@ -245,51 +277,89 @@ private constructor( } /** The EEOC-defined ethnicity of the individual. */ - fun ethnicity(ethnicity: Ethnicity) = ethnicity(JsonField.of(ethnicity)) + fun ethnicity(ethnicity: Ethnicity?) = ethnicity(JsonField.ofNullable(ethnicity)) + + /** The EEOC-defined ethnicity of the individual. */ + fun ethnicity(ethnicity: Optional) = ethnicity(ethnicity.orElse(null)) /** The EEOC-defined ethnicity of the individual. */ fun ethnicity(ethnicity: JsonField) = apply { this.ethnicity = ethnicity } /** The legal first name of the individual. */ - fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) + + /** The legal first name of the individual. */ + fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) /** The legal first name of the individual. */ fun firstName(firstName: JsonField) = apply { this.firstName = firstName } /** The gender of the individual. */ - fun gender(gender: Gender) = gender(JsonField.of(gender)) + fun gender(gender: Gender?) = gender(JsonField.ofNullable(gender)) + + /** The gender of the individual. */ + fun gender(gender: Optional) = gender(gender.orElse(null)) /** The gender of the individual. */ fun gender(gender: JsonField) = apply { this.gender = gender } /** The legal last name of the individual. */ - fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) + + /** The legal last name of the individual. */ + fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) /** The legal last name of the individual. */ fun lastName(lastName: JsonField) = apply { this.lastName = lastName } /** The legal middle name of the individual. */ - fun middleName(middleName: String) = middleName(JsonField.of(middleName)) + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) + + /** The legal middle name of the individual. */ + fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) /** The legal middle name of the individual. */ fun middleName(middleName: JsonField) = apply { this.middleName = middleName } - fun phoneNumbers(phoneNumbers: List) = - phoneNumbers(JsonField.of(phoneNumbers)) + fun phoneNumbers(phoneNumbers: List?) = + phoneNumbers(JsonField.ofNullable(phoneNumbers)) + + fun phoneNumbers(phoneNumbers: Optional>) = + phoneNumbers(phoneNumbers.orElse(null)) fun phoneNumbers(phoneNumbers: JsonField>) = apply { - this.phoneNumbers = phoneNumbers + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } } + fun addPhoneNumber(phoneNumber: PhoneNumber) = apply { + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(phoneNumber) + } + } + + /** The preferred name of the individual. */ + fun preferredName(preferredName: String?) = + preferredName(JsonField.ofNullable(preferredName)) + /** The preferred name of the individual. */ - fun preferredName(preferredName: String) = preferredName(JsonField.of(preferredName)) + fun preferredName(preferredName: Optional) = + preferredName(preferredName.orElse(null)) /** The preferred name of the individual. */ fun preferredName(preferredName: JsonField) = apply { this.preferredName = preferredName } - fun residence(residence: Location) = residence(JsonField.of(residence)) + fun residence(residence: Location?) = residence(JsonField.ofNullable(residence)) + + fun residence(residence: Optional) = residence(residence.orElse(null)) fun residence(residence: JsonField) = apply { this.residence = residence } @@ -298,7 +368,14 @@ private constructor( * scope enabled and the `options: { include: ['ssn'] }` param set in the body. * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). */ - fun ssn(ssn: String) = ssn(JsonField.of(ssn)) + fun ssn(ssn: String?) = ssn(JsonField.ofNullable(ssn)) + + /** + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun ssn(ssn: Optional) = ssn(ssn.orElse(null)) /** * Social Security Number of the individual. This field is only available with the `ssn` @@ -330,14 +407,14 @@ private constructor( Individual( id, dob, - emails.map { it.toImmutable() }, + (emails ?: JsonMissing.of()).map { it.toImmutable() }, encryptedSsn, ethnicity, firstName, gender, lastName, middleName, - phoneNumbers.map { it.toImmutable() }, + (phoneNumbers ?: JsonMissing.of()).map { it.toImmutable() }, preferredName, residence, ssn, @@ -361,9 +438,9 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -403,7 +480,9 @@ private constructor( fun data(data: JsonField) = apply { this.data = data } - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + fun type(type: Optional) = type(type.orElse(null)) fun type(type: JsonField) = apply { this.type = type } @@ -688,9 +767,9 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -726,11 +805,15 @@ private constructor( additionalProperties = phoneNumber.additionalProperties.toMutableMap() } - fun data(data: String) = data(JsonField.of(data)) + fun data(data: String?) = data(JsonField.ofNullable(data)) + + fun data(data: Optional) = data(data.orElse(null)) fun data(data: JsonField) = apply { this.data = data } - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + fun type(type: Optional) = type(type.orElse(null)) fun type(type: JsonField) = apply { this.type = type } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualBenefit.kt index 5f0811f9..5d784e1a 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualBenefit.kt @@ -37,11 +37,13 @@ private constructor( fun individualId(): Optional = Optional.ofNullable(individualId.getNullable("individual_id")) - @JsonProperty("body") @ExcludeMissing fun _body() = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing @@ -166,26 +168,28 @@ private constructor( Optional.ofNullable(hsaContributionLimit.getNullable("hsa_contribution_limit")) /** If the benefit supports annual maximum, the amount in cents for this individual. */ - @JsonProperty("annual_maximum") @ExcludeMissing fun _annualMaximum() = annualMaximum + @JsonProperty("annual_maximum") + @ExcludeMissing + fun _annualMaximum(): JsonField = annualMaximum /** * If the benefit supports catch up (401k, 403b, etc.), whether catch up is enabled for this * individual. */ - @JsonProperty("catch_up") @ExcludeMissing fun _catchUp() = catchUp + @JsonProperty("catch_up") @ExcludeMissing fun _catchUp(): JsonField = catchUp @JsonProperty("company_contribution") @ExcludeMissing - fun _companyContribution() = companyContribution + fun _companyContribution(): JsonField = companyContribution @JsonProperty("employee_deduction") @ExcludeMissing - fun _employeeDeduction() = employeeDeduction + fun _employeeDeduction(): JsonField = employeeDeduction /** Type for HSA contribution limit if the benefit is a HSA. */ @JsonProperty("hsa_contribution_limit") @ExcludeMissing - fun _hsaContributionLimit() = hsaContributionLimit + fun _hsaContributionLimit(): JsonField = hsaContributionLimit @JsonAnyGetter @ExcludeMissing @@ -231,7 +235,16 @@ private constructor( } /** If the benefit supports annual maximum, the amount in cents for this individual. */ - fun annualMaximum(annualMaximum: Long) = annualMaximum(JsonField.of(annualMaximum)) + fun annualMaximum(annualMaximum: Long?) = + annualMaximum(JsonField.ofNullable(annualMaximum)) + + /** If the benefit supports annual maximum, the amount in cents for this individual. */ + fun annualMaximum(annualMaximum: Long) = annualMaximum(annualMaximum as Long?) + + /** If the benefit supports annual maximum, the amount in cents for this individual. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun annualMaximum(annualMaximum: Optional) = + annualMaximum(annualMaximum.orElse(null) as Long?) /** If the benefit supports annual maximum, the amount in cents for this individual. */ fun annualMaximum(annualMaximum: JsonField) = apply { @@ -242,7 +255,20 @@ private constructor( * If the benefit supports catch up (401k, 403b, etc.), whether catch up is enabled for * this individual. */ - fun catchUp(catchUp: Boolean) = catchUp(JsonField.of(catchUp)) + fun catchUp(catchUp: Boolean?) = catchUp(JsonField.ofNullable(catchUp)) + + /** + * If the benefit supports catch up (401k, 403b, etc.), whether catch up is enabled for + * this individual. + */ + fun catchUp(catchUp: Boolean) = catchUp(catchUp as Boolean?) + + /** + * If the benefit supports catch up (401k, 403b, etc.), whether catch up is enabled for + * this individual. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun catchUp(catchUp: Optional) = catchUp(catchUp.orElse(null) as Boolean?) /** * If the benefit supports catch up (401k, 403b, etc.), whether catch up is enabled for @@ -250,23 +276,33 @@ private constructor( */ fun catchUp(catchUp: JsonField) = apply { this.catchUp = catchUp } - fun companyContribution(companyContribution: BenefitContribution) = - companyContribution(JsonField.of(companyContribution)) + fun companyContribution(companyContribution: BenefitContribution?) = + companyContribution(JsonField.ofNullable(companyContribution)) + + fun companyContribution(companyContribution: Optional) = + companyContribution(companyContribution.orElse(null)) fun companyContribution(companyContribution: JsonField) = apply { this.companyContribution = companyContribution } - fun employeeDeduction(employeeDeduction: BenefitContribution) = - employeeDeduction(JsonField.of(employeeDeduction)) + fun employeeDeduction(employeeDeduction: BenefitContribution?) = + employeeDeduction(JsonField.ofNullable(employeeDeduction)) + + fun employeeDeduction(employeeDeduction: Optional) = + employeeDeduction(employeeDeduction.orElse(null)) fun employeeDeduction(employeeDeduction: JsonField) = apply { this.employeeDeduction = employeeDeduction } /** Type for HSA contribution limit if the benefit is a HSA. */ - fun hsaContributionLimit(hsaContributionLimit: HsaContributionLimit) = - hsaContributionLimit(JsonField.of(hsaContributionLimit)) + fun hsaContributionLimit(hsaContributionLimit: HsaContributionLimit?) = + hsaContributionLimit(JsonField.ofNullable(hsaContributionLimit)) + + /** Type for HSA contribution limit if the benefit is a HSA. */ + fun hsaContributionLimit(hsaContributionLimit: Optional) = + hsaContributionLimit(hsaContributionLimit.orElse(null)) /** Type for HSA contribution limit if the benefit is a HSA. */ fun hsaContributionLimit(hsaContributionLimit: JsonField) = diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponse.kt index 4a84938e..f357d9ca 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEnrolledIdsResponse.kt @@ -32,9 +32,11 @@ private constructor( fun individualIds(): List = individualIds.getRequired("individual_ids") - @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId() = benefitId + @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId(): JsonField = benefitId - @JsonProperty("individual_ids") @ExcludeMissing fun _individualIds() = individualIds + @JsonProperty("individual_ids") + @ExcludeMissing + fun _individualIds(): JsonField> = individualIds @JsonAnyGetter @ExcludeMissing @@ -59,14 +61,14 @@ private constructor( class Builder { - private var benefitId: JsonField = JsonMissing.of() - private var individualIds: JsonField> = JsonMissing.of() + private var benefitId: JsonField? = null + private var individualIds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(individualEnrolledIdsResponse: IndividualEnrolledIdsResponse) = apply { benefitId = individualEnrolledIdsResponse.benefitId - individualIds = individualEnrolledIdsResponse.individualIds + individualIds = individualEnrolledIdsResponse.individualIds.map { it.toMutableList() } additionalProperties = individualEnrolledIdsResponse.additionalProperties.toMutableMap() } @@ -77,7 +79,20 @@ private constructor( fun individualIds(individualIds: List) = individualIds(JsonField.of(individualIds)) fun individualIds(individualIds: JsonField>) = apply { - this.individualIds = individualIds + this.individualIds = individualIds.map { it.toMutableList() } + } + + fun addIndividualId(individualId: String) = apply { + individualIds = + (individualIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(individualId) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -101,8 +116,9 @@ private constructor( fun build(): IndividualEnrolledIdsResponse = IndividualEnrolledIdsResponse( - benefitId, - individualIds.map { it.toImmutable() }, + checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + checkNotNull(individualIds) { "`individualIds` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEvent.kt index 9d4bf162..2ddad75f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualEvent.kt @@ -62,20 +62,22 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing @@ -110,8 +112,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var data: JsonField = JsonMissing.of() private var eventType: JsonField = JsonMissing.of() @@ -188,8 +190,8 @@ private constructor( fun build(): IndividualEvent = IndividualEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, data, eventType, @@ -213,7 +215,9 @@ private constructor( Optional.ofNullable(individualId.getNullable("individual_id")) /** The ID of the individual related to the event. */ - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualInDirectory.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualInDirectory.kt index a985108a..1bf98637 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualInDirectory.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualInDirectory.kt @@ -65,25 +65,27 @@ private constructor( fun middleName(): Optional = Optional.ofNullable(middleName.getNullable("middle_name")) /** A stable Finch id (UUID v4) for an individual in the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The department object. */ - @JsonProperty("department") @ExcludeMissing fun _department() = department + @JsonProperty("department") + @ExcludeMissing + fun _department(): JsonField = department /** The legal first name of the individual. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** `true` if the individual is an active employee or contractor at the company. */ - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") @ExcludeMissing fun _isActive(): JsonField = isActive /** The legal last name of the individual. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** The manager object. */ - @JsonProperty("manager") @ExcludeMissing fun _manager() = manager + @JsonProperty("manager") @ExcludeMissing fun _manager(): JsonField = manager /** The legal middle name of the individual. */ - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") @ExcludeMissing fun _middleName(): JsonField = middleName @JsonAnyGetter @ExcludeMissing @@ -141,37 +143,59 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** The department object. */ - fun department(department: Department) = department(JsonField.of(department)) + fun department(department: Department?) = department(JsonField.ofNullable(department)) + + /** The department object. */ + fun department(department: Optional) = department(department.orElse(null)) /** The department object. */ fun department(department: JsonField) = apply { this.department = department } /** The legal first name of the individual. */ - fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) + + /** The legal first name of the individual. */ + fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) /** The legal first name of the individual. */ fun firstName(firstName: JsonField) = apply { this.firstName = firstName } /** `true` if the individual is an active employee or contractor at the company. */ - fun isActive(isActive: Boolean) = isActive(JsonField.of(isActive)) + fun isActive(isActive: Boolean?) = isActive(JsonField.ofNullable(isActive)) + + /** `true` if the individual is an active employee or contractor at the company. */ + fun isActive(isActive: Boolean) = isActive(isActive as Boolean?) + + /** `true` if the individual is an active employee or contractor at the company. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun isActive(isActive: Optional) = isActive(isActive.orElse(null) as Boolean?) /** `true` if the individual is an active employee or contractor at the company. */ fun isActive(isActive: JsonField) = apply { this.isActive = isActive } /** The legal last name of the individual. */ - fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) + + /** The legal last name of the individual. */ + fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) /** The legal last name of the individual. */ fun lastName(lastName: JsonField) = apply { this.lastName = lastName } /** The manager object. */ - fun manager(manager: Manager) = manager(JsonField.of(manager)) + fun manager(manager: Manager?) = manager(JsonField.ofNullable(manager)) + + /** The manager object. */ + fun manager(manager: Optional) = manager(manager.orElse(null)) /** The manager object. */ fun manager(manager: JsonField) = apply { this.manager = manager } /** The legal middle name of the individual. */ - fun middleName(middleName: String) = middleName(JsonField.of(middleName)) + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) + + /** The legal middle name of the individual. */ + fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) /** The legal middle name of the individual. */ fun middleName(middleName: JsonField) = apply { this.middleName = middleName } @@ -224,7 +248,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The name of the department. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -258,7 +282,10 @@ private constructor( } /** The name of the department. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The name of the department. */ + fun name(name: Optional) = name(name.orElse(null)) /** The name of the department. */ fun name(name: JsonField) = apply { this.name = name } @@ -317,7 +344,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id.getNullable("id")) /** A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt index d40abc77..7bf461f2 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualResponse.kt @@ -37,11 +37,13 @@ private constructor( fun individualId(): Optional = Optional.ofNullable(individualId.getNullable("individual_id")) - @JsonProperty("body") @ExcludeMissing fun _body() = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUpdateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUpdateResponse.kt index 37ecff50..b70a9897 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUpdateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/IndividualUpdateResponse.kt @@ -105,47 +105,53 @@ private constructor( fun ssn(): Optional = Optional.ofNullable(ssn.getNullable("ssn")) /** A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob - @JsonProperty("emails") @ExcludeMissing fun _emails() = emails + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails /** * Social Security Number of the individual in **encrypted** format. This field is only * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set in * the body. */ - @JsonProperty("encrypted_ssn") @ExcludeMissing fun _encryptedSsn() = encryptedSsn + @JsonProperty("encrypted_ssn") + @ExcludeMissing + fun _encryptedSsn(): JsonField = encryptedSsn /** The EEOC-defined ethnicity of the individual. */ - @JsonProperty("ethnicity") @ExcludeMissing fun _ethnicity() = ethnicity + @JsonProperty("ethnicity") @ExcludeMissing fun _ethnicity(): JsonField = ethnicity /** The legal first name of the individual. */ - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** The gender of the individual. */ - @JsonProperty("gender") @ExcludeMissing fun _gender() = gender + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender /** The legal last name of the individual. */ - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** The legal middle name of the individual. */ - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") @ExcludeMissing fun _middleName(): JsonField = middleName - @JsonProperty("phone_numbers") @ExcludeMissing fun _phoneNumbers() = phoneNumbers + @JsonProperty("phone_numbers") + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers /** The preferred name of the individual. */ - @JsonProperty("preferred_name") @ExcludeMissing fun _preferredName() = preferredName + @JsonProperty("preferred_name") + @ExcludeMissing + fun _preferredName(): JsonField = preferredName - @JsonProperty("residence") @ExcludeMissing fun _residence() = residence + @JsonProperty("residence") @ExcludeMissing fun _residence(): JsonField = residence /** * Social Security Number of the individual. This field is only available with the `ssn` scope * enabled and the `options: { include: ['ssn'] }` param set in the body. * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). */ - @JsonProperty("ssn") @ExcludeMissing fun _ssn() = ssn + @JsonProperty("ssn") @ExcludeMissing fun _ssn(): JsonField = ssn @JsonAnyGetter @ExcludeMissing @@ -183,14 +189,14 @@ private constructor( private var id: JsonField = JsonMissing.of() private var dob: JsonField = JsonMissing.of() - private var emails: JsonField> = JsonMissing.of() + private var emails: JsonField>? = null private var encryptedSsn: JsonField = JsonMissing.of() private var ethnicity: JsonField = JsonMissing.of() private var firstName: JsonField = JsonMissing.of() private var gender: JsonField = JsonMissing.of() private var lastName: JsonField = JsonMissing.of() private var middleName: JsonField = JsonMissing.of() - private var phoneNumbers: JsonField> = JsonMissing.of() + private var phoneNumbers: JsonField>? = null private var preferredName: JsonField = JsonMissing.of() private var residence: JsonField = JsonMissing.of() private var ssn: JsonField = JsonMissing.of() @@ -200,14 +206,14 @@ private constructor( internal fun from(individualUpdateResponse: IndividualUpdateResponse) = apply { id = individualUpdateResponse.id dob = individualUpdateResponse.dob - emails = individualUpdateResponse.emails + emails = individualUpdateResponse.emails.map { it.toMutableList() } encryptedSsn = individualUpdateResponse.encryptedSsn ethnicity = individualUpdateResponse.ethnicity firstName = individualUpdateResponse.firstName gender = individualUpdateResponse.gender lastName = individualUpdateResponse.lastName middleName = individualUpdateResponse.middleName - phoneNumbers = individualUpdateResponse.phoneNumbers + phoneNumbers = individualUpdateResponse.phoneNumbers.map { it.toMutableList() } preferredName = individualUpdateResponse.preferredName residence = individualUpdateResponse.residence ssn = individualUpdateResponse.ssn @@ -220,20 +226,46 @@ private constructor( /** A stable Finch `id` (UUID v4) for an individual in the company. */ fun id(id: JsonField) = apply { this.id = id } - fun dob(dob: String) = dob(JsonField.of(dob)) + fun dob(dob: String?) = dob(JsonField.ofNullable(dob)) + + fun dob(dob: Optional) = dob(dob.orElse(null)) fun dob(dob: JsonField) = apply { this.dob = dob } - fun emails(emails: List) = emails(JsonField.of(emails)) + fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) + + fun emails(emails: Optional>) = emails(emails.orElse(null)) + + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } + + fun addEmail(email: Email) = apply { + emails = + (emails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(email) + } + } - fun emails(emails: JsonField>) = apply { this.emails = emails } + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set + * in the body. + */ + fun encryptedSsn(encryptedSsn: String?) = encryptedSsn(JsonField.ofNullable(encryptedSsn)) /** * Social Security Number of the individual in **encrypted** format. This field is only * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set * in the body. */ - fun encryptedSsn(encryptedSsn: String) = encryptedSsn(JsonField.of(encryptedSsn)) + fun encryptedSsn(encryptedSsn: Optional) = encryptedSsn(encryptedSsn.orElse(null)) /** * Social Security Number of the individual in **encrypted** format. This field is only @@ -245,51 +277,89 @@ private constructor( } /** The EEOC-defined ethnicity of the individual. */ - fun ethnicity(ethnicity: Ethnicity) = ethnicity(JsonField.of(ethnicity)) + fun ethnicity(ethnicity: Ethnicity?) = ethnicity(JsonField.ofNullable(ethnicity)) + + /** The EEOC-defined ethnicity of the individual. */ + fun ethnicity(ethnicity: Optional) = ethnicity(ethnicity.orElse(null)) /** The EEOC-defined ethnicity of the individual. */ fun ethnicity(ethnicity: JsonField) = apply { this.ethnicity = ethnicity } /** The legal first name of the individual. */ - fun firstName(firstName: String) = firstName(JsonField.of(firstName)) + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) + + /** The legal first name of the individual. */ + fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) /** The legal first name of the individual. */ fun firstName(firstName: JsonField) = apply { this.firstName = firstName } /** The gender of the individual. */ - fun gender(gender: Gender) = gender(JsonField.of(gender)) + fun gender(gender: Gender?) = gender(JsonField.ofNullable(gender)) + + /** The gender of the individual. */ + fun gender(gender: Optional) = gender(gender.orElse(null)) /** The gender of the individual. */ fun gender(gender: JsonField) = apply { this.gender = gender } /** The legal last name of the individual. */ - fun lastName(lastName: String) = lastName(JsonField.of(lastName)) + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) + + /** The legal last name of the individual. */ + fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) /** The legal last name of the individual. */ fun lastName(lastName: JsonField) = apply { this.lastName = lastName } /** The legal middle name of the individual. */ - fun middleName(middleName: String) = middleName(JsonField.of(middleName)) + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) + + /** The legal middle name of the individual. */ + fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) /** The legal middle name of the individual. */ fun middleName(middleName: JsonField) = apply { this.middleName = middleName } - fun phoneNumbers(phoneNumbers: List) = - phoneNumbers(JsonField.of(phoneNumbers)) + fun phoneNumbers(phoneNumbers: List?) = + phoneNumbers(JsonField.ofNullable(phoneNumbers)) + + fun phoneNumbers(phoneNumbers: Optional>) = + phoneNumbers(phoneNumbers.orElse(null)) fun phoneNumbers(phoneNumbers: JsonField>) = apply { - this.phoneNumbers = phoneNumbers + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } + } + + fun addPhoneNumber(phoneNumber: PhoneNumber) = apply { + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(phoneNumber) + } } /** The preferred name of the individual. */ - fun preferredName(preferredName: String) = preferredName(JsonField.of(preferredName)) + fun preferredName(preferredName: String?) = + preferredName(JsonField.ofNullable(preferredName)) + + /** The preferred name of the individual. */ + fun preferredName(preferredName: Optional) = + preferredName(preferredName.orElse(null)) /** The preferred name of the individual. */ fun preferredName(preferredName: JsonField) = apply { this.preferredName = preferredName } - fun residence(residence: Location) = residence(JsonField.of(residence)) + fun residence(residence: Location?) = residence(JsonField.ofNullable(residence)) + + fun residence(residence: Optional) = residence(residence.orElse(null)) fun residence(residence: JsonField) = apply { this.residence = residence } @@ -298,7 +368,14 @@ private constructor( * scope enabled and the `options: { include: ['ssn'] }` param set in the body. * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). */ - fun ssn(ssn: String) = ssn(JsonField.of(ssn)) + fun ssn(ssn: String?) = ssn(JsonField.ofNullable(ssn)) + + /** + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun ssn(ssn: Optional) = ssn(ssn.orElse(null)) /** * Social Security Number of the individual. This field is only available with the `ssn` @@ -330,14 +407,14 @@ private constructor( IndividualUpdateResponse( id, dob, - emails.map { it.toImmutable() }, + (emails ?: JsonMissing.of()).map { it.toImmutable() }, encryptedSsn, ethnicity, firstName, gender, lastName, middleName, - phoneNumbers.map { it.toImmutable() }, + (phoneNumbers ?: JsonMissing.of()).map { it.toImmutable() }, preferredName, residence, ssn, @@ -361,9 +438,9 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -403,7 +480,9 @@ private constructor( fun data(data: JsonField) = apply { this.data = data } - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + fun type(type: Optional) = type(type.orElse(null)) fun type(type: JsonField) = apply { this.type = type } @@ -688,9 +767,9 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -730,7 +809,9 @@ private constructor( fun data(data: JsonField) = apply { this.data = data } - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + fun type(type: Optional) = type(type.orElse(null)) fun type(type: JsonField) = apply { this.type = type } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Introspection.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Introspection.kt index fe29212c..2bc6b92f 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Introspection.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Introspection.kt @@ -150,75 +150,87 @@ private constructor( * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this * account ID. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId @JsonProperty("authentication_methods") @ExcludeMissing - fun _authenticationMethods() = authenticationMethods + fun _authenticationMethods(): JsonField> = authenticationMethods /** The client ID of the application associated with the `access_token`. */ - @JsonProperty("client_id") @ExcludeMissing fun _clientId() = clientId + @JsonProperty("client_id") @ExcludeMissing fun _clientId(): JsonField = clientId /** The type of application associated with a token. */ - @JsonProperty("client_type") @ExcludeMissing fun _clientType() = clientType + @JsonProperty("client_type") + @ExcludeMissing + fun _clientType(): JsonField = clientType /** * [DEPRECATED] Use `connection_id` to associate tokens with a Finch connection instead of this * company ID. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** The Finch UUID of the connection associated with the `access_token`. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("connection_status") @ExcludeMissing fun _connectionStatus() = connectionStatus + @JsonProperty("connection_status") + @ExcludeMissing + fun _connectionStatus(): JsonField = connectionStatus /** * The type of the connection associated with the token. * - `provider` - connection to an external provider * - `finch` - finch-generated data. */ - @JsonProperty("connection_type") @ExcludeMissing fun _connectionType() = connectionType + @JsonProperty("connection_type") + @ExcludeMissing + fun _connectionType(): JsonField = connectionType /** * The email of your customer you provided to Finch when a connect session was created for this * connection. */ - @JsonProperty("customer_email") @ExcludeMissing fun _customerEmail() = customerEmail + @JsonProperty("customer_email") + @ExcludeMissing + fun _customerEmail(): JsonField = customerEmail /** * The ID of your customer you provided to Finch when a connect session was created for this * connection. */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId() = customerId + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId /** * The name of your customer you provided to Finch when a connect session was created for this * connection. */ - @JsonProperty("customer_name") @ExcludeMissing fun _customerName() = customerName + @JsonProperty("customer_name") + @ExcludeMissing + fun _customerName(): JsonField = customerName /** * Whether the connection associated with the `access_token` uses the Assisted Connect Flow. * (`true` if using Assisted Connect, `false` if connection is automated) */ - @JsonProperty("manual") @ExcludeMissing fun _manual() = manual + @JsonProperty("manual") @ExcludeMissing fun _manual(): JsonField = manual /** * [DEPRECATED] Use `provider_id` to identify the provider instead of this payroll provider ID. */ @JsonProperty("payroll_provider_id") @ExcludeMissing - fun _payrollProviderId() = payrollProviderId + fun _payrollProviderId(): JsonField = payrollProviderId /** An array of the authorized products associated with the `access_token`. */ - @JsonProperty("products") @ExcludeMissing fun _products() = products + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products /** The ID of the provider associated with the `access_token`. */ - @JsonProperty("provider_id") @ExcludeMissing fun _providerId() = providerId + @JsonProperty("provider_id") @ExcludeMissing fun _providerId(): JsonField = providerId /** The account username used for login associated with the `access_token`. */ - @JsonProperty("username") @ExcludeMissing fun _username() = username + @JsonProperty("username") @ExcludeMissing fun _username(): JsonField = username @JsonAnyGetter @ExcludeMissing @@ -257,28 +269,28 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var authenticationMethods: JsonField> = JsonMissing.of() - private var clientId: JsonField = JsonMissing.of() - private var clientType: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() - private var connectionId: JsonField = JsonMissing.of() - private var connectionStatus: JsonField = JsonMissing.of() - private var connectionType: JsonField = JsonMissing.of() - private var customerEmail: JsonField = JsonMissing.of() - private var customerId: JsonField = JsonMissing.of() - private var customerName: JsonField = JsonMissing.of() - private var manual: JsonField = JsonMissing.of() - private var payrollProviderId: JsonField = JsonMissing.of() - private var products: JsonField> = JsonMissing.of() - private var providerId: JsonField = JsonMissing.of() - private var username: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var authenticationMethods: JsonField>? = null + private var clientId: JsonField? = null + private var clientType: JsonField? = null + private var companyId: JsonField? = null + private var connectionId: JsonField? = null + private var connectionStatus: JsonField? = null + private var connectionType: JsonField? = null + private var customerEmail: JsonField? = null + private var customerId: JsonField? = null + private var customerName: JsonField? = null + private var manual: JsonField? = null + private var payrollProviderId: JsonField? = null + private var products: JsonField>? = null + private var providerId: JsonField? = null + private var username: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(introspection: Introspection) = apply { accountId = introspection.accountId - authenticationMethods = introspection.authenticationMethods + authenticationMethods = introspection.authenticationMethods.map { it.toMutableList() } clientId = introspection.clientId clientType = introspection.clientType companyId = introspection.companyId @@ -290,7 +302,7 @@ private constructor( customerName = introspection.customerName manual = introspection.manual payrollProviderId = introspection.payrollProviderId - products = introspection.products + products = introspection.products.map { it.toMutableList() } providerId = introspection.providerId username = introspection.username additionalProperties = introspection.additionalProperties.toMutableMap() @@ -313,9 +325,22 @@ private constructor( fun authenticationMethods(authenticationMethods: JsonField>) = apply { - this.authenticationMethods = authenticationMethods + this.authenticationMethods = authenticationMethods.map { it.toMutableList() } } + fun addAuthenticationMethod(authenticationMethod: AuthenticationMethod) = apply { + authenticationMethods = + (authenticationMethods ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(authenticationMethod) + } + } + /** The client ID of the application associated with the `access_token`. */ fun clientId(clientId: String) = clientId(JsonField.of(clientId)) @@ -376,7 +401,15 @@ private constructor( * The email of your customer you provided to Finch when a connect session was created for * this connection. */ - fun customerEmail(customerEmail: String) = customerEmail(JsonField.of(customerEmail)) + fun customerEmail(customerEmail: String?) = + customerEmail(JsonField.ofNullable(customerEmail)) + + /** + * The email of your customer you provided to Finch when a connect session was created for + * this connection. + */ + fun customerEmail(customerEmail: Optional) = + customerEmail(customerEmail.orElse(null)) /** * The email of your customer you provided to Finch when a connect session was created for @@ -390,7 +423,13 @@ private constructor( * The ID of your customer you provided to Finch when a connect session was created for this * connection. */ - fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** + * The ID of your customer you provided to Finch when a connect session was created for this + * connection. + */ + fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) /** * The ID of your customer you provided to Finch when a connect session was created for this @@ -402,7 +441,13 @@ private constructor( * The name of your customer you provided to Finch when a connect session was created for * this connection. */ - fun customerName(customerName: String) = customerName(JsonField.of(customerName)) + fun customerName(customerName: String?) = customerName(JsonField.ofNullable(customerName)) + + /** + * The name of your customer you provided to Finch when a connect session was created for + * this connection. + */ + fun customerName(customerName: Optional) = customerName(customerName.orElse(null)) /** * The name of your customer you provided to Finch when a connect session was created for @@ -443,7 +488,23 @@ private constructor( fun products(products: List) = products(JsonField.of(products)) /** An array of the authorized products associated with the `access_token`. */ - fun products(products: JsonField>) = apply { this.products = products } + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + /** An array of the authorized products associated with the `access_token`. */ + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } + } /** The ID of the provider associated with the `access_token`. */ fun providerId(providerId: String) = providerId(JsonField.of(providerId)) @@ -478,22 +539,28 @@ private constructor( fun build(): Introspection = Introspection( - accountId, - authenticationMethods.map { it.toImmutable() }, - clientId, - clientType, - companyId, - connectionId, - connectionStatus, - connectionType, - customerEmail, - customerId, - customerName, - manual, - payrollProviderId, - products.map { it.toImmutable() }, - providerId, - username, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(authenticationMethods) { + "`authenticationMethods` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(clientId) { "`clientId` is required but was not set" }, + checkNotNull(clientType) { "`clientType` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, + checkNotNull(connectionId) { "`connectionId` is required but was not set" }, + checkNotNull(connectionStatus) { "`connectionStatus` is required but was not set" }, + checkNotNull(connectionType) { "`connectionType` is required but was not set" }, + checkNotNull(customerEmail) { "`customerEmail` is required but was not set" }, + checkNotNull(customerId) { "`customerId` is required but was not set" }, + checkNotNull(customerName) { "`customerName` is required but was not set" }, + checkNotNull(manual) { "`manual` is required but was not set" }, + checkNotNull(payrollProviderId) { + "`payrollProviderId` is required but was not set" + }, + checkNotNull(products) { "`products` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(providerId) { "`providerId` is required but was not set" }, + checkNotNull(username) { "`username` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -525,13 +592,15 @@ private constructor( @JsonProperty("connection_status") @ExcludeMissing - fun _connectionStatus() = connectionStatus + fun _connectionStatus(): JsonField = connectionStatus /** An array of the authorized products associated with the `access_token`. */ - @JsonProperty("products") @ExcludeMissing fun _products() = products + @JsonProperty("products") + @ExcludeMissing + fun _products(): JsonField> = products /** The type of authentication method. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -558,14 +627,14 @@ private constructor( class Builder { private var connectionStatus: JsonField = JsonMissing.of() - private var products: JsonField> = JsonMissing.of() + private var products: JsonField>? = null private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(authenticationMethod: AuthenticationMethod) = apply { connectionStatus = authenticationMethod.connectionStatus - products = authenticationMethod.products + products = authenticationMethod.products.map { it.toMutableList() } type = authenticationMethod.type additionalProperties = authenticationMethod.additionalProperties.toMutableMap() } @@ -581,7 +650,23 @@ private constructor( fun products(products: List) = products(JsonField.of(products)) /** An array of the authorized products associated with the `access_token`. */ - fun products(products: JsonField>) = apply { this.products = products } + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + /** An array of the authorized products associated with the `access_token`. */ + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } + } /** The type of authentication method. */ fun type(type: Type) = type(JsonField.of(type)) @@ -611,7 +696,7 @@ private constructor( fun build(): AuthenticationMethod = AuthenticationMethod( connectionStatus, - products.map { it.toImmutable() }, + (products ?: JsonMissing.of()).map { it.toImmutable() }, type, additionalProperties.toImmutable(), ) @@ -636,9 +721,11 @@ private constructor( fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - @JsonProperty("message") @ExcludeMissing fun _message() = message + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -905,9 +992,11 @@ private constructor( fun status(): Optional = Optional.ofNullable(status.getNullable("status")) - @JsonProperty("message") @ExcludeMissing fun _message() = message + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") + @ExcludeMissing + fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedCreateParams.kt index 6b1c5463..b977af66 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobAutomatedCreateParams.kt @@ -18,6 +18,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.getOrThrow @@ -321,18 +322,30 @@ constructor( class DataSyncAll @JsonCreator private constructor( - @JsonProperty("type") private val type: Type, + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The type of job to start. */ - @JsonProperty("type") fun type(): Type = type + fun type(): Type = type.getRequired("type") + + /** The type of job to start. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DataSyncAll = apply { + if (!validated) { + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -342,7 +355,7 @@ constructor( class Builder { - private var type: Type? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -352,7 +365,10 @@ constructor( } /** The type of job to start. */ - fun type(type: Type) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + /** The type of job to start. */ + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -453,22 +469,42 @@ constructor( class W4FormEmployeeSync @JsonCreator private constructor( - @JsonProperty("individual_id") private val individualId: String, - @JsonProperty("type") private val type: Type, + @JsonProperty("individual_id") + @ExcludeMissing + private val individualId: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The unique ID of the individual for W-4 data sync. */ - @JsonProperty("individual_id") fun individualId(): String = individualId + fun individualId(): String = individualId.getRequired("individual_id") /** The type of job to start. */ - @JsonProperty("type") fun type(): Type = type + fun type(): Type = type.getRequired("type") + + /** The unique ID of the individual for W-4 data sync. */ + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId + + /** The type of job to start. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): W4FormEmployeeSync = apply { + if (!validated) { + individualId() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -478,8 +514,8 @@ constructor( class Builder { - private var individualId: String? = null - private var type: Type? = null + private var individualId: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -490,10 +526,18 @@ constructor( } /** The unique ID of the individual for W-4 data sync. */ - fun individualId(individualId: String) = apply { this.individualId = individualId } + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) + + /** The unique ID of the individual for W-4 data sync. */ + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } + + /** The type of job to start. */ + fun type(type: Type) = type(JsonField.of(type)) /** The type of job to start. */ - fun type(type: Type) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCompletionEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCompletionEvent.kt index 16487802..5edc106c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCompletionEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCompletionEvent.kt @@ -62,20 +62,22 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing @@ -110,8 +112,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var data: JsonField = JsonMissing.of() private var eventType: JsonField = JsonMissing.of() @@ -188,8 +190,8 @@ private constructor( fun build(): JobCompletionEvent = JobCompletionEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, data, eventType, @@ -218,10 +220,10 @@ private constructor( fun jobUrl(): String = jobUrl.getRequired("job_url") /** The id of the job which has completed. */ - @JsonProperty("job_id") @ExcludeMissing fun _jobId() = jobId + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId /** The url to query the result of the job. */ - @JsonProperty("job_url") @ExcludeMissing fun _jobUrl() = jobUrl + @JsonProperty("job_url") @ExcludeMissing fun _jobUrl(): JsonField = jobUrl @JsonAnyGetter @ExcludeMissing @@ -246,8 +248,8 @@ private constructor( class Builder { - private var jobId: JsonField = JsonMissing.of() - private var jobUrl: JsonField = JsonMissing.of() + private var jobId: JsonField? = null + private var jobUrl: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -290,8 +292,8 @@ private constructor( fun build(): Data = Data( - jobId, - jobUrl, + checkNotNull(jobId) { "`jobId` is required but was not set" }, + checkNotNull(jobUrl) { "`jobUrl` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCreateResponse.kt index 595a71c7..9efdd745 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/JobCreateResponse.kt @@ -45,18 +45,20 @@ private constructor( fun remainingRefreshes(): Long = remainingRefreshes.getRequired("remaining_refreshes") /** The number of allowed refreshes per hour (per hour, fixed window) */ - @JsonProperty("allowed_refreshes") @ExcludeMissing fun _allowedRefreshes() = allowedRefreshes + @JsonProperty("allowed_refreshes") + @ExcludeMissing + fun _allowedRefreshes(): JsonField = allowedRefreshes /** The id of the job that has been created. */ - @JsonProperty("job_id") @ExcludeMissing fun _jobId() = jobId + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId /** The url that can be used to retrieve the job status */ - @JsonProperty("job_url") @ExcludeMissing fun _jobUrl() = jobUrl + @JsonProperty("job_url") @ExcludeMissing fun _jobUrl(): JsonField = jobUrl /** The number of remaining refreshes available (per hour, fixed window) */ @JsonProperty("remaining_refreshes") @ExcludeMissing - fun _remainingRefreshes() = remainingRefreshes + fun _remainingRefreshes(): JsonField = remainingRefreshes @JsonAnyGetter @ExcludeMissing @@ -83,10 +85,10 @@ private constructor( class Builder { - private var allowedRefreshes: JsonField = JsonMissing.of() - private var jobId: JsonField = JsonMissing.of() - private var jobUrl: JsonField = JsonMissing.of() - private var remainingRefreshes: JsonField = JsonMissing.of() + private var allowedRefreshes: JsonField? = null + private var jobId: JsonField? = null + private var jobUrl: JsonField? = null + private var remainingRefreshes: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -149,10 +151,12 @@ private constructor( fun build(): JobCreateResponse = JobCreateResponse( - allowedRefreshes, - jobId, - jobUrl, - remainingRefreshes, + checkNotNull(allowedRefreshes) { "`allowedRefreshes` is required but was not set" }, + checkNotNull(jobId) { "`jobId` is required but was not set" }, + checkNotNull(jobUrl) { "`jobUrl` is required but was not set" }, + checkNotNull(remainingRefreshes) { + "`remainingRefreshes` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Location.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Location.kt index 1ec9a5cb..74b7ece0 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Location.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Location.kt @@ -60,26 +60,26 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) /** City, district, suburb, town, or village. */ - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city /** The 2-letter ISO 3166 country code. */ - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country /** Street address or PO box. */ - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 /** Apartment, suite, unit, or building. */ - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The postal code or zip code. */ - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") @ExcludeMissing fun _postalCode(): JsonField = postalCode - @JsonProperty("source_id") @ExcludeMissing fun _sourceId() = sourceId + @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId /** The state code. */ - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -134,45 +134,67 @@ private constructor( } /** City, district, suburb, town, or village. */ - fun city(city: String) = city(JsonField.of(city)) + fun city(city: String?) = city(JsonField.ofNullable(city)) + + /** City, district, suburb, town, or village. */ + fun city(city: Optional) = city(city.orElse(null)) /** City, district, suburb, town, or village. */ fun city(city: JsonField) = apply { this.city = city } /** The 2-letter ISO 3166 country code. */ - fun country(country: String) = country(JsonField.of(country)) + fun country(country: String?) = country(JsonField.ofNullable(country)) + + /** The 2-letter ISO 3166 country code. */ + fun country(country: Optional) = country(country.orElse(null)) /** The 2-letter ISO 3166 country code. */ fun country(country: JsonField) = apply { this.country = country } /** Street address or PO box. */ - fun line1(line1: String) = line1(JsonField.of(line1)) + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + /** Street address or PO box. */ + fun line1(line1: Optional) = line1(line1.orElse(null)) /** Street address or PO box. */ fun line1(line1: JsonField) = apply { this.line1 = line1 } /** Apartment, suite, unit, or building. */ - fun line2(line2: String) = line2(JsonField.of(line2)) + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + /** Apartment, suite, unit, or building. */ + fun line2(line2: Optional) = line2(line2.orElse(null)) /** Apartment, suite, unit, or building. */ fun line2(line2: JsonField) = apply { this.line2 = line2 } - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) fun name(name: JsonField) = apply { this.name = name } /** The postal code or zip code. */ - fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + /** The postal code or zip code. */ + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) /** The postal code or zip code. */ fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun sourceId(sourceId: String) = sourceId(JsonField.of(sourceId)) + fun sourceId(sourceId: String?) = sourceId(JsonField.ofNullable(sourceId)) + + fun sourceId(sourceId: Optional) = sourceId(sourceId.orElse(null)) fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } /** The state code. */ - fun state(state: String) = state(JsonField.of(state)) + fun state(state: String?) = state(JsonField.ofNullable(state)) + + /** The state code. */ + fun state(state: Optional) = state(state.orElse(null)) /** The state code. */ fun state(state: JsonField) = apply { this.state = state } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ManualAsyncJob.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ManualAsyncJob.kt index e5969d97..0d24f99c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ManualAsyncJob.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/ManualAsyncJob.kt @@ -40,11 +40,11 @@ private constructor( fun status(): Status = status.getRequired("status") /** Specific information about the job, such as individual statuses for batch jobs. */ - @JsonProperty("body") @ExcludeMissing fun _body() = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField> = body - @JsonProperty("job_id") @ExcludeMissing fun _jobId() = jobId + @JsonProperty("job_id") @ExcludeMissing fun _jobId(): JsonField = jobId - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -70,24 +70,43 @@ private constructor( class Builder { - private var body: JsonField> = JsonMissing.of() - private var jobId: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() + private var body: JsonField>? = null + private var jobId: JsonField? = null + private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(manualAsyncJob: ManualAsyncJob) = apply { - body = manualAsyncJob.body + body = manualAsyncJob.body.map { it.toMutableList() } jobId = manualAsyncJob.jobId status = manualAsyncJob.status additionalProperties = manualAsyncJob.additionalProperties.toMutableMap() } /** Specific information about the job, such as individual statuses for batch jobs. */ - fun body(body: List) = body(JsonField.of(body)) + fun body(body: List?) = body(JsonField.ofNullable(body)) /** Specific information about the job, such as individual statuses for batch jobs. */ - fun body(body: JsonField>) = apply { this.body = body } + fun body(body: Optional>) = body(body.orElse(null)) + + /** Specific information about the job, such as individual statuses for batch jobs. */ + fun body(body: JsonField>) = apply { + this.body = body.map { it.toMutableList() } + } + + /** Specific information about the job, such as individual statuses for batch jobs. */ + fun addBody(body: JsonValue) = apply { + this.body = + (this.body ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(body) + } + } fun jobId(jobId: String) = jobId(JsonField.of(jobId)) @@ -118,9 +137,10 @@ private constructor( fun build(): ManualAsyncJob = ManualAsyncJob( - body.map { it.toImmutable() }, - jobId, - status, + checkNotNull(body) { "`body` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(jobId) { "`jobId` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, additionalProperties.toImmutable(), ) } 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 3305db6c..59202734 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 @@ -33,9 +33,9 @@ private constructor( fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** Amount for money object (in cents) */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -72,7 +72,14 @@ private constructor( } /** Amount for money object (in cents) */ - fun amount(amount: Long) = amount(JsonField.of(amount)) + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** Amount for money object (in cents) */ + fun amount(amount: Long) = amount(amount as Long?) + + /** Amount for money object (in cents) */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) /** Amount for money object (in cents) */ fun amount(amount: JsonField) = apply { this.amount = amount } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupportMatrix.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupportMatrix.kt index 2e2ed02d..42e31488 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupportMatrix.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/OperationSupportMatrix.kt @@ -88,7 +88,7 @@ private constructor( * - `client_access_only`: This behavior is supported by the provider, but only available to the * client and not to Finch */ - @JsonProperty("create") @ExcludeMissing fun _create() = create + @JsonProperty("create") @ExcludeMissing fun _create(): JsonField = create /** * - `supported`: This operation is supported by both the provider and Finch @@ -99,7 +99,7 @@ private constructor( * - `client_access_only`: This behavior is supported by the provider, but only available to the * client and not to Finch */ - @JsonProperty("delete") @ExcludeMissing fun _delete() = delete + @JsonProperty("delete") @ExcludeMissing fun _delete(): JsonField = delete /** * - `supported`: This operation is supported by both the provider and Finch @@ -110,7 +110,7 @@ private constructor( * - `client_access_only`: This behavior is supported by the provider, but only available to the * client and not to Finch */ - @JsonProperty("read") @ExcludeMissing fun _read() = read + @JsonProperty("read") @ExcludeMissing fun _read(): JsonField = read /** * - `supported`: This operation is supported by both the provider and Finch @@ -121,7 +121,7 @@ private constructor( * - `client_access_only`: This behavior is supported by the provider, but only available to the * client and not to Finch */ - @JsonProperty("update") @ExcludeMissing fun _update() = update + @JsonProperty("update") @ExcludeMissing fun _update(): JsonField = update @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Paging.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Paging.kt index fe1f77e2..4ce7f300 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Paging.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Paging.kt @@ -32,10 +32,10 @@ private constructor( fun offset(): Optional = Optional.ofNullable(offset.getNullable("offset")) /** The total number of elements for the entire query (not just the given page) */ - @JsonProperty("count") @ExcludeMissing fun _count() = count + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count /** The current start index of the returned list of elements */ - @JsonProperty("offset") @ExcludeMissing fun _offset() = offset + @JsonProperty("offset") @ExcludeMissing fun _offset(): JsonField = offset @JsonAnyGetter @ExcludeMissing 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 8539c47f..e83fa445 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 @@ -41,13 +41,15 @@ private constructor( Optional.ofNullable(payFrequencies.getNullable("pay_frequencies")) /** Finch id (uuidv4) for the pay group */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** Name of the pay group */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** List of pay frequencies associated with this pay group */ - @JsonProperty("pay_frequencies") @ExcludeMissing fun _payFrequencies() = payFrequencies + @JsonProperty("pay_frequencies") + @ExcludeMissing + fun _payFrequencies(): JsonField> = payFrequencies @JsonAnyGetter @ExcludeMissing @@ -75,14 +77,14 @@ private constructor( private var id: JsonField = JsonMissing.of() private var name: JsonField = JsonMissing.of() - private var payFrequencies: JsonField> = JsonMissing.of() + private var payFrequencies: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(payGroupListResponse: PayGroupListResponse) = apply { id = payGroupListResponse.id name = payGroupListResponse.name - payFrequencies = payGroupListResponse.payFrequencies + payFrequencies = payGroupListResponse.payFrequencies.map { it.toMutableList() } additionalProperties = payGroupListResponse.additionalProperties.toMutableMap() } @@ -104,7 +106,21 @@ private constructor( /** List of pay frequencies associated with this pay group */ fun payFrequencies(payFrequencies: JsonField>) = apply { - this.payFrequencies = payFrequencies + this.payFrequencies = payFrequencies.map { it.toMutableList() } + } + + /** List of pay frequencies associated with this pay group */ + fun addPayFrequency(payFrequency: PayFrequency) = apply { + payFrequencies = + (payFrequencies ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(payFrequency) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -130,7 +146,7 @@ private constructor( PayGroupListResponse( id, name, - payFrequencies.map { it.toImmutable() }, + (payFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } 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 583c9ac3..830b64c5 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 @@ -44,15 +44,19 @@ private constructor( fun payFrequencies(): List = payFrequencies.getRequired("pay_frequencies") /** Finch id (uuidv4) for the pay group */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("individual_ids") @ExcludeMissing fun _individualIds() = individualIds + @JsonProperty("individual_ids") + @ExcludeMissing + fun _individualIds(): JsonField> = individualIds /** Name of the pay group */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** List of pay frequencies associated with this pay group */ - @JsonProperty("pay_frequencies") @ExcludeMissing fun _payFrequencies() = payFrequencies + @JsonProperty("pay_frequencies") + @ExcludeMissing + fun _payFrequencies(): JsonField> = payFrequencies @JsonAnyGetter @ExcludeMissing @@ -79,18 +83,18 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var individualIds: JsonField> = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var payFrequencies: JsonField> = JsonMissing.of() + private var id: JsonField? = null + private var individualIds: JsonField>? = null + private var name: JsonField? = null + private var payFrequencies: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(payGroupRetrieveResponse: PayGroupRetrieveResponse) = apply { id = payGroupRetrieveResponse.id - individualIds = payGroupRetrieveResponse.individualIds + individualIds = payGroupRetrieveResponse.individualIds.map { it.toMutableList() } name = payGroupRetrieveResponse.name - payFrequencies = payGroupRetrieveResponse.payFrequencies + payFrequencies = payGroupRetrieveResponse.payFrequencies.map { it.toMutableList() } additionalProperties = payGroupRetrieveResponse.additionalProperties.toMutableMap() } @@ -103,7 +107,20 @@ private constructor( fun individualIds(individualIds: List) = individualIds(JsonField.of(individualIds)) fun individualIds(individualIds: JsonField>) = apply { - this.individualIds = individualIds + this.individualIds = individualIds.map { it.toMutableList() } + } + + fun addIndividualId(individualId: String) = apply { + individualIds = + (individualIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(individualId) + } } /** Name of the pay group */ @@ -118,7 +135,21 @@ private constructor( /** List of pay frequencies associated with this pay group */ fun payFrequencies(payFrequencies: JsonField>) = apply { - this.payFrequencies = payFrequencies + this.payFrequencies = payFrequencies.map { it.toMutableList() } + } + + /** List of pay frequencies associated with this pay group */ + fun addPayFrequency(payFrequency: PayFrequency) = apply { + payFrequencies = + (payFrequencies ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(payFrequency) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -142,10 +173,12 @@ private constructor( fun build(): PayGroupRetrieveResponse = PayGroupRetrieveResponse( - id, - individualIds.map { it.toImmutable() }, - name, - payFrequencies.map { it.toImmutable() }, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(individualIds) { "`individualIds` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(payFrequencies) { "`payFrequencies` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt index a39df463..8edc003b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatement.kt @@ -85,35 +85,39 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** The array of earnings objects associated with this pay statement */ - @JsonProperty("earnings") @ExcludeMissing fun _earnings() = earnings + @JsonProperty("earnings") @ExcludeMissing fun _earnings(): JsonField> = earnings /** The array of deductions objects associated with this pay statement. */ @JsonProperty("employee_deductions") @ExcludeMissing - fun _employeeDeductions() = employeeDeductions + fun _employeeDeductions(): JsonField> = employeeDeductions @JsonProperty("employer_contributions") @ExcludeMissing - fun _employerContributions() = employerContributions + fun _employerContributions(): JsonField> = employerContributions - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay() = grossPay + @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay /** A stable Finch `id` (UUID v4) for an individual in the company */ - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId - @JsonProperty("net_pay") @ExcludeMissing fun _netPay() = netPay + @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay /** The payment method. */ - @JsonProperty("payment_method") @ExcludeMissing fun _paymentMethod() = paymentMethod + @JsonProperty("payment_method") + @ExcludeMissing + fun _paymentMethod(): JsonField = paymentMethod /** The array of taxes objects associated with this pay statement. */ - @JsonProperty("taxes") @ExcludeMissing fun _taxes() = taxes + @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes /** The number of hours worked for this pay period */ - @JsonProperty("total_hours") @ExcludeMissing fun _totalHours() = totalHours + @JsonProperty("total_hours") @ExcludeMissing fun _totalHours(): JsonField = totalHours /** The type of the payment associated with the pay statement. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -146,57 +150,112 @@ private constructor( class Builder { - private var earnings: JsonField> = JsonMissing.of() - private var employeeDeductions: JsonField> = JsonMissing.of() - private var employerContributions: JsonField> = JsonMissing.of() + 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> = 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 - employeeDeductions = payStatement.employeeDeductions - employerContributions = payStatement.employerContributions + 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 + 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.of(earnings)) + fun earnings(earnings: List?) = earnings(JsonField.ofNullable(earnings)) + + /** The array of earnings objects associated with this pay statement */ + fun earnings(earnings: Optional>) = earnings(earnings.orElse(null)) /** The array of earnings objects associated with this pay statement */ - fun earnings(earnings: JsonField>) = apply { this.earnings = earnings } + fun earnings(earnings: JsonField>) = apply { + this.earnings = earnings.map { it.toMutableList() } + } + + /** The array of earnings objects associated with this pay statement */ + fun addEarning(earning: Earning) = apply { + earnings = + (earnings ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(earning) + } + } + + /** The array of deductions objects associated with this pay statement. */ + fun employeeDeductions(employeeDeductions: List?) = + employeeDeductions(JsonField.ofNullable(employeeDeductions)) /** The array of deductions objects associated with this pay statement. */ - fun employeeDeductions(employeeDeductions: List) = - employeeDeductions(JsonField.of(employeeDeductions)) + fun employeeDeductions(employeeDeductions: Optional>) = + employeeDeductions(employeeDeductions.orElse(null)) /** The array of deductions objects associated with this pay statement. */ fun employeeDeductions(employeeDeductions: JsonField>) = apply { - this.employeeDeductions = employeeDeductions + this.employeeDeductions = employeeDeductions.map { it.toMutableList() } + } + + /** The array of deductions objects associated with this pay statement. */ + fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { + employeeDeductions = + (employeeDeductions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(employeeDeduction) + } } - fun employerContributions(employerContributions: List) = - employerContributions(JsonField.of(employerContributions)) + fun employerContributions(employerContributions: List?) = + employerContributions(JsonField.ofNullable(employerContributions)) + + fun employerContributions(employerContributions: Optional>) = + employerContributions(employerContributions.orElse(null)) fun employerContributions(employerContributions: JsonField>) = apply { - this.employerContributions = employerContributions + this.employerContributions = employerContributions.map { it.toMutableList() } } - fun grossPay(grossPay: Money) = grossPay(JsonField.of(grossPay)) + fun addEmployerContribution(employerContribution: EmployerContribution) = apply { + employerContributions = + (employerContributions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(employerContribution) + } + } + + fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) + + fun grossPay(grossPay: Optional) = grossPay(grossPay.orElse(null)) fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } @@ -208,12 +267,19 @@ private constructor( this.individualId = individualId } - fun netPay(netPay: Money) = netPay(JsonField.of(netPay)) + fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) + + fun netPay(netPay: Optional) = netPay(netPay.orElse(null)) fun netPay(netPay: JsonField) = apply { this.netPay = netPay } /** The payment method. */ - fun paymentMethod(paymentMethod: PaymentMethod) = paymentMethod(JsonField.of(paymentMethod)) + fun paymentMethod(paymentMethod: PaymentMethod?) = + paymentMethod(JsonField.ofNullable(paymentMethod)) + + /** The payment method. */ + fun paymentMethod(paymentMethod: Optional) = + paymentMethod(paymentMethod.orElse(null)) /** The payment method. */ fun paymentMethod(paymentMethod: JsonField) = apply { @@ -221,19 +287,49 @@ private constructor( } /** The array of taxes objects associated with this pay statement. */ - fun taxes(taxes: List) = taxes(JsonField.of(taxes)) + fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) + + /** The array of taxes objects associated with this pay statement. */ + fun taxes(taxes: Optional>) = taxes(taxes.orElse(null)) + + /** The array of taxes objects associated with this pay statement. */ + fun taxes(taxes: JsonField>) = apply { + this.taxes = taxes.map { it.toMutableList() } + } /** The array of taxes objects associated with this pay statement. */ - fun taxes(taxes: JsonField>) = apply { this.taxes = taxes } + fun addTax(tax: Tax) = apply { + taxes = + (taxes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tax) + } + } + + /** The number of hours worked for this pay period */ + fun totalHours(totalHours: Double?) = totalHours(JsonField.ofNullable(totalHours)) + + /** The number of hours worked for this pay period */ + fun totalHours(totalHours: Double) = totalHours(totalHours as Double?) /** The number of hours worked for this pay period */ - fun totalHours(totalHours: Double) = totalHours(JsonField.of(totalHours)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun totalHours(totalHours: Optional) = + totalHours(totalHours.orElse(null) as Double?) /** The number of hours worked for this pay period */ fun totalHours(totalHours: JsonField) = apply { this.totalHours = totalHours } /** The type of the payment associated with the pay statement. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** The type of the payment associated with the pay statement. */ + fun type(type: Optional) = type(type.orElse(null)) /** The type of the payment associated with the pay statement. */ fun type(type: JsonField) = apply { this.type = type } @@ -259,14 +355,14 @@ private constructor( fun build(): PayStatement = PayStatement( - earnings.map { it.toImmutable() }, - employeeDeductions.map { it.toImmutable() }, - employerContributions.map { it.toImmutable() }, + (earnings ?: JsonMissing.of()).map { it.toImmutable() }, + (employeeDeductions ?: JsonMissing.of()).map { it.toImmutable() }, + (employerContributions ?: JsonMissing.of()).map { it.toImmutable() }, grossPay, individualId, netPay, paymentMethod, - taxes.map { it.toImmutable() }, + (taxes ?: JsonMissing.of()).map { it.toImmutable() }, totalHours, type, additionalProperties.toImmutable(), @@ -313,22 +409,22 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** The earnings amount in cents. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The earnings currency code. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = 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). */ - @JsonProperty("hours") @ExcludeMissing fun _hours() = hours + @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField = hours /** The exact name of the deduction from the pay statement. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The type of earning. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -374,13 +470,23 @@ private constructor( } /** The earnings amount in cents. */ - fun amount(amount: Long) = amount(JsonField.of(amount)) + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** The earnings amount in cents. */ + fun amount(amount: Long) = amount(amount as Long?) + + /** The earnings amount in cents. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) /** The earnings amount in cents. */ fun amount(amount: JsonField) = apply { this.amount = amount } /** The earnings currency code. */ - fun currency(currency: String) = currency(JsonField.of(currency)) + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** The earnings currency code. */ + fun currency(currency: Optional) = currency(currency.orElse(null)) /** The earnings currency code. */ fun currency(currency: JsonField) = apply { this.currency = currency } @@ -389,7 +495,20 @@ private constructor( * 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.of(hours)) + fun hours(hours: Double?) = hours(JsonField.ofNullable(hours)) + + /** + * 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(hours as Double?) + + /** + * 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). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun hours(hours: Optional) = hours(hours.orElse(null) as Double?) /** * The number of hours associated with this earning. (For salaried employees, this could @@ -398,13 +517,19 @@ private constructor( fun hours(hours: JsonField) = apply { this.hours = hours } /** The exact name of the deduction from the pay statement. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The exact name of the deduction from the pay statement. */ + fun name(name: Optional) = name(name.orElse(null)) /** The exact name of the deduction from the pay statement. */ fun name(name: JsonField) = apply { this.name = name } /** The type of earning. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** The type of earning. */ + fun type(type: Optional) = type(type.orElse(null)) /** The type of earning. */ fun type(type: JsonField) = apply { this.type = type } @@ -619,19 +744,19 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** The deduction amount in cents. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The deduction currency. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The deduction name from the pay statement. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Boolean indicating if the deduction is pre-tax. */ - @JsonProperty("pre_tax") @ExcludeMissing fun _preTax() = preTax + @JsonProperty("pre_tax") @ExcludeMissing fun _preTax(): JsonField = preTax /** Type of benefit. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -677,31 +802,54 @@ private constructor( } /** The deduction amount in cents. */ - fun amount(amount: Long) = amount(JsonField.of(amount)) + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** The deduction amount in cents. */ + fun amount(amount: Long) = amount(amount as Long?) + + /** The deduction amount in cents. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) /** The deduction amount in cents. */ fun amount(amount: JsonField) = apply { this.amount = amount } /** The deduction currency. */ - fun currency(currency: String) = currency(JsonField.of(currency)) + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** The deduction currency. */ + fun currency(currency: Optional) = currency(currency.orElse(null)) /** The deduction currency. */ fun currency(currency: JsonField) = apply { this.currency = currency } /** The deduction name from the pay statement. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The deduction name from the pay statement. */ + fun name(name: Optional) = name(name.orElse(null)) /** The deduction name from the pay statement. */ fun name(name: JsonField) = apply { this.name = name } /** Boolean indicating if the deduction is pre-tax. */ - fun preTax(preTax: Boolean) = preTax(JsonField.of(preTax)) + fun preTax(preTax: Boolean?) = preTax(JsonField.ofNullable(preTax)) + + /** Boolean indicating if the deduction is pre-tax. */ + fun preTax(preTax: Boolean) = preTax(preTax as Boolean?) + + /** Boolean indicating if the deduction is pre-tax. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun preTax(preTax: Optional) = preTax(preTax.orElse(null) as Boolean?) /** Boolean indicating if the deduction is pre-tax. */ fun preTax(preTax: JsonField) = apply { this.preTax = preTax } /** Type of benefit. */ - fun type(type: BenefitType) = type(JsonField.of(type)) + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + + /** Type of benefit. */ + fun type(type: Optional) = type(type.orElse(null)) /** Type of benefit. */ fun type(type: JsonField) = apply { this.type = type } @@ -787,16 +935,16 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** The contribution amount in cents. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The contribution currency. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The contribution name from the pay statement. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Type of benefit. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -839,25 +987,41 @@ private constructor( } /** The contribution amount in cents. */ - fun amount(amount: Long) = amount(JsonField.of(amount)) + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** The contribution amount in cents. */ + fun amount(amount: Long) = amount(amount as Long?) + + /** The contribution amount in cents. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) /** The contribution amount in cents. */ fun amount(amount: JsonField) = apply { this.amount = amount } /** The contribution currency. */ - fun currency(currency: String) = currency(JsonField.of(currency)) + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** The contribution currency. */ + fun currency(currency: Optional) = currency(currency.orElse(null)) /** The contribution currency. */ fun currency(currency: JsonField) = apply { this.currency = currency } /** The contribution name from the pay statement. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The contribution name from the pay statement. */ + fun name(name: Optional) = name(name.orElse(null)) /** The contribution name from the pay statement. */ fun name(name: JsonField) = apply { this.name = name } /** Type of benefit. */ - fun type(type: BenefitType) = type(JsonField.of(type)) + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + + /** Type of benefit. */ + fun type(type: Optional) = type(type.orElse(null)) /** Type of benefit. */ fun type(type: JsonField) = apply { this.type = type } @@ -1003,19 +1167,19 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** The tax amount in cents. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The currency code. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** `true` if the amount is paid by the employers. */ - @JsonProperty("employer") @ExcludeMissing fun _employer() = employer + @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer /** The exact name of tax from the pay statement. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The type of taxes. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1061,31 +1225,54 @@ private constructor( } /** The tax amount in cents. */ - fun amount(amount: Long) = amount(JsonField.of(amount)) + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) + + /** The tax amount in cents. */ + fun amount(amount: Long) = amount(amount as Long?) + + /** The tax amount in cents. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) /** The tax amount in cents. */ fun amount(amount: JsonField) = apply { this.amount = amount } /** The currency code. */ - fun currency(currency: String) = currency(JsonField.of(currency)) + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** The currency code. */ + fun currency(currency: Optional) = currency(currency.orElse(null)) /** The currency code. */ fun currency(currency: JsonField) = apply { this.currency = currency } /** `true` if the amount is paid by the employers. */ - fun employer(employer: Boolean) = employer(JsonField.of(employer)) + fun employer(employer: Boolean?) = employer(JsonField.ofNullable(employer)) + + /** `true` if the amount is paid by the employers. */ + fun employer(employer: Boolean) = employer(employer as Boolean?) + + /** `true` if the amount is paid by the employers. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun employer(employer: Optional) = employer(employer.orElse(null) as Boolean?) /** `true` if the amount is paid by the employers. */ fun employer(employer: JsonField) = apply { this.employer = employer } /** The exact name of tax from the pay statement. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** The exact name of tax from the pay statement. */ + fun name(name: Optional) = name(name.orElse(null)) /** The exact name of tax from the pay statement. */ fun name(name: JsonField) = apply { this.name = name } /** The type of taxes. */ - fun type(type: Type) = type(JsonField.of(type)) + fun type(type: Type?) = type(JsonField.ofNullable(type)) + + /** The type of taxes. */ + fun type(type: Optional) = type(type.orElse(null)) /** The type of taxes. */ fun type(type: JsonField) = apply { this.type = type } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementEvent.kt index 46c7db05..50bae7d3 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PayStatementEvent.kt @@ -62,20 +62,22 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing @@ -110,8 +112,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var data: JsonField = JsonMissing.of() private var eventType: JsonField = JsonMissing.of() @@ -188,8 +190,8 @@ private constructor( fun build(): PayStatementEvent = PayStatementEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, data, eventType, @@ -219,10 +221,12 @@ private constructor( fun paymentId(): Optional = Optional.ofNullable(paymentId.getNullable("payment_id")) /** The ID of the individual associated with the pay statement. */ - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId /** The ID of the payment associated with the pay statement. */ - @JsonProperty("payment_id") @ExcludeMissing fun _paymentId() = paymentId + @JsonProperty("payment_id") @ExcludeMissing fun _paymentId(): JsonField = paymentId @JsonAnyGetter @ExcludeMissing 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 5d77697f..6924dc30 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 @@ -36,11 +36,11 @@ private constructor( fun paymentId(): Optional = Optional.ofNullable(paymentId.getNullable("payment_id")) - @JsonProperty("body") @ExcludeMissing fun _body() = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("payment_id") @ExcludeMissing fun _paymentId() = paymentId + @JsonProperty("payment_id") @ExcludeMissing fun _paymentId(): JsonField = paymentId @JsonAnyGetter @ExcludeMissing 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 52acf10f..a14b8564 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 @@ -35,10 +35,12 @@ private constructor( fun payStatements(): Optional> = Optional.ofNullable(payStatements.getNullable("pay_statements")) - @JsonProperty("paging") @ExcludeMissing fun _paging() = paging + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging /** The array of pay statements for the current payment. */ - @JsonProperty("pay_statements") @ExcludeMissing fun _payStatements() = payStatements + @JsonProperty("pay_statements") + @ExcludeMissing + fun _payStatements(): JsonField> = payStatements @JsonAnyGetter @ExcludeMissing @@ -64,13 +66,13 @@ private constructor( class Builder { private var paging: JsonField = JsonMissing.of() - private var payStatements: JsonField> = JsonMissing.of() + private var payStatements: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(payStatementResponseBody: PayStatementResponseBody) = apply { paging = payStatementResponseBody.paging - payStatements = payStatementResponseBody.payStatements + payStatements = payStatementResponseBody.payStatements.map { it.toMutableList() } additionalProperties = payStatementResponseBody.additionalProperties.toMutableMap() } @@ -84,7 +86,21 @@ private constructor( /** The array of pay statements for the current payment. */ fun payStatements(payStatements: JsonField>) = apply { - this.payStatements = payStatements + this.payStatements = payStatements.map { it.toMutableList() } + } + + /** The array of pay statements for the current payment. */ + fun addPayStatement(payStatement: PayStatement) = apply { + payStatements = + (payStatements ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(payStatement) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -109,7 +125,7 @@ private constructor( fun build(): PayStatementResponseBody = PayStatementResponseBody( paging, - payStatements.map { it.toImmutable() }, + (payStatements ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } 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 a5b93d14..6a0c1ffb 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 @@ -95,33 +95,45 @@ private constructor( fun payPeriod(): Optional = Optional.ofNullable(payPeriod.getNullable("pay_period")) /** The unique id for the payment. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("company_debit") @ExcludeMissing fun _companyDebit() = companyDebit + @JsonProperty("company_debit") + @ExcludeMissing + fun _companyDebit(): JsonField = companyDebit - @JsonProperty("debit_date") @ExcludeMissing fun _debitDate() = debitDate + @JsonProperty("debit_date") @ExcludeMissing fun _debitDate(): JsonField = debitDate - @JsonProperty("employee_taxes") @ExcludeMissing fun _employeeTaxes() = employeeTaxes + @JsonProperty("employee_taxes") + @ExcludeMissing + fun _employeeTaxes(): JsonField = employeeTaxes - @JsonProperty("employer_taxes") @ExcludeMissing fun _employerTaxes() = employerTaxes + @JsonProperty("employer_taxes") + @ExcludeMissing + fun _employerTaxes(): JsonField = employerTaxes - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay() = grossPay + @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay /** Array of every individual on this payment. */ - @JsonProperty("individual_ids") @ExcludeMissing fun _individualIds() = individualIds + @JsonProperty("individual_ids") + @ExcludeMissing + fun _individualIds(): JsonField> = individualIds - @JsonProperty("net_pay") @ExcludeMissing fun _netPay() = netPay + @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay - @JsonProperty("pay_date") @ExcludeMissing fun _payDate() = payDate + @JsonProperty("pay_date") @ExcludeMissing fun _payDate(): JsonField = payDate /** List of pay frequencies associated with this payment. */ - @JsonProperty("pay_frequencies") @ExcludeMissing fun _payFrequencies() = payFrequencies + @JsonProperty("pay_frequencies") + @ExcludeMissing + fun _payFrequencies(): JsonField> = payFrequencies /** Array of the Finch id (uuidv4) of every pay group associated with this payment. */ - @JsonProperty("pay_group_ids") @ExcludeMissing fun _payGroupIds() = payGroupIds + @JsonProperty("pay_group_ids") + @ExcludeMissing + fun _payGroupIds(): JsonField> = payGroupIds /** The pay period object. */ - @JsonProperty("pay_period") @ExcludeMissing fun _payPeriod() = payPeriod + @JsonProperty("pay_period") @ExcludeMissing fun _payPeriod(): JsonField = payPeriod @JsonAnyGetter @ExcludeMissing @@ -162,11 +174,11 @@ private constructor( private var employeeTaxes: JsonField = JsonMissing.of() private var employerTaxes: JsonField = JsonMissing.of() private var grossPay: JsonField = JsonMissing.of() - private var individualIds: JsonField> = JsonMissing.of() + private var individualIds: JsonField>? = null private var netPay: JsonField = JsonMissing.of() private var payDate: JsonField = JsonMissing.of() - private var payFrequencies: JsonField> = JsonMissing.of() - private var payGroupIds: JsonField> = JsonMissing.of() + private var payFrequencies: JsonField>? = null + private var payGroupIds: JsonField>? = null private var payPeriod: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -178,11 +190,11 @@ private constructor( employeeTaxes = payment.employeeTaxes employerTaxes = payment.employerTaxes grossPay = payment.grossPay - individualIds = payment.individualIds + individualIds = payment.individualIds.map { it.toMutableList() } netPay = payment.netPay payDate = payment.payDate - payFrequencies = payment.payFrequencies - payGroupIds = payment.payGroupIds + payFrequencies = payment.payFrequencies.map { it.toMutableList() } + payGroupIds = payment.payGroupIds.map { it.toMutableList() } payPeriod = payment.payPeriod additionalProperties = payment.additionalProperties.toMutableMap() } @@ -193,67 +205,142 @@ private constructor( /** The unique id for the payment. */ fun id(id: JsonField) = apply { this.id = id } - fun companyDebit(companyDebit: Money) = companyDebit(JsonField.of(companyDebit)) + fun companyDebit(companyDebit: Money?) = companyDebit(JsonField.ofNullable(companyDebit)) + + fun companyDebit(companyDebit: Optional) = companyDebit(companyDebit.orElse(null)) fun companyDebit(companyDebit: JsonField) = apply { this.companyDebit = companyDebit } - fun debitDate(debitDate: String) = debitDate(JsonField.of(debitDate)) + fun debitDate(debitDate: String?) = debitDate(JsonField.ofNullable(debitDate)) + + fun debitDate(debitDate: Optional) = debitDate(debitDate.orElse(null)) fun debitDate(debitDate: JsonField) = apply { this.debitDate = debitDate } - fun employeeTaxes(employeeTaxes: Money) = employeeTaxes(JsonField.of(employeeTaxes)) + fun employeeTaxes(employeeTaxes: Money?) = + employeeTaxes(JsonField.ofNullable(employeeTaxes)) + + fun employeeTaxes(employeeTaxes: Optional) = + employeeTaxes(employeeTaxes.orElse(null)) fun employeeTaxes(employeeTaxes: JsonField) = apply { this.employeeTaxes = employeeTaxes } - fun employerTaxes(employerTaxes: Money) = employerTaxes(JsonField.of(employerTaxes)) + fun employerTaxes(employerTaxes: Money?) = + employerTaxes(JsonField.ofNullable(employerTaxes)) + + fun employerTaxes(employerTaxes: Optional) = + employerTaxes(employerTaxes.orElse(null)) fun employerTaxes(employerTaxes: JsonField) = apply { this.employerTaxes = employerTaxes } - fun grossPay(grossPay: Money) = grossPay(JsonField.of(grossPay)) + fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) + + fun grossPay(grossPay: Optional) = grossPay(grossPay.orElse(null)) fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } /** Array of every individual on this payment. */ - fun individualIds(individualIds: List) = individualIds(JsonField.of(individualIds)) + fun individualIds(individualIds: List?) = + individualIds(JsonField.ofNullable(individualIds)) + + /** Array of every individual on this payment. */ + fun individualIds(individualIds: Optional>) = + individualIds(individualIds.orElse(null)) /** Array of every individual on this payment. */ fun individualIds(individualIds: JsonField>) = apply { - this.individualIds = individualIds + this.individualIds = individualIds.map { it.toMutableList() } } - fun netPay(netPay: Money) = netPay(JsonField.of(netPay)) + /** Array of every individual on this payment. */ + fun addIndividualId(individualId: String) = apply { + individualIds = + (individualIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(individualId) + } + } + + fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) + + fun netPay(netPay: Optional) = netPay(netPay.orElse(null)) fun netPay(netPay: JsonField) = apply { this.netPay = netPay } - fun payDate(payDate: String) = payDate(JsonField.of(payDate)) + fun payDate(payDate: String?) = payDate(JsonField.ofNullable(payDate)) + + fun payDate(payDate: Optional) = payDate(payDate.orElse(null)) fun payDate(payDate: JsonField) = apply { this.payDate = payDate } /** List of pay frequencies associated with this payment. */ - fun payFrequencies(payFrequencies: List) = - payFrequencies(JsonField.of(payFrequencies)) + fun payFrequencies(payFrequencies: List?) = + payFrequencies(JsonField.ofNullable(payFrequencies)) + + /** List of pay frequencies associated with this payment. */ + fun payFrequencies(payFrequencies: Optional>) = + payFrequencies(payFrequencies.orElse(null)) /** List of pay frequencies associated with this payment. */ fun payFrequencies(payFrequencies: JsonField>) = apply { - this.payFrequencies = payFrequencies + this.payFrequencies = payFrequencies.map { it.toMutableList() } + } + + /** List of pay frequencies associated with this payment. */ + fun addPayFrequency(payFrequency: PayFrequency) = apply { + payFrequencies = + (payFrequencies ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(payFrequency) + } } /** Array of the Finch id (uuidv4) of every pay group associated with this payment. */ - fun payGroupIds(payGroupIds: List) = payGroupIds(JsonField.of(payGroupIds)) + fun payGroupIds(payGroupIds: List?) = payGroupIds(JsonField.ofNullable(payGroupIds)) + + /** Array of the Finch id (uuidv4) of every pay group associated with this payment. */ + fun payGroupIds(payGroupIds: Optional>) = payGroupIds(payGroupIds.orElse(null)) /** Array of the Finch id (uuidv4) of every pay group associated with this payment. */ fun payGroupIds(payGroupIds: JsonField>) = apply { - this.payGroupIds = payGroupIds + this.payGroupIds = payGroupIds.map { it.toMutableList() } + } + + /** Array of the Finch id (uuidv4) of every pay group associated with this payment. */ + fun addPayGroupId(payGroupId: String) = apply { + payGroupIds = + (payGroupIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(payGroupId) + } } /** The pay period object. */ - fun payPeriod(payPeriod: PayPeriod) = payPeriod(JsonField.of(payPeriod)) + fun payPeriod(payPeriod: PayPeriod?) = payPeriod(JsonField.ofNullable(payPeriod)) + + /** The pay period object. */ + fun payPeriod(payPeriod: Optional) = payPeriod(payPeriod.orElse(null)) /** The pay period object. */ fun payPeriod(payPeriod: JsonField) = apply { this.payPeriod = payPeriod } @@ -285,11 +372,11 @@ private constructor( employeeTaxes, employerTaxes, grossPay, - individualIds.map { it.toImmutable() }, + (individualIds ?: JsonMissing.of()).map { it.toImmutable() }, netPay, payDate, - payFrequencies.map { it.toImmutable() }, - payGroupIds.map { it.toImmutable() }, + (payFrequencies ?: JsonMissing.of()).map { it.toImmutable() }, + (payGroupIds ?: JsonMissing.of()).map { it.toImmutable() }, payPeriod, additionalProperties.toImmutable(), ) @@ -413,9 +500,9 @@ private constructor( fun startDate(): Optional = Optional.ofNullable(startDate.getNullable("start_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -451,11 +538,15 @@ private constructor( additionalProperties = payPeriod.additionalProperties.toMutableMap() } - fun endDate(endDate: String) = endDate(JsonField.of(endDate)) + fun endDate(endDate: String?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - fun startDate(startDate: String) = startDate(JsonField.of(startDate)) + fun startDate(startDate: String?) = startDate(JsonField.ofNullable(startDate)) + + fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) fun startDate(startDate: JsonField) = apply { this.startDate = startDate } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentCreateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentCreateResponse.kt index 06534456..169ccfe8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentCreateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentCreateResponse.kt @@ -35,10 +35,10 @@ private constructor( fun paymentId(): String = paymentId.getRequired("payment_id") /** The date of the payment. */ - @JsonProperty("pay_date") @ExcludeMissing fun _payDate() = payDate + @JsonProperty("pay_date") @ExcludeMissing fun _payDate(): JsonField = payDate /** The ID of the payment. */ - @JsonProperty("payment_id") @ExcludeMissing fun _paymentId() = paymentId + @JsonProperty("payment_id") @ExcludeMissing fun _paymentId(): JsonField = paymentId @JsonAnyGetter @ExcludeMissing @@ -63,8 +63,8 @@ private constructor( class Builder { - private var payDate: JsonField = JsonMissing.of() - private var paymentId: JsonField = JsonMissing.of() + private var payDate: JsonField? = null + private var paymentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -107,8 +107,8 @@ private constructor( fun build(): PaymentCreateResponse = PaymentCreateResponse( - payDate, - paymentId, + checkNotNull(payDate) { "`payDate` is required but was not set" }, + checkNotNull(paymentId) { "`paymentId` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentEvent.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentEvent.kt index 19777058..6a340eb7 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentEvent.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/PaymentEvent.kt @@ -64,20 +64,22 @@ private constructor( * [DEPRECATED] Unique Finch ID of the employer account used to make this connection. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("account_id") @ExcludeMissing fun _accountId() = accountId + @JsonProperty("account_id") @ExcludeMissing fun _accountId(): JsonField = accountId /** * [DEPRECATED] Unique Finch ID of the company for which data has been updated. Use * `connection_id` instead to identify the connection associated with this event. */ - @JsonProperty("company_id") @ExcludeMissing fun _companyId() = companyId + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId /** Unique Finch ID of the connection associated with the webhook event. */ - @JsonProperty("connection_id") @ExcludeMissing fun _connectionId() = connectionId + @JsonProperty("connection_id") + @ExcludeMissing + fun _connectionId(): JsonField = connectionId - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("event_type") @ExcludeMissing fun _eventType() = eventType + @JsonProperty("event_type") @ExcludeMissing fun _eventType(): JsonField = eventType @JsonAnyGetter @ExcludeMissing @@ -112,8 +114,8 @@ private constructor( class Builder { - private var accountId: JsonField = JsonMissing.of() - private var companyId: JsonField = JsonMissing.of() + private var accountId: JsonField? = null + private var companyId: JsonField? = null private var connectionId: JsonField = JsonMissing.of() private var data: JsonField = JsonMissing.of() private var eventType: JsonField = JsonMissing.of() @@ -190,8 +192,8 @@ private constructor( fun build(): PaymentEvent = PaymentEvent( - accountId, - companyId, + checkNotNull(accountId) { "`accountId` is required but was not set" }, + checkNotNull(companyId) { "`companyId` is required but was not set" }, connectionId, data, eventType, @@ -220,10 +222,10 @@ private constructor( fun paymentId(): String = paymentId.getRequired("payment_id") /** The date of the payment. */ - @JsonProperty("pay_date") @ExcludeMissing fun _payDate() = payDate + @JsonProperty("pay_date") @ExcludeMissing fun _payDate(): JsonField = payDate /** The ID of the payment. */ - @JsonProperty("payment_id") @ExcludeMissing fun _paymentId() = paymentId + @JsonProperty("payment_id") @ExcludeMissing fun _paymentId(): JsonField = paymentId @JsonAnyGetter @ExcludeMissing @@ -248,8 +250,8 @@ private constructor( class Builder { - private var payDate: JsonField = JsonMissing.of() - private var paymentId: JsonField = JsonMissing.of() + private var payDate: JsonField? = null + private var paymentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -292,8 +294,8 @@ private constructor( fun build(): PaymentIdentifiers = PaymentIdentifiers( - payDate, - paymentId, + checkNotNull(payDate) { "`payDate` is required but was not set" }, + checkNotNull(paymentId) { "`paymentId` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Provider.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Provider.kt index 364184d0..3092504d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Provider.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/Provider.kt @@ -86,40 +86,46 @@ private constructor( fun products(): Optional> = Optional.ofNullable(products.getNullable("products")) /** The id of the payroll provider used in Connect. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The list of authentication methods supported by the provider. */ @JsonProperty("authentication_methods") @ExcludeMissing - fun _authenticationMethods() = authenticationMethods + fun _authenticationMethods(): JsonField> = authenticationMethods /** `true` if the integration is in a beta state, `false` otherwise */ - @JsonProperty("beta") @ExcludeMissing fun _beta() = beta + @JsonProperty("beta") @ExcludeMissing fun _beta(): JsonField = beta /** The display name of the payroll provider. */ - @JsonProperty("display_name") @ExcludeMissing fun _displayName() = displayName + @JsonProperty("display_name") + @ExcludeMissing + fun _displayName(): JsonField = displayName /** The url to the official icon of the payroll provider. */ - @JsonProperty("icon") @ExcludeMissing fun _icon() = icon + @JsonProperty("icon") @ExcludeMissing fun _icon(): JsonField = icon /** The url to the official logo of the payroll provider. */ - @JsonProperty("logo") @ExcludeMissing fun _logo() = logo + @JsonProperty("logo") @ExcludeMissing fun _logo(): JsonField = logo /** * [DEPRECATED] Whether the Finch integration with this provider uses the Assisted Connect Flow * by default. This field is now deprecated. Please check for a `type` of `assisted` in the * `authentication_methods` field instead. */ - @JsonProperty("manual") @ExcludeMissing fun _manual() = manual + @JsonProperty("manual") @ExcludeMissing fun _manual(): JsonField = manual /** whether MFA is required for the provider. */ - @JsonProperty("mfa_required") @ExcludeMissing fun _mfaRequired() = mfaRequired + @JsonProperty("mfa_required") + @ExcludeMissing + fun _mfaRequired(): JsonField = mfaRequired /** The hex code for the primary color of the payroll provider. */ - @JsonProperty("primary_color") @ExcludeMissing fun _primaryColor() = primaryColor + @JsonProperty("primary_color") + @ExcludeMissing + fun _primaryColor(): JsonField = primaryColor /** The list of Finch products supported on this payroll provider. */ - @JsonProperty("products") @ExcludeMissing fun _products() = products + @JsonProperty("products") @ExcludeMissing fun _products(): JsonField> = products @JsonAnyGetter @ExcludeMissing @@ -153,7 +159,7 @@ private constructor( class Builder { private var id: JsonField = JsonMissing.of() - private var authenticationMethods: JsonField> = JsonMissing.of() + private var authenticationMethods: JsonField>? = null private var beta: JsonField = JsonMissing.of() private var displayName: JsonField = JsonMissing.of() private var icon: JsonField = JsonMissing.of() @@ -161,13 +167,13 @@ private constructor( private var manual: JsonField = JsonMissing.of() private var mfaRequired: JsonField = JsonMissing.of() private var primaryColor: JsonField = JsonMissing.of() - private var products: JsonField> = JsonMissing.of() + private var products: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(provider: Provider) = apply { id = provider.id - authenticationMethods = provider.authenticationMethods + authenticationMethods = provider.authenticationMethods.map { it.toMutableList() } beta = provider.beta displayName = provider.displayName icon = provider.icon @@ -175,7 +181,7 @@ private constructor( manual = provider.manual mfaRequired = provider.mfaRequired primaryColor = provider.primaryColor - products = provider.products + products = provider.products.map { it.toMutableList() } additionalProperties = provider.additionalProperties.toMutableMap() } @@ -192,9 +198,23 @@ private constructor( /** The list of authentication methods supported by the provider. */ fun authenticationMethods(authenticationMethods: JsonField>) = apply { - this.authenticationMethods = authenticationMethods + this.authenticationMethods = authenticationMethods.map { it.toMutableList() } } + /** The list of authentication methods supported by the provider. */ + fun addAuthenticationMethod(authenticationMethod: AuthenticationMethod) = apply { + authenticationMethods = + (authenticationMethods ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(authenticationMethod) + } + } + /** `true` if the integration is in a beta state, `false` otherwise */ fun beta(beta: Boolean) = beta(JsonField.of(beta)) @@ -251,7 +271,23 @@ private constructor( fun products(products: List) = products(JsonField.of(products)) /** The list of Finch products supported on this payroll provider. */ - fun products(products: JsonField>) = apply { this.products = products } + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } + + /** The list of Finch products supported on this payroll provider. */ + fun addProduct(product: String) = apply { + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -275,7 +311,7 @@ private constructor( fun build(): Provider = Provider( id, - authenticationMethods.map { it.toImmutable() }, + (authenticationMethods ?: JsonMissing.of()).map { it.toImmutable() }, beta, displayName, icon, @@ -283,7 +319,7 @@ private constructor( manual, mfaRequired, primaryColor, - products.map { it.toImmutable() }, + (products ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -321,13 +357,17 @@ private constructor( * Each benefit type and their supported features. If the benefit type is not supported, the * property will be null */ - @JsonProperty("benefits_support") @ExcludeMissing fun _benefitsSupport() = benefitsSupport + @JsonProperty("benefits_support") + @ExcludeMissing + fun _benefitsSupport(): JsonField = benefitsSupport /** The supported data fields returned by our HR and payroll endpoints */ - @JsonProperty("supported_fields") @ExcludeMissing fun _supportedFields() = supportedFields + @JsonProperty("supported_fields") + @ExcludeMissing + fun _supportedFields(): JsonField = supportedFields /** The type of authentication method. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -370,8 +410,15 @@ private constructor( * Each benefit type and their supported features. If the benefit type is not supported, * the property will be null */ - fun benefitsSupport(benefitsSupport: BenefitsSupport) = - benefitsSupport(JsonField.of(benefitsSupport)) + fun benefitsSupport(benefitsSupport: BenefitsSupport?) = + benefitsSupport(JsonField.ofNullable(benefitsSupport)) + + /** + * Each benefit type and their supported features. If the benefit type is not supported, + * the property will be null + */ + fun benefitsSupport(benefitsSupport: Optional) = + benefitsSupport(benefitsSupport.orElse(null)) /** * Each benefit type and their supported features. If the benefit type is not supported, @@ -382,8 +429,12 @@ private constructor( } /** The supported data fields returned by our HR and payroll endpoints */ - fun supportedFields(supportedFields: SupportedFields) = - supportedFields(JsonField.of(supportedFields)) + fun supportedFields(supportedFields: SupportedFields?) = + supportedFields(JsonField.ofNullable(supportedFields)) + + /** The supported data fields returned by our HR and payroll endpoints */ + fun supportedFields(supportedFields: Optional) = + supportedFields(supportedFields.orElse(null)) /** The supported data fields returned by our HR and payroll endpoints */ fun supportedFields(supportedFields: JsonField) = apply { @@ -475,19 +526,33 @@ private constructor( fun payment(): Optional = Optional.ofNullable(payment.getNullable("payment")) - @JsonProperty("company") @ExcludeMissing fun _company() = company + @JsonProperty("company") + @ExcludeMissing + fun _company(): JsonField = company - @JsonProperty("directory") @ExcludeMissing fun _directory() = directory + @JsonProperty("directory") + @ExcludeMissing + fun _directory(): JsonField = directory - @JsonProperty("employment") @ExcludeMissing fun _employment() = employment + @JsonProperty("employment") + @ExcludeMissing + fun _employment(): JsonField = employment - @JsonProperty("individual") @ExcludeMissing fun _individual() = individual + @JsonProperty("individual") + @ExcludeMissing + fun _individual(): JsonField = individual - @JsonProperty("pay_group") @ExcludeMissing fun _payGroup() = payGroup + @JsonProperty("pay_group") + @ExcludeMissing + fun _payGroup(): JsonField = payGroup - @JsonProperty("pay_statement") @ExcludeMissing fun _payStatement() = payStatement + @JsonProperty("pay_statement") + @ExcludeMissing + fun _payStatement(): JsonField = payStatement - @JsonProperty("payment") @ExcludeMissing fun _payment() = payment + @JsonProperty("payment") + @ExcludeMissing + fun _payment(): JsonField = payment @JsonAnyGetter @ExcludeMissing @@ -678,25 +743,35 @@ private constructor( fun primaryPhoneNumber(): Optional = Optional.ofNullable(primaryPhoneNumber.getNullable("primary_phone_number")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("accounts") @ExcludeMissing fun _accounts() = accounts + @JsonProperty("accounts") + @ExcludeMissing + fun _accounts(): JsonField = accounts - @JsonProperty("departments") @ExcludeMissing fun _departments() = departments + @JsonProperty("departments") + @ExcludeMissing + fun _departments(): JsonField = departments - @JsonProperty("ein") @ExcludeMissing fun _ein() = ein + @JsonProperty("ein") @ExcludeMissing fun _ein(): JsonField = ein - @JsonProperty("entity") @ExcludeMissing fun _entity() = entity + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity - @JsonProperty("legal_name") @ExcludeMissing fun _legalName() = legalName + @JsonProperty("legal_name") + @ExcludeMissing + fun _legalName(): JsonField = legalName - @JsonProperty("locations") @ExcludeMissing fun _locations() = locations + @JsonProperty("locations") + @ExcludeMissing + fun _locations(): JsonField = locations - @JsonProperty("primary_email") @ExcludeMissing fun _primaryEmail() = primaryEmail + @JsonProperty("primary_email") + @ExcludeMissing + fun _primaryEmail(): JsonField = primaryEmail @JsonProperty("primary_phone_number") @ExcludeMissing - fun _primaryPhoneNumber() = primaryPhoneNumber + fun _primaryPhoneNumber(): JsonField = primaryPhoneNumber @JsonAnyGetter @ExcludeMissing @@ -878,21 +953,25 @@ private constructor( fun routingNumber(): Optional = Optional.ofNullable(routingNumber.getNullable("routing_number")) - @JsonProperty("account_name") @ExcludeMissing fun _accountName() = accountName + @JsonProperty("account_name") + @ExcludeMissing + fun _accountName(): JsonField = accountName @JsonProperty("account_number") @ExcludeMissing - fun _accountNumber() = accountNumber + fun _accountNumber(): JsonField = accountNumber - @JsonProperty("account_type") @ExcludeMissing fun _accountType() = accountType + @JsonProperty("account_type") + @ExcludeMissing + fun _accountType(): JsonField = accountType @JsonProperty("institution_name") @ExcludeMissing - fun _institutionName() = institutionName + fun _institutionName(): JsonField = institutionName @JsonProperty("routing_number") @ExcludeMissing - fun _routingNumber() = routingNumber + fun _routingNumber(): JsonField = routingNumber @JsonAnyGetter @ExcludeMissing @@ -1043,9 +1122,11 @@ private constructor( fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("parent") @ExcludeMissing fun _parent() = parent + @JsonProperty("parent") + @ExcludeMissing + fun _parent(): JsonField = parent @JsonAnyGetter @ExcludeMissing @@ -1135,7 +1216,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1253,9 +1334,11 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") + @ExcludeMissing + fun _subtype(): JsonField = subtype - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1388,17 +1471,21 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") + @ExcludeMissing + fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -1562,9 +1649,11 @@ private constructor( fun paging(): Optional = Optional.ofNullable(paging.getNullable("paging")) - @JsonProperty("individuals") @ExcludeMissing fun _individuals() = individuals + @JsonProperty("individuals") + @ExcludeMissing + fun _individuals(): JsonField = individuals - @JsonProperty("paging") @ExcludeMissing fun _paging() = paging + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging @JsonAnyGetter @ExcludeMissing @@ -1691,19 +1780,31 @@ private constructor( fun middleName(): Optional = Optional.ofNullable(middleName.getNullable("middle_name")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("department") @ExcludeMissing fun _department() = department + @JsonProperty("department") + @ExcludeMissing + fun _department(): JsonField = department - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") + @ExcludeMissing + fun _isActive(): JsonField = isActive - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName - @JsonProperty("manager") @ExcludeMissing fun _manager() = manager + @JsonProperty("manager") + @ExcludeMissing + fun _manager(): JsonField = manager - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") + @ExcludeMissing + fun _middleName(): JsonField = middleName @JsonAnyGetter @ExcludeMissing @@ -1842,7 +1943,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -1960,9 +2061,11 @@ private constructor( fun offset(): Optional = Optional.ofNullable(offset.getNullable("offset")) - @JsonProperty("count") @ExcludeMissing fun _count() = count + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count - @JsonProperty("offset") @ExcludeMissing fun _offset() = offset + @JsonProperty("offset") + @ExcludeMissing + fun _offset(): JsonField = offset @JsonAnyGetter @ExcludeMissing @@ -2180,41 +2283,67 @@ private constructor( fun title(): Optional = Optional.ofNullable(title.getNullable("title")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("class_code") @ExcludeMissing fun _classCode() = classCode + @JsonProperty("class_code") + @ExcludeMissing + fun _classCode(): JsonField = classCode - @JsonProperty("custom_fields") @ExcludeMissing fun _customFields() = customFields + @JsonProperty("custom_fields") + @ExcludeMissing + fun _customFields(): JsonField = customFields - @JsonProperty("department") @ExcludeMissing fun _department() = department + @JsonProperty("department") + @ExcludeMissing + fun _department(): JsonField = department - @JsonProperty("employment") @ExcludeMissing fun _employment() = employment + @JsonProperty("employment") + @ExcludeMissing + fun _employment(): JsonField = employment @JsonProperty("employment_status") @ExcludeMissing - fun _employmentStatus() = employmentStatus + fun _employmentStatus(): JsonField = employmentStatus - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName - @JsonProperty("income") @ExcludeMissing fun _income() = income + @JsonProperty("income") @ExcludeMissing fun _income(): JsonField = income - @JsonProperty("income_history") @ExcludeMissing fun _incomeHistory() = incomeHistory + @JsonProperty("income_history") + @ExcludeMissing + fun _incomeHistory(): JsonField = incomeHistory - @JsonProperty("is_active") @ExcludeMissing fun _isActive() = isActive + @JsonProperty("is_active") + @ExcludeMissing + fun _isActive(): JsonField = isActive - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName - @JsonProperty("location") @ExcludeMissing fun _location() = location + @JsonProperty("location") + @ExcludeMissing + fun _location(): JsonField = location - @JsonProperty("manager") @ExcludeMissing fun _manager() = manager + @JsonProperty("manager") + @ExcludeMissing + fun _manager(): JsonField = manager - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") + @ExcludeMissing + fun _middleName(): JsonField = middleName - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("title") @ExcludeMissing fun _title() = title + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title @JsonAnyGetter @ExcludeMissing @@ -2444,7 +2573,7 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2545,9 +2674,11 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("subtype") @ExcludeMissing fun _subtype() = subtype + @JsonProperty("subtype") + @ExcludeMissing + fun _subtype(): JsonField = subtype - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2665,11 +2796,15 @@ private constructor( fun unit(): Optional = Optional.ofNullable(unit.getNullable("unit")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("unit") @ExcludeMissing fun _unit() = unit + @JsonProperty("unit") @ExcludeMissing fun _unit(): JsonField = unit @JsonAnyGetter @ExcludeMissing @@ -2812,17 +2947,21 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") + @ExcludeMissing + fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -2962,7 +3101,7 @@ private constructor( fun id(): Optional = Optional.ofNullable(id.getNullable("id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -3142,31 +3281,47 @@ private constructor( fun ssn(): Optional = Optional.ofNullable(ssn.getNullable("ssn")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("dob") @ExcludeMissing fun _dob() = dob + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob - @JsonProperty("emails") @ExcludeMissing fun _emails() = emails + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField = emails - @JsonProperty("encrypted_ssn") @ExcludeMissing fun _encryptedSsn() = encryptedSsn + @JsonProperty("encrypted_ssn") + @ExcludeMissing + fun _encryptedSsn(): JsonField = encryptedSsn - @JsonProperty("ethnicity") @ExcludeMissing fun _ethnicity() = ethnicity + @JsonProperty("ethnicity") + @ExcludeMissing + fun _ethnicity(): JsonField = ethnicity - @JsonProperty("first_name") @ExcludeMissing fun _firstName() = firstName + @JsonProperty("first_name") + @ExcludeMissing + fun _firstName(): JsonField = firstName - @JsonProperty("gender") @ExcludeMissing fun _gender() = gender + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender - @JsonProperty("last_name") @ExcludeMissing fun _lastName() = lastName + @JsonProperty("last_name") + @ExcludeMissing + fun _lastName(): JsonField = lastName - @JsonProperty("middle_name") @ExcludeMissing fun _middleName() = middleName + @JsonProperty("middle_name") + @ExcludeMissing + fun _middleName(): JsonField = middleName - @JsonProperty("phone_numbers") @ExcludeMissing fun _phoneNumbers() = phoneNumbers + @JsonProperty("phone_numbers") + @ExcludeMissing + fun _phoneNumbers(): JsonField = phoneNumbers - @JsonProperty("preferred_name") @ExcludeMissing fun _preferredName() = preferredName + @JsonProperty("preferred_name") + @ExcludeMissing + fun _preferredName(): JsonField = preferredName - @JsonProperty("residence") @ExcludeMissing fun _residence() = residence + @JsonProperty("residence") + @ExcludeMissing + fun _residence(): JsonField = residence - @JsonProperty("ssn") @ExcludeMissing fun _ssn() = ssn + @JsonProperty("ssn") @ExcludeMissing fun _ssn(): JsonField = ssn @JsonAnyGetter @ExcludeMissing @@ -3365,9 +3520,9 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3478,9 +3633,9 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -3613,17 +3768,21 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") + @ExcludeMissing + fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -3798,15 +3957,17 @@ private constructor( fun payFrequencies(): Optional = Optional.ofNullable(payFrequencies.getNullable("pay_frequencies")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("individual_ids") @ExcludeMissing fun _individualIds() = individualIds + @JsonProperty("individual_ids") + @ExcludeMissing + fun _individualIds(): JsonField = individualIds - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("pay_frequencies") @ExcludeMissing - fun _payFrequencies() = payFrequencies + fun _payFrequencies(): JsonField = payFrequencies @JsonAnyGetter @ExcludeMissing @@ -3940,9 +4101,11 @@ private constructor( fun payStatements(): Optional = Optional.ofNullable(payStatements.getNullable("pay_statements")) - @JsonProperty("paging") @ExcludeMissing fun _paging() = paging + @JsonProperty("paging") @ExcludeMissing fun _paging(): JsonField = paging - @JsonProperty("pay_statements") @ExcludeMissing fun _payStatements() = payStatements + @JsonProperty("pay_statements") + @ExcludeMissing + fun _payStatements(): JsonField = payStatements @JsonAnyGetter @ExcludeMissing @@ -4039,9 +4202,11 @@ private constructor( fun offset(): Boolean = offset.getRequired("offset") - @JsonProperty("count") @ExcludeMissing fun _count() = count + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count - @JsonProperty("offset") @ExcludeMissing fun _offset() = offset + @JsonProperty("offset") + @ExcludeMissing + fun _offset(): JsonField = offset @JsonAnyGetter @ExcludeMissing @@ -4066,8 +4231,8 @@ private constructor( class Builder { - private var count: JsonField = JsonMissing.of() - private var offset: JsonField = JsonMissing.of() + private var count: JsonField? = null + private var offset: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4110,8 +4275,8 @@ private constructor( fun build(): Paging = Paging( - count, - offset, + checkNotNull(count) { "`count` is required but was not set" }, + checkNotNull(offset) { "`offset` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4204,33 +4369,42 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("earnings") @ExcludeMissing fun _earnings() = earnings + @JsonProperty("earnings") + @ExcludeMissing + fun _earnings(): JsonField = earnings @JsonProperty("employee_deductions") @ExcludeMissing - fun _employeeDeductions() = employeeDeductions + fun _employeeDeductions(): JsonField = employeeDeductions @JsonProperty("employer_contributions") @ExcludeMissing - fun _employerContributions() = employerContributions + fun _employerContributions(): JsonField = + employerContributions - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay() = grossPay + @JsonProperty("gross_pay") + @ExcludeMissing + fun _grossPay(): JsonField = grossPay @JsonProperty("individual_id") @ExcludeMissing - fun _individualId() = individualId + fun _individualId(): JsonField = individualId - @JsonProperty("net_pay") @ExcludeMissing fun _netPay() = netPay + @JsonProperty("net_pay") + @ExcludeMissing + fun _netPay(): JsonField = netPay @JsonProperty("payment_method") @ExcludeMissing - fun _paymentMethod() = paymentMethod + fun _paymentMethod(): JsonField = paymentMethod - @JsonProperty("taxes") @ExcludeMissing fun _taxes() = taxes + @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField = taxes - @JsonProperty("total_hours") @ExcludeMissing fun _totalHours() = totalHours + @JsonProperty("total_hours") + @ExcludeMissing + fun _totalHours(): JsonField = totalHours - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -4423,13 +4597,17 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -4579,15 +4757,21 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("pre_tax") @ExcludeMissing fun _preTax() = preTax + @JsonProperty("pre_tax") + @ExcludeMissing + fun _preTax(): JsonField = preTax - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -4734,11 +4918,15 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -4882,15 +5070,21 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") + @ExcludeMissing + fun _amount(): JsonField = amount - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency - @JsonProperty("employer") @ExcludeMissing fun _employer() = employer + @JsonProperty("employer") + @ExcludeMissing + fun _employer(): JsonField = employer - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -5125,31 +5319,49 @@ private constructor( fun payPeriod(): Optional = Optional.ofNullable(payPeriod.getNullable("pay_period")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("company_debit") @ExcludeMissing fun _companyDebit() = companyDebit + @JsonProperty("company_debit") + @ExcludeMissing + fun _companyDebit(): JsonField = companyDebit - @JsonProperty("debit_date") @ExcludeMissing fun _debitDate() = debitDate + @JsonProperty("debit_date") + @ExcludeMissing + fun _debitDate(): JsonField = debitDate - @JsonProperty("employee_taxes") @ExcludeMissing fun _employeeTaxes() = employeeTaxes + @JsonProperty("employee_taxes") + @ExcludeMissing + fun _employeeTaxes(): JsonField = employeeTaxes - @JsonProperty("employer_taxes") @ExcludeMissing fun _employerTaxes() = employerTaxes + @JsonProperty("employer_taxes") + @ExcludeMissing + fun _employerTaxes(): JsonField = employerTaxes - @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay() = grossPay + @JsonProperty("gross_pay") + @ExcludeMissing + fun _grossPay(): JsonField = grossPay - @JsonProperty("individual_ids") @ExcludeMissing fun _individualIds() = individualIds + @JsonProperty("individual_ids") + @ExcludeMissing + fun _individualIds(): JsonField = individualIds - @JsonProperty("net_pay") @ExcludeMissing fun _netPay() = netPay + @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay - @JsonProperty("pay_date") @ExcludeMissing fun _payDate() = payDate + @JsonProperty("pay_date") + @ExcludeMissing + fun _payDate(): JsonField = payDate @JsonProperty("pay_frequencies") @ExcludeMissing - fun _payFrequencies() = payFrequencies + fun _payFrequencies(): JsonField = payFrequencies - @JsonProperty("pay_group_ids") @ExcludeMissing fun _payGroupIds() = payGroupIds + @JsonProperty("pay_group_ids") + @ExcludeMissing + fun _payGroupIds(): JsonField = payGroupIds - @JsonProperty("pay_period") @ExcludeMissing fun _payPeriod() = payPeriod + @JsonProperty("pay_period") + @ExcludeMissing + fun _payPeriod(): JsonField = payPeriod @JsonAnyGetter @ExcludeMissing @@ -5345,9 +5557,13 @@ private constructor( fun startDate(): Optional = Optional.ofNullable(startDate.getNullable("start_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardParams.kt index 0bfb87e9..4e0fb356 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -51,20 +53,38 @@ constructor( * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": * "v1" }` */ - fun headers(): Optional = body.headers() + fun _headers(): JsonValue = body._headers() /** * The query parameters for the forwarded request. This value must be specified as a valid JSON * object rather than a query string. */ - fun params(): Optional = body.params() + fun _params(): JsonValue = body._params() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * The HTTP method for the forwarded request. Valid values include: `GET` , `POST` , `PUT` , + * `DELETE` , and `PATCH`. + */ + fun _method(): JsonField = body._method() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * The URL route path for the forwarded request. This value must begin with a forward-slash ( / + * ) and may only contain alphanumeric characters, hyphens, and underscores. + */ + fun _route(): JsonField = body._route() + + /** + * The body for the forwarded request. This value must be specified as either a string or a + * valid JSON object. + */ + fun _data(): JsonField = body._data() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): RequestForwardingForwardBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -76,11 +96,17 @@ constructor( class RequestForwardingForwardBody @JsonCreator internal constructor( - @JsonProperty("method") private val method: String, - @JsonProperty("route") private val route: String, - @JsonProperty("data") private val data: String?, - @JsonProperty("headers") private val headers: JsonValue?, - @JsonProperty("params") private val params: JsonValue?, + @JsonProperty("method") + @ExcludeMissing + private val method: JsonField = JsonMissing.of(), + @JsonProperty("route") + @ExcludeMissing + private val route: JsonField = JsonMissing.of(), + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("headers") @ExcludeMissing private val headers: JsonValue = JsonMissing.of(), + @JsonProperty("params") @ExcludeMissing private val params: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -89,37 +115,66 @@ constructor( * The HTTP method for the forwarded request. Valid values include: `GET` , `POST` , `PUT` , * `DELETE` , and `PATCH`. */ - @JsonProperty("method") fun method(): String = method + fun method(): String = method.getRequired("method") /** * The URL route path for the forwarded request. This value must begin with a forward-slash * ( / ) and may only contain alphanumeric characters, hyphens, and underscores. */ - @JsonProperty("route") fun route(): String = route + fun route(): String = route.getRequired("route") /** * The body for the forwarded request. This value must be specified as either a string or a * valid JSON object. */ - @JsonProperty("data") fun data(): Optional = Optional.ofNullable(data) + fun data(): Optional = Optional.ofNullable(data.getNullable("data")) /** * The HTTP headers to include on the forwarded request. This value must be specified as an * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": * "v1" }` */ - @JsonProperty("headers") fun headers(): Optional = Optional.ofNullable(headers) + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers /** * The query parameters for the forwarded request. This value must be specified as a valid * JSON object rather than a query string. */ - @JsonProperty("params") fun params(): Optional = Optional.ofNullable(params) + @JsonProperty("params") @ExcludeMissing fun _params(): JsonValue = params + + /** + * The HTTP method for the forwarded request. Valid values include: `GET` , `POST` , `PUT` , + * `DELETE` , and `PATCH`. + */ + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method + + /** + * The URL route path for the forwarded request. This value must begin with a forward-slash + * ( / ) and may only contain alphanumeric characters, hyphens, and underscores. + */ + @JsonProperty("route") @ExcludeMissing fun _route(): JsonField = route + + /** + * The body for the forwarded request. This value must be specified as either a string or a + * valid JSON object. + */ + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RequestForwardingForwardBody = apply { + if (!validated) { + method() + route() + data() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -129,11 +184,11 @@ constructor( class Builder { - private var method: String? = null - private var route: String? = null - private var data: String? = null - private var headers: JsonValue? = null - private var params: JsonValue? = null + private var method: JsonField? = null + private var route: JsonField? = null + private var data: JsonField = JsonMissing.of() + private var headers: JsonValue = JsonMissing.of() + private var params: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -151,20 +206,33 @@ constructor( * The HTTP method for the forwarded request. Valid values include: `GET` , `POST` , * `PUT` , `DELETE` , and `PATCH`. */ - fun method(method: String) = apply { this.method = method } + fun method(method: String) = method(JsonField.of(method)) + + /** + * The HTTP method for the forwarded request. Valid values include: `GET` , `POST` , + * `PUT` , `DELETE` , and `PATCH`. + */ + fun method(method: JsonField) = apply { this.method = method } + + /** + * The URL route path for the forwarded request. This value must begin with a + * forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and + * underscores. + */ + fun route(route: String) = route(JsonField.of(route)) /** * The URL route path for the forwarded request. This value must begin with a * forward-slash ( / ) and may only contain alphanumeric characters, hyphens, and * underscores. */ - fun route(route: String) = apply { this.route = route } + fun route(route: JsonField) = apply { this.route = route } /** * The body for the forwarded request. This value must be specified as either a string * or a valid JSON object. */ - fun data(data: String?) = apply { this.data = data } + fun data(data: String?) = data(JsonField.ofNullable(data)) /** * The body for the forwarded request. This value must be specified as either a string @@ -173,30 +241,23 @@ constructor( fun data(data: Optional) = data(data.orElse(null)) /** - * The HTTP headers to include on the forwarded request. This value must be specified as - * an object of key-value pairs. Example: `{"Content-Type": "application/xml", - * "X-API-Version": "v1" }` + * The body for the forwarded request. This value must be specified as either a string + * or a valid JSON object. */ - fun headers(headers: JsonValue?) = apply { this.headers = headers } + fun data(data: JsonField) = apply { this.data = data } /** * The HTTP headers to include on the forwarded request. This value must be specified as * an object of key-value pairs. Example: `{"Content-Type": "application/xml", * "X-API-Version": "v1" }` */ - fun headers(headers: Optional) = headers(headers.orElse(null)) - - /** - * The query parameters for the forwarded request. This value must be specified as a - * valid JSON object rather than a query string. - */ - fun params(params: JsonValue?) = apply { this.params = params } + fun headers(headers: JsonValue) = apply { this.headers = headers } /** * The query parameters for the forwarded request. This value must be specified as a * valid JSON object rather than a query string. */ - fun params(params: Optional) = params(params.orElse(null)) + fun params(params: JsonValue) = apply { this.params = params } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -274,12 +335,24 @@ constructor( */ fun method(method: String) = apply { body.method(method) } + /** + * The HTTP method for the forwarded request. Valid values include: `GET` , `POST` , `PUT` , + * `DELETE` , and `PATCH`. + */ + fun method(method: JsonField) = apply { body.method(method) } + /** * The URL route path for the forwarded request. This value must begin with a forward-slash * ( / ) and may only contain alphanumeric characters, hyphens, and underscores. */ fun route(route: String) = apply { body.route(route) } + /** + * The URL route path for the forwarded request. This value must begin with a forward-slash + * ( / ) and may only contain alphanumeric characters, hyphens, and underscores. + */ + fun route(route: JsonField) = apply { body.route(route) } + /** * The body for the forwarded request. This value must be specified as either a string or a * valid JSON object. @@ -293,30 +366,42 @@ constructor( fun data(data: Optional) = data(data.orElse(null)) /** - * The HTTP headers to include on the forwarded request. This value must be specified as an - * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": - * "v1" }` + * The body for the forwarded request. This value must be specified as either a string or a + * valid JSON object. */ - fun headers(headers: JsonValue?) = apply { body.headers(headers) } + fun data(data: JsonField) = apply { body.data(data) } /** * The HTTP headers to include on the forwarded request. This value must be specified as an * object of key-value pairs. Example: `{"Content-Type": "application/xml", "X-API-Version": * "v1" }` */ - fun headers(headers: Optional) = headers(headers.orElse(null)) + fun headers(headers: JsonValue) = apply { body.headers(headers) } /** * The query parameters for the forwarded request. This value must be specified as a valid * JSON object rather than a query string. */ - fun params(params: JsonValue?) = apply { body.params(params) } + fun params(params: JsonValue) = apply { body.params(params) } - /** - * The query parameters for the forwarded request. This value must be specified as a valid - * JSON object rather than a query string. - */ - fun params(params: Optional) = params(params.orElse(null)) + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -416,25 +501,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): RequestForwardingForwardParams = RequestForwardingForwardParams( body.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponse.kt index cc9cd11e..8fdf3c20 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/RequestForwardingForwardResponse.kt @@ -38,6 +38,12 @@ private constructor( */ fun data(): Optional = Optional.ofNullable(data.getNullable("data")) + /** + * The HTTP headers of the forwarded request’s response, exactly as received from the underlying + * integration’s API. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers + /** * An object containing details of your original forwarded request, for your ease of reference. */ @@ -54,24 +60,18 @@ private constructor( * received from the underlying integration’s API. This field may be null in the case where the * upstream system’s response is empty. */ - @JsonProperty("data") @ExcludeMissing fun _data() = data - - /** - * The HTTP headers of the forwarded request’s response, exactly as received from the underlying - * integration’s API. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers() = headers + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data /** * An object containing details of your original forwarded request, for your ease of reference. */ - @JsonProperty("request") @ExcludeMissing fun _request() = request + @JsonProperty("request") @ExcludeMissing fun _request(): JsonField = request /** * The HTTP status code of the forwarded request’s response, exactly received from the * underlying integration’s API. This value will be returned as an integer. */ - @JsonProperty("statusCode") @ExcludeMissing fun _statusCode() = statusCode + @JsonProperty("statusCode") @ExcludeMissing fun _statusCode(): JsonField = statusCode @JsonAnyGetter @ExcludeMissing @@ -97,10 +97,10 @@ private constructor( class Builder { - private var data: JsonField = JsonMissing.of() - private var headers: JsonValue = JsonMissing.of() - private var request: JsonField = JsonMissing.of() - private var statusCode: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var headers: JsonValue? = null + private var request: JsonField? = null + private var statusCode: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -119,7 +119,14 @@ private constructor( * received from the underlying integration’s API. This field may be null in the case where * the upstream system’s response is empty. */ - fun data(data: String) = data(JsonField.of(data)) + fun data(data: String?) = data(JsonField.ofNullable(data)) + + /** + * A string representation of the HTTP response body of the forwarded request’s response + * received from the underlying integration’s API. This field may be null in the case where + * the upstream system’s response is empty. + */ + fun data(data: Optional) = data(data.orElse(null)) /** * A string representation of the HTTP response body of the forwarded request’s response @@ -179,10 +186,10 @@ private constructor( fun build(): RequestForwardingForwardResponse = RequestForwardingForwardResponse( - data, - headers, - request, - statusCode, + checkNotNull(data) { "`data` is required but was not set" }, + checkNotNull(headers) { "`headers` is required but was not set" }, + checkNotNull(request) { "`request` is required but was not set" }, + checkNotNull(statusCode) { "`statusCode` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -216,12 +223,24 @@ private constructor( */ fun data(): Optional = Optional.ofNullable(data.getNullable("data")) + /** + * The specified HTTP headers that were included in the forwarded request. If no headers + * were specified, this will be returned as `null`. + */ + @JsonProperty("headers") @ExcludeMissing fun _headers(): JsonValue = headers + /** * The HTTP method that was specified for the forwarded request. Valid values include: `GET` * , `POST` , `PUT` , `DELETE` , and `PATCH`. */ fun method(): String = method.getRequired("method") + /** + * The query parameters that were included in the forwarded request. If no query parameters + * were specified, this will be returned as `null`. + */ + @JsonProperty("params") @ExcludeMissing fun _params(): JsonValue = params + /** The URL route path that was specified for the forwarded request. */ fun route(): String = route.getRequired("route") @@ -230,28 +249,16 @@ private constructor( * the original request, this value will be returned as null ; otherwise, this value will * always be returned as a string. */ - @JsonProperty("data") @ExcludeMissing fun _data() = data - - /** - * The specified HTTP headers that were included in the forwarded request. If no headers - * were specified, this will be returned as `null`. - */ - @JsonProperty("headers") @ExcludeMissing fun _headers() = headers + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data /** * The HTTP method that was specified for the forwarded request. Valid values include: `GET` * , `POST` , `PUT` , `DELETE` , and `PATCH`. */ - @JsonProperty("method") @ExcludeMissing fun _method() = method - - /** - * The query parameters that were included in the forwarded request. If no query parameters - * were specified, this will be returned as `null`. - */ - @JsonProperty("params") @ExcludeMissing fun _params() = params + @JsonProperty("method") @ExcludeMissing fun _method(): JsonField = method /** The URL route path that was specified for the forwarded request. */ - @JsonProperty("route") @ExcludeMissing fun _route() = route + @JsonProperty("route") @ExcludeMissing fun _route(): JsonField = route @JsonAnyGetter @ExcludeMissing @@ -277,11 +284,11 @@ private constructor( class Builder { - private var data: JsonField = JsonMissing.of() - private var headers: JsonValue = JsonMissing.of() - private var method: JsonField = JsonMissing.of() - private var params: JsonValue = JsonMissing.of() - private var route: JsonField = JsonMissing.of() + private var data: JsonField? = null + private var headers: JsonValue? = null + private var method: JsonField? = null + private var params: JsonValue? = null + private var route: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -299,7 +306,14 @@ private constructor( * in the original request, this value will be returned as null ; otherwise, this value * will always be returned as a string. */ - fun data(data: String) = data(JsonField.of(data)) + fun data(data: String?) = data(JsonField.ofNullable(data)) + + /** + * The body that was specified for the forwarded request. If a value was not specified + * in the original request, this value will be returned as null ; otherwise, this value + * will always be returned as a string. + */ + fun data(data: Optional) = data(data.orElse(null)) /** * The body that was specified for the forwarded request. If a value was not specified @@ -359,11 +373,11 @@ private constructor( fun build(): Request = Request( - data, - headers, - method, - params, - route, + checkNotNull(data) { "`data` is required but was not set" }, + checkNotNull(headers) { "`headers` is required but was not set" }, + checkNotNull(method) { "`method` is required but was not set" }, + checkNotNull(params) { "`params` is required but was not set" }, + checkNotNull(route) { "`route` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParams.kt index 4843a099..e1fa5d5c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -50,12 +51,35 @@ constructor( /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ fun primaryPhoneNumber(): Optional = body.primaryPhoneNumber() - fun _additionalHeaders(): Headers = additionalHeaders + /** An array of bank account objects associated with the payroll/HRIS system. */ + fun _accounts(): JsonField> = body._accounts() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The array of company departments. */ + fun _departments(): JsonField> = body._departments() + + /** The employer identification number. */ + fun _ein(): JsonField = body._ein() + + /** The entity type object. */ + fun _entity(): JsonField = body._entity() + + /** The legal name of the company. */ + fun _legalName(): JsonField = body._legalName() + + fun _locations(): JsonField> = body._locations() + + /** The email of the main administrator on the account. */ + fun _primaryEmail(): JsonField = body._primaryEmail() + + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ + fun _primaryPhoneNumber(): JsonField = body._primaryPhoneNumber() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SandboxCompanyUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -66,51 +90,113 @@ constructor( class SandboxCompanyUpdateBody @JsonCreator internal constructor( - @JsonProperty("accounts") private val accounts: List?, - @JsonProperty("departments") private val departments: List?, - @JsonProperty("ein") private val ein: String?, - @JsonProperty("entity") private val entity: Entity?, - @JsonProperty("legal_name") private val legalName: String?, - @JsonProperty("locations") private val locations: List?, - @JsonProperty("primary_email") private val primaryEmail: String?, - @JsonProperty("primary_phone_number") private val primaryPhoneNumber: String?, + @JsonProperty("accounts") + @ExcludeMissing + private val accounts: JsonField> = JsonMissing.of(), + @JsonProperty("departments") + @ExcludeMissing + private val departments: JsonField> = JsonMissing.of(), + @JsonProperty("ein") @ExcludeMissing private val ein: JsonField = JsonMissing.of(), + @JsonProperty("entity") + @ExcludeMissing + private val entity: JsonField = JsonMissing.of(), + @JsonProperty("legal_name") + @ExcludeMissing + private val legalName: JsonField = JsonMissing.of(), + @JsonProperty("locations") + @ExcludeMissing + private val locations: JsonField> = JsonMissing.of(), + @JsonProperty("primary_email") + @ExcludeMissing + private val primaryEmail: JsonField = JsonMissing.of(), + @JsonProperty("primary_phone_number") + @ExcludeMissing + private val primaryPhoneNumber: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** An array of bank account objects associated with the payroll/HRIS system. */ + fun accounts(): Optional> = + Optional.ofNullable(accounts.getNullable("accounts")) + + /** The array of company departments. */ + fun departments(): Optional> = + Optional.ofNullable(departments.getNullable("departments")) + + /** The employer identification number. */ + fun ein(): Optional = Optional.ofNullable(ein.getNullable("ein")) + + /** The entity type object. */ + fun entity(): Optional = Optional.ofNullable(entity.getNullable("entity")) + + /** The legal name of the company. */ + fun legalName(): Optional = Optional.ofNullable(legalName.getNullable("legal_name")) + + fun locations(): Optional> = + Optional.ofNullable(locations.getNullable("locations")) + + /** The email of the main administrator on the account. */ + fun primaryEmail(): Optional = + Optional.ofNullable(primaryEmail.getNullable("primary_email")) + + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ + fun primaryPhoneNumber(): Optional = + Optional.ofNullable(primaryPhoneNumber.getNullable("primary_phone_number")) + /** An array of bank account objects associated with the payroll/HRIS system. */ @JsonProperty("accounts") - fun accounts(): Optional> = Optional.ofNullable(accounts) + @ExcludeMissing + fun _accounts(): JsonField> = accounts /** The array of company departments. */ @JsonProperty("departments") - fun departments(): Optional> = Optional.ofNullable(departments) + @ExcludeMissing + fun _departments(): JsonField> = departments /** The employer identification number. */ - @JsonProperty("ein") fun ein(): Optional = Optional.ofNullable(ein) + @JsonProperty("ein") @ExcludeMissing fun _ein(): JsonField = ein /** The entity type object. */ - @JsonProperty("entity") fun entity(): Optional = Optional.ofNullable(entity) + @JsonProperty("entity") @ExcludeMissing fun _entity(): JsonField = entity /** The legal name of the company. */ - @JsonProperty("legal_name") - fun legalName(): Optional = Optional.ofNullable(legalName) + @JsonProperty("legal_name") @ExcludeMissing fun _legalName(): JsonField = legalName @JsonProperty("locations") - fun locations(): Optional> = Optional.ofNullable(locations) + @ExcludeMissing + fun _locations(): JsonField> = locations /** The email of the main administrator on the account. */ @JsonProperty("primary_email") - fun primaryEmail(): Optional = Optional.ofNullable(primaryEmail) + @ExcludeMissing + fun _primaryEmail(): JsonField = primaryEmail /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ @JsonProperty("primary_phone_number") - fun primaryPhoneNumber(): Optional = Optional.ofNullable(primaryPhoneNumber) + @ExcludeMissing + fun _primaryPhoneNumber(): JsonField = primaryPhoneNumber @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxCompanyUpdateBody = apply { + if (!validated) { + accounts().map { it.forEach { it.validate() } } + departments().map { it.forEach { it?.validate() } } + ein() + entity().map { it.validate() } + legalName() + locations().map { it.forEach { it?.validate() } } + primaryEmail() + primaryPhoneNumber() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -120,100 +206,155 @@ constructor( class Builder { - private var accounts: MutableList? = null - private var departments: MutableList? = null - private var ein: String? = null - private var entity: Entity? = null - private var legalName: String? = null - private var locations: MutableList? = null - private var primaryEmail: String? = null - private var primaryPhoneNumber: String? = null + private var accounts: JsonField>? = null + private var departments: JsonField>? = null + private var ein: JsonField? = null + private var entity: JsonField? = null + private var legalName: JsonField? = null + private var locations: JsonField>? = null + private var primaryEmail: JsonField? = null + private var primaryPhoneNumber: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(sandboxCompanyUpdateBody: SandboxCompanyUpdateBody) = apply { - accounts = sandboxCompanyUpdateBody.accounts?.toMutableList() - departments = sandboxCompanyUpdateBody.departments?.toMutableList() + accounts = sandboxCompanyUpdateBody.accounts.map { it.toMutableList() } + departments = sandboxCompanyUpdateBody.departments.map { it.toMutableList() } ein = sandboxCompanyUpdateBody.ein entity = sandboxCompanyUpdateBody.entity legalName = sandboxCompanyUpdateBody.legalName - locations = sandboxCompanyUpdateBody.locations?.toMutableList() + locations = sandboxCompanyUpdateBody.locations.map { it.toMutableList() } primaryEmail = sandboxCompanyUpdateBody.primaryEmail primaryPhoneNumber = sandboxCompanyUpdateBody.primaryPhoneNumber additionalProperties = sandboxCompanyUpdateBody.additionalProperties.toMutableMap() } /** An array of bank account objects associated with the payroll/HRIS system. */ - fun accounts(accounts: List?) = apply { - this.accounts = accounts?.toMutableList() - } + fun accounts(accounts: List?) = accounts(JsonField.ofNullable(accounts)) /** An array of bank account objects associated with the payroll/HRIS system. */ fun accounts(accounts: Optional>) = accounts(accounts.orElse(null)) + /** An array of bank account objects associated with the payroll/HRIS system. */ + fun accounts(accounts: JsonField>) = apply { + this.accounts = accounts.map { it.toMutableList() } + } + /** An array of bank account objects associated with the payroll/HRIS system. */ fun addAccount(account: Account) = apply { - accounts = (accounts ?: mutableListOf()).apply { add(account) } + accounts = + (accounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(account) + } } /** The array of company departments. */ - fun departments(departments: List?) = apply { - this.departments = departments?.toMutableList() - } + fun departments(departments: List?) = + departments(JsonField.ofNullable(departments)) /** The array of company departments. */ fun departments(departments: Optional>) = departments(departments.orElse(null)) + /** The array of company departments. */ + fun departments(departments: JsonField>) = apply { + this.departments = departments.map { it.toMutableList() } + } + /** The array of company departments. */ fun addDepartment(department: Department) = apply { - departments = (departments ?: mutableListOf()).apply { add(department) } + departments = + (departments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(department) + } } /** The employer identification number. */ - fun ein(ein: String?) = apply { this.ein = ein } + fun ein(ein: String?) = ein(JsonField.ofNullable(ein)) /** The employer identification number. */ fun ein(ein: Optional) = ein(ein.orElse(null)) + /** The employer identification number. */ + fun ein(ein: JsonField) = apply { this.ein = ein } + /** The entity type object. */ - fun entity(entity: Entity?) = apply { this.entity = entity } + fun entity(entity: Entity?) = entity(JsonField.ofNullable(entity)) /** The entity type object. */ fun entity(entity: Optional) = entity(entity.orElse(null)) + /** The entity type object. */ + fun entity(entity: JsonField) = apply { this.entity = entity } + /** The legal name of the company. */ - fun legalName(legalName: String?) = apply { this.legalName = legalName } + fun legalName(legalName: String?) = legalName(JsonField.ofNullable(legalName)) /** The legal name of the company. */ fun legalName(legalName: Optional) = legalName(legalName.orElse(null)) - fun locations(locations: List?) = apply { - this.locations = locations?.toMutableList() - } + /** The legal name of the company. */ + fun legalName(legalName: JsonField) = apply { this.legalName = legalName } + + fun locations(locations: List?) = locations(JsonField.ofNullable(locations)) fun locations(locations: Optional>) = locations(locations.orElse(null)) + fun locations(locations: JsonField>) = apply { + this.locations = locations.map { it.toMutableList() } + } + fun addLocation(location: Location) = apply { - locations = (locations ?: mutableListOf()).apply { add(location) } + locations = + (locations ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(location) + } } /** The email of the main administrator on the account. */ - fun primaryEmail(primaryEmail: String?) = apply { this.primaryEmail = primaryEmail } + fun primaryEmail(primaryEmail: String?) = + primaryEmail(JsonField.ofNullable(primaryEmail)) /** The email of the main administrator on the account. */ fun primaryEmail(primaryEmail: Optional) = primaryEmail(primaryEmail.orElse(null)) - /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ - fun primaryPhoneNumber(primaryPhoneNumber: String?) = apply { - this.primaryPhoneNumber = primaryPhoneNumber + /** The email of the main administrator on the account. */ + fun primaryEmail(primaryEmail: JsonField) = apply { + this.primaryEmail = primaryEmail } + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ + fun primaryPhoneNumber(primaryPhoneNumber: String?) = + primaryPhoneNumber(JsonField.ofNullable(primaryPhoneNumber)) + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ fun primaryPhoneNumber(primaryPhoneNumber: Optional) = primaryPhoneNumber(primaryPhoneNumber.orElse(null)) + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ + fun primaryPhoneNumber(primaryPhoneNumber: JsonField) = apply { + this.primaryPhoneNumber = primaryPhoneNumber + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -235,14 +376,19 @@ constructor( fun build(): SandboxCompanyUpdateBody = SandboxCompanyUpdateBody( - accounts?.toImmutable(), - departments?.toImmutable(), - ein, - entity, - legalName, - locations?.toImmutable(), - primaryEmail, - primaryPhoneNumber, + checkNotNull(accounts) { "`accounts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(departments) { "`departments` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(ein) { "`ein` is required but was not set" }, + checkNotNull(entity) { "`entity` is required but was not set" }, + checkNotNull(legalName) { "`legalName` is required but was not set" }, + checkNotNull(locations) { "`locations` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(primaryEmail) { "`primaryEmail` is required but was not set" }, + checkNotNull(primaryPhoneNumber) { + "`primaryPhoneNumber` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -292,6 +438,9 @@ constructor( /** An array of bank account objects associated with the payroll/HRIS system. */ fun accounts(accounts: Optional>) = accounts(accounts.orElse(null)) + /** An array of bank account objects associated with the payroll/HRIS system. */ + fun accounts(accounts: JsonField>) = apply { body.accounts(accounts) } + /** An array of bank account objects associated with the payroll/HRIS system. */ fun addAccount(account: Account) = apply { body.addAccount(account) } @@ -302,6 +451,11 @@ constructor( fun departments(departments: Optional>) = departments(departments.orElse(null)) + /** The array of company departments. */ + fun departments(departments: JsonField>) = apply { + body.departments(departments) + } + /** The array of company departments. */ fun addDepartment(department: Department) = apply { body.addDepartment(department) } @@ -311,22 +465,33 @@ constructor( /** The employer identification number. */ fun ein(ein: Optional) = ein(ein.orElse(null)) + /** The employer identification number. */ + fun ein(ein: JsonField) = apply { body.ein(ein) } + /** The entity type object. */ fun entity(entity: Entity?) = apply { body.entity(entity) } /** The entity type object. */ fun entity(entity: Optional) = entity(entity.orElse(null)) + /** The entity type object. */ + fun entity(entity: JsonField) = apply { body.entity(entity) } + /** The legal name of the company. */ fun legalName(legalName: String?) = apply { body.legalName(legalName) } /** The legal name of the company. */ fun legalName(legalName: Optional) = legalName(legalName.orElse(null)) + /** The legal name of the company. */ + fun legalName(legalName: JsonField) = apply { body.legalName(legalName) } + fun locations(locations: List?) = apply { body.locations(locations) } fun locations(locations: Optional>) = locations(locations.orElse(null)) + fun locations(locations: JsonField>) = apply { body.locations(locations) } + fun addLocation(location: Location) = apply { body.addLocation(location) } /** The email of the main administrator on the account. */ @@ -335,6 +500,11 @@ constructor( /** The email of the main administrator on the account. */ fun primaryEmail(primaryEmail: Optional) = primaryEmail(primaryEmail.orElse(null)) + /** The email of the main administrator on the account. */ + fun primaryEmail(primaryEmail: JsonField) = apply { + body.primaryEmail(primaryEmail) + } + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ fun primaryPhoneNumber(primaryPhoneNumber: String?) = apply { body.primaryPhoneNumber(primaryPhoneNumber) @@ -344,6 +514,30 @@ constructor( fun primaryPhoneNumber(primaryPhoneNumber: Optional) = primaryPhoneNumber(primaryPhoneNumber.orElse(null)) + /** The phone number of the main administrator on the account. Format: `XXXXXXXXXX` */ + fun primaryPhoneNumber(primaryPhoneNumber: JsonField) = apply { + body.primaryPhoneNumber(primaryPhoneNumber) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -442,25 +636,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxCompanyUpdateParams = SandboxCompanyUpdateParams( body.build(), @@ -473,41 +648,91 @@ constructor( class Account @JsonCreator private constructor( - @JsonProperty("account_name") private val accountName: String?, - @JsonProperty("account_number") private val accountNumber: String?, - @JsonProperty("account_type") private val accountType: AccountType?, - @JsonProperty("institution_name") private val institutionName: String?, - @JsonProperty("routing_number") private val routingNumber: String?, + @JsonProperty("account_name") + @ExcludeMissing + private val accountName: JsonField = JsonMissing.of(), + @JsonProperty("account_number") + @ExcludeMissing + private val accountNumber: JsonField = JsonMissing.of(), + @JsonProperty("account_type") + @ExcludeMissing + private val accountType: JsonField = JsonMissing.of(), + @JsonProperty("institution_name") + @ExcludeMissing + private val institutionName: JsonField = JsonMissing.of(), + @JsonProperty("routing_number") + @ExcludeMissing + private val routingNumber: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The name of the bank associated in the payroll/HRIS system. */ + fun accountName(): Optional = + Optional.ofNullable(accountName.getNullable("account_name")) + + /** 10-12 digit number to specify the bank account */ + fun accountNumber(): Optional = + Optional.ofNullable(accountNumber.getNullable("account_number")) + + /** The type of bank account. */ + fun accountType(): Optional = + Optional.ofNullable(accountType.getNullable("account_type")) + + /** Name of the banking institution. */ + fun institutionName(): Optional = + Optional.ofNullable(institutionName.getNullable("institution_name")) + + /** + * A nine-digit code that's based on the U.S. Bank location where your account was opened. + */ + fun routingNumber(): Optional = + Optional.ofNullable(routingNumber.getNullable("routing_number")) + /** The name of the bank associated in the payroll/HRIS system. */ @JsonProperty("account_name") - fun accountName(): Optional = Optional.ofNullable(accountName) + @ExcludeMissing + fun _accountName(): JsonField = accountName /** 10-12 digit number to specify the bank account */ @JsonProperty("account_number") - fun accountNumber(): Optional = Optional.ofNullable(accountNumber) + @ExcludeMissing + fun _accountNumber(): JsonField = accountNumber /** The type of bank account. */ @JsonProperty("account_type") - fun accountType(): Optional = Optional.ofNullable(accountType) + @ExcludeMissing + fun _accountType(): JsonField = accountType /** Name of the banking institution. */ @JsonProperty("institution_name") - fun institutionName(): Optional = Optional.ofNullable(institutionName) + @ExcludeMissing + fun _institutionName(): JsonField = institutionName /** * A nine-digit code that's based on the U.S. Bank location where your account was opened. */ @JsonProperty("routing_number") - fun routingNumber(): Optional = Optional.ofNullable(routingNumber) + @ExcludeMissing + fun _routingNumber(): JsonField = routingNumber @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Account = apply { + if (!validated) { + accountName() + accountNumber() + accountType() + institutionName() + routingNumber() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -517,11 +742,11 @@ constructor( class Builder { - private var accountName: String? = null - private var accountNumber: String? = null - private var accountType: AccountType? = null - private var institutionName: String? = null - private var routingNumber: String? = null + private var accountName: JsonField = JsonMissing.of() + private var accountNumber: JsonField = JsonMissing.of() + private var accountType: JsonField = JsonMissing.of() + private var institutionName: JsonField = JsonMissing.of() + private var routingNumber: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -535,39 +760,61 @@ constructor( } /** The name of the bank associated in the payroll/HRIS system. */ - fun accountName(accountName: String?) = apply { this.accountName = accountName } + fun accountName(accountName: String?) = accountName(JsonField.ofNullable(accountName)) /** The name of the bank associated in the payroll/HRIS system. */ fun accountName(accountName: Optional) = accountName(accountName.orElse(null)) + /** The name of the bank associated in the payroll/HRIS system. */ + fun accountName(accountName: JsonField) = apply { + this.accountName = accountName + } + /** 10-12 digit number to specify the bank account */ - fun accountNumber(accountNumber: String?) = apply { this.accountNumber = accountNumber } + fun accountNumber(accountNumber: String?) = + accountNumber(JsonField.ofNullable(accountNumber)) /** 10-12 digit number to specify the bank account */ fun accountNumber(accountNumber: Optional) = accountNumber(accountNumber.orElse(null)) + /** 10-12 digit number to specify the bank account */ + fun accountNumber(accountNumber: JsonField) = apply { + this.accountNumber = accountNumber + } + /** The type of bank account. */ - fun accountType(accountType: AccountType?) = apply { this.accountType = accountType } + fun accountType(accountType: AccountType?) = + accountType(JsonField.ofNullable(accountType)) /** The type of bank account. */ fun accountType(accountType: Optional) = accountType(accountType.orElse(null)) - /** Name of the banking institution. */ - fun institutionName(institutionName: String?) = apply { - this.institutionName = institutionName + /** The type of bank account. */ + fun accountType(accountType: JsonField) = apply { + this.accountType = accountType } + /** Name of the banking institution. */ + fun institutionName(institutionName: String?) = + institutionName(JsonField.ofNullable(institutionName)) + /** Name of the banking institution. */ fun institutionName(institutionName: Optional) = institutionName(institutionName.orElse(null)) + /** Name of the banking institution. */ + fun institutionName(institutionName: JsonField) = apply { + this.institutionName = institutionName + } + /** * A nine-digit code that's based on the U.S. Bank location where your account was * opened. */ - fun routingNumber(routingNumber: String?) = apply { this.routingNumber = routingNumber } + fun routingNumber(routingNumber: String?) = + routingNumber(JsonField.ofNullable(routingNumber)) /** * A nine-digit code that's based on the U.S. Bank location where your account was @@ -576,6 +823,14 @@ constructor( fun routingNumber(routingNumber: Optional) = routingNumber(routingNumber.orElse(null)) + /** + * A nine-digit code that's based on the U.S. Bank location where your account was + * opened. + */ + fun routingNumber(routingNumber: JsonField) = apply { + this.routingNumber = routingNumber + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -685,22 +940,42 @@ constructor( class Department @JsonCreator private constructor( - @JsonProperty("name") private val name: String?, - @JsonProperty("parent") private val parent: Parent?, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("parent") + @ExcludeMissing + private val parent: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The department name. */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The parent department, if present. */ - @JsonProperty("parent") fun parent(): Optional = Optional.ofNullable(parent) + fun parent(): Optional = Optional.ofNullable(parent.getNullable("parent")) + + /** The department name. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The parent department, if present. */ + @JsonProperty("parent") @ExcludeMissing fun _parent(): JsonField = parent @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Department = apply { + if (!validated) { + name() + parent().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -710,8 +985,8 @@ constructor( class Builder { - private var name: String? = null - private var parent: Parent? = null + private var name: JsonField = JsonMissing.of() + private var parent: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -722,17 +997,23 @@ constructor( } /** The department name. */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The department name. */ fun name(name: Optional) = name(name.orElse(null)) + /** The department name. */ + fun name(name: JsonField) = apply { this.name = name } + /** The parent department, if present. */ - fun parent(parent: Parent?) = apply { this.parent = parent } + fun parent(parent: Parent?) = parent(JsonField.ofNullable(parent)) /** The parent department, if present. */ fun parent(parent: Optional) = parent(parent.orElse(null)) + /** The parent department, if present. */ + fun parent(parent: JsonField) = apply { this.parent = parent } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -765,18 +1046,32 @@ constructor( class Parent @JsonCreator private constructor( - @JsonProperty("name") private val name: String?, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The parent department's name. */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** The parent department's name. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Parent = apply { + if (!validated) { + name() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -786,7 +1081,7 @@ constructor( class Builder { - private var name: String? = null + private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -796,11 +1091,14 @@ constructor( } /** The parent department's name. */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The parent department's name. */ fun name(name: Optional) = name(name.orElse(null)) + /** The parent department's name. */ + fun name(name: JsonField) = apply { this.name = name } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -867,22 +1165,40 @@ constructor( class Entity @JsonCreator private constructor( - @JsonProperty("subtype") private val subtype: Subtype?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("subtype") + @ExcludeMissing + private val subtype: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The tax payer subtype of the company. */ - @JsonProperty("subtype") fun subtype(): Optional = Optional.ofNullable(subtype) + fun subtype(): Optional = Optional.ofNullable(subtype.getNullable("subtype")) /** The tax payer type of the company. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** The tax payer subtype of the company. */ + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype + + /** The tax payer type of the company. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Entity = apply { + if (!validated) { + subtype() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -892,8 +1208,8 @@ constructor( class Builder { - private var subtype: Subtype? = null - private var type: Type? = null + private var subtype: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -904,17 +1220,23 @@ constructor( } /** The tax payer subtype of the company. */ - fun subtype(subtype: Subtype?) = apply { this.subtype = subtype } + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) /** The tax payer subtype of the company. */ fun subtype(subtype: Optional) = subtype(subtype.orElse(null)) + /** The tax payer subtype of the company. */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + /** The tax payer type of the company. */ - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) /** The tax payer type of the company. */ fun type(type: Optional) = type(type.orElse(null)) + /** The tax payer type of the company. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParams.kt index 44a56f93..62b1169c 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountCreateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -40,12 +41,25 @@ constructor( */ fun products(): Optional> = body.products() - fun _additionalHeaders(): Headers = additionalHeaders + fun _companyId(): JsonField = body._companyId() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The provider associated with the `access_token` */ + fun _providerId(): JsonField = body._providerId() + + fun _authenticationType(): JsonField = body._authenticationType() + + /** + * Optional, defaults to Organization products (`company`, `directory`, `employment`, + * `individual`) + */ + fun _products(): JsonField> = body._products() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SandboxConnectionAccountCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -56,34 +70,72 @@ constructor( class SandboxConnectionAccountCreateBody @JsonCreator internal constructor( - @JsonProperty("company_id") private val companyId: String, - @JsonProperty("provider_id") private val providerId: String, - @JsonProperty("authentication_type") private val authenticationType: AuthenticationType?, - @JsonProperty("products") private val products: List?, + @JsonProperty("company_id") + @ExcludeMissing + private val companyId: JsonField = JsonMissing.of(), + @JsonProperty("provider_id") + @ExcludeMissing + private val providerId: JsonField = JsonMissing.of(), + @JsonProperty("authentication_type") + @ExcludeMissing + private val authenticationType: JsonField = JsonMissing.of(), + @JsonProperty("products") + @ExcludeMissing + private val products: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("company_id") fun companyId(): String = companyId + fun companyId(): String = companyId.getRequired("company_id") /** The provider associated with the `access_token` */ - @JsonProperty("provider_id") fun providerId(): String = providerId + fun providerId(): String = providerId.getRequired("provider_id") - @JsonProperty("authentication_type") fun authenticationType(): Optional = - Optional.ofNullable(authenticationType) + Optional.ofNullable(authenticationType.getNullable("authentication_type")) + + /** + * Optional, defaults to Organization products (`company`, `directory`, `employment`, + * `individual`) + */ + fun products(): Optional> = + Optional.ofNullable(products.getNullable("products")) + + @JsonProperty("company_id") @ExcludeMissing fun _companyId(): JsonField = companyId + + /** The provider associated with the `access_token` */ + @JsonProperty("provider_id") + @ExcludeMissing + fun _providerId(): JsonField = providerId + + @JsonProperty("authentication_type") + @ExcludeMissing + fun _authenticationType(): JsonField = authenticationType /** * Optional, defaults to Organization products (`company`, `directory`, `employment`, * `individual`) */ @JsonProperty("products") - fun products(): Optional> = Optional.ofNullable(products) + @ExcludeMissing + fun _products(): JsonField> = products @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxConnectionAccountCreateBody = apply { + if (!validated) { + companyId() + providerId() + authenticationType() + products() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -93,10 +145,10 @@ constructor( class Builder { - private var companyId: String? = null - private var providerId: String? = null - private var authenticationType: AuthenticationType? = null - private var products: MutableList? = null + private var companyId: JsonField? = null + private var providerId: JsonField? = null + private var authenticationType: JsonField = JsonMissing.of() + private var products: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -106,43 +158,57 @@ constructor( companyId = sandboxConnectionAccountCreateBody.companyId providerId = sandboxConnectionAccountCreateBody.providerId authenticationType = sandboxConnectionAccountCreateBody.authenticationType - products = sandboxConnectionAccountCreateBody.products?.toMutableList() + products = sandboxConnectionAccountCreateBody.products.map { it.toMutableList() } additionalProperties = sandboxConnectionAccountCreateBody.additionalProperties.toMutableMap() } - fun companyId(companyId: String) = apply { this.companyId = companyId } + fun companyId(companyId: String) = companyId(JsonField.of(companyId)) + + fun companyId(companyId: JsonField) = apply { this.companyId = companyId } /** The provider associated with the `access_token` */ - fun providerId(providerId: String) = apply { this.providerId = providerId } + fun providerId(providerId: String) = providerId(JsonField.of(providerId)) - fun authenticationType(authenticationType: AuthenticationType?) = apply { + /** The provider associated with the `access_token` */ + fun providerId(providerId: JsonField) = apply { this.providerId = providerId } + + fun authenticationType(authenticationType: AuthenticationType) = + authenticationType(JsonField.of(authenticationType)) + + fun authenticationType(authenticationType: JsonField) = apply { this.authenticationType = authenticationType } - fun authenticationType(authenticationType: Optional) = - authenticationType(authenticationType.orElse(null)) - /** * Optional, defaults to Organization products (`company`, `directory`, `employment`, * `individual`) */ - fun products(products: List?) = apply { - this.products = products?.toMutableList() - } + fun products(products: List) = products(JsonField.of(products)) /** * Optional, defaults to Organization products (`company`, `directory`, `employment`, * `individual`) */ - fun products(products: Optional>) = products(products.orElse(null)) + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } + } /** * Optional, defaults to Organization products (`company`, `directory`, `employment`, * `individual`) */ fun addProduct(product: String) = apply { - products = (products ?: mutableListOf()).apply { add(product) } + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -169,7 +235,7 @@ constructor( checkNotNull(companyId) { "`companyId` is required but was not set" }, checkNotNull(providerId) { "`providerId` is required but was not set" }, authenticationType, - products?.toImmutable(), + (products ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -219,27 +285,33 @@ constructor( fun companyId(companyId: String) = apply { body.companyId(companyId) } + fun companyId(companyId: JsonField) = apply { body.companyId(companyId) } + /** The provider associated with the `access_token` */ fun providerId(providerId: String) = apply { body.providerId(providerId) } - fun authenticationType(authenticationType: AuthenticationType?) = apply { + /** The provider associated with the `access_token` */ + fun providerId(providerId: JsonField) = apply { body.providerId(providerId) } + + fun authenticationType(authenticationType: AuthenticationType) = apply { body.authenticationType(authenticationType) } - fun authenticationType(authenticationType: Optional) = - authenticationType(authenticationType.orElse(null)) + fun authenticationType(authenticationType: JsonField) = apply { + body.authenticationType(authenticationType) + } /** * Optional, defaults to Organization products (`company`, `directory`, `employment`, * `individual`) */ - fun products(products: List?) = apply { body.products(products) } + fun products(products: List) = apply { body.products(products) } /** * Optional, defaults to Organization products (`company`, `directory`, `employment`, * `individual`) */ - fun products(products: Optional>) = products(products.orElse(null)) + fun products(products: JsonField>) = apply { body.products(products) } /** * Optional, defaults to Organization products (`company`, `directory`, `employment`, @@ -247,6 +319,25 @@ constructor( */ fun addProduct(product: String) = apply { body.addProduct(product) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -345,25 +436,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxConnectionAccountCreateParams = SandboxConnectionAccountCreateParams( body.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParams.kt index c942a512..1e675c2b 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionAccountUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.tryfinch.api.core.ExcludeMissing +import com.tryfinch.api.core.JsonField +import com.tryfinch.api.core.JsonMissing import com.tryfinch.api.core.JsonValue import com.tryfinch.api.core.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -29,12 +31,14 @@ constructor( fun connectionStatus(): Optional = body.connectionStatus() + fun _connectionStatus(): JsonField = body._connectionStatus() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): SandboxConnectionAccountUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -45,19 +49,33 @@ constructor( class SandboxConnectionAccountUpdateBody @JsonCreator internal constructor( - @JsonProperty("connection_status") private val connectionStatus: ConnectionStatusType?, + @JsonProperty("connection_status") + @ExcludeMissing + private val connectionStatus: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("connection_status") fun connectionStatus(): Optional = - Optional.ofNullable(connectionStatus) + Optional.ofNullable(connectionStatus.getNullable("connection_status")) + + @JsonProperty("connection_status") + @ExcludeMissing + fun _connectionStatus(): JsonField = connectionStatus @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxConnectionAccountUpdateBody = apply { + if (!validated) { + connectionStatus() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -67,7 +85,7 @@ constructor( class Builder { - private var connectionStatus: ConnectionStatusType? = null + private var connectionStatus: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -79,13 +97,13 @@ constructor( sandboxConnectionAccountUpdateBody.additionalProperties.toMutableMap() } - fun connectionStatus(connectionStatus: ConnectionStatusType?) = apply { + fun connectionStatus(connectionStatus: ConnectionStatusType) = + connectionStatus(JsonField.of(connectionStatus)) + + fun connectionStatus(connectionStatus: JsonField) = apply { this.connectionStatus = connectionStatus } - fun connectionStatus(connectionStatus: Optional) = - connectionStatus(connectionStatus.orElse(null)) - fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -155,12 +173,32 @@ constructor( sandboxConnectionAccountUpdateParams.additionalQueryParams.toBuilder() } - fun connectionStatus(connectionStatus: ConnectionStatusType?) = apply { + fun connectionStatus(connectionStatus: ConnectionStatusType) = apply { body.connectionStatus(connectionStatus) } - fun connectionStatus(connectionStatus: Optional) = - connectionStatus(connectionStatus.orElse(null)) + fun connectionStatus(connectionStatus: JsonField) = apply { + body.connectionStatus(connectionStatus) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -260,25 +298,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxConnectionAccountUpdateParams = SandboxConnectionAccountUpdateParams( body.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParams.kt index ce413a94..0530185d 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxConnectionCreateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -41,12 +42,26 @@ constructor( fun products(): Optional> = body.products() - fun _additionalHeaders(): Headers = additionalHeaders + /** The provider associated with the connection */ + fun _providerId(): JsonField = body._providerId() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _authenticationType(): JsonField = body._authenticationType() + + /** + * Optional: the size of the employer to be created with this connection. Defaults to 20. Note + * that if this is higher than 100, historical payroll data will not be generated, and instead + * only one pay period will be created. + */ + fun _employeeSize(): JsonField = body._employeeSize() + + fun _products(): JsonField> = body._products() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SandboxConnectionCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -57,20 +72,47 @@ constructor( class SandboxConnectionCreateBody @JsonCreator internal constructor( - @JsonProperty("provider_id") private val providerId: String, - @JsonProperty("authentication_type") private val authenticationType: AuthenticationType?, - @JsonProperty("employee_size") private val employeeSize: Long?, - @JsonProperty("products") private val products: List?, + @JsonProperty("provider_id") + @ExcludeMissing + private val providerId: JsonField = JsonMissing.of(), + @JsonProperty("authentication_type") + @ExcludeMissing + private val authenticationType: JsonField = JsonMissing.of(), + @JsonProperty("employee_size") + @ExcludeMissing + private val employeeSize: JsonField = JsonMissing.of(), + @JsonProperty("products") + @ExcludeMissing + private val products: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The provider associated with the connection */ - @JsonProperty("provider_id") fun providerId(): String = providerId + fun providerId(): String = providerId.getRequired("provider_id") - @JsonProperty("authentication_type") fun authenticationType(): Optional = - Optional.ofNullable(authenticationType) + Optional.ofNullable(authenticationType.getNullable("authentication_type")) + + /** + * Optional: the size of the employer to be created with this connection. Defaults to 20. + * Note that if this is higher than 100, historical payroll data will not be generated, and + * instead only one pay period will be created. + */ + fun employeeSize(): Optional = + Optional.ofNullable(employeeSize.getNullable("employee_size")) + + fun products(): Optional> = + Optional.ofNullable(products.getNullable("products")) + + /** The provider associated with the connection */ + @JsonProperty("provider_id") + @ExcludeMissing + fun _providerId(): JsonField = providerId + + @JsonProperty("authentication_type") + @ExcludeMissing + fun _authenticationType(): JsonField = authenticationType /** * Optional: the size of the employer to be created with this connection. Defaults to 20. @@ -78,15 +120,29 @@ constructor( * instead only one pay period will be created. */ @JsonProperty("employee_size") - fun employeeSize(): Optional = Optional.ofNullable(employeeSize) + @ExcludeMissing + fun _employeeSize(): JsonField = employeeSize @JsonProperty("products") - fun products(): Optional> = Optional.ofNullable(products) + @ExcludeMissing + fun _products(): JsonField> = products @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxConnectionCreateBody = apply { + if (!validated) { + providerId() + authenticationType() + employeeSize() + products() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -96,10 +152,10 @@ constructor( class Builder { - private var providerId: String? = null - private var authenticationType: AuthenticationType? = null - private var employeeSize: Long? = null - private var products: MutableList? = null + private var providerId: JsonField? = null + private var authenticationType: JsonField = JsonMissing.of() + private var employeeSize: JsonField = JsonMissing.of() + private var products: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -107,52 +163,57 @@ constructor( providerId = sandboxConnectionCreateBody.providerId authenticationType = sandboxConnectionCreateBody.authenticationType employeeSize = sandboxConnectionCreateBody.employeeSize - products = sandboxConnectionCreateBody.products?.toMutableList() + products = sandboxConnectionCreateBody.products.map { it.toMutableList() } additionalProperties = sandboxConnectionCreateBody.additionalProperties.toMutableMap() } /** The provider associated with the connection */ - fun providerId(providerId: String) = apply { this.providerId = providerId } + fun providerId(providerId: String) = providerId(JsonField.of(providerId)) + + /** The provider associated with the connection */ + fun providerId(providerId: JsonField) = apply { this.providerId = providerId } + + fun authenticationType(authenticationType: AuthenticationType) = + authenticationType(JsonField.of(authenticationType)) - fun authenticationType(authenticationType: AuthenticationType?) = apply { + fun authenticationType(authenticationType: JsonField) = apply { this.authenticationType = authenticationType } - fun authenticationType(authenticationType: Optional) = - authenticationType(authenticationType.orElse(null)) - /** * Optional: the size of the employer to be created with this connection. Defaults * to 20. Note that if this is higher than 100, historical payroll data will not be * generated, and instead only one pay period will be created. */ - fun employeeSize(employeeSize: Long?) = apply { this.employeeSize = employeeSize } + fun employeeSize(employeeSize: Long) = employeeSize(JsonField.of(employeeSize)) /** * Optional: the size of the employer to be created with this connection. Defaults * to 20. Note that if this is higher than 100, historical payroll data will not be * generated, and instead only one pay period will be created. */ - fun employeeSize(employeeSize: Long) = employeeSize(employeeSize as Long?) + fun employeeSize(employeeSize: JsonField) = apply { + this.employeeSize = employeeSize + } - /** - * Optional: the size of the employer to be created with this connection. Defaults - * to 20. Note that if this is higher than 100, historical payroll data will not be - * generated, and instead only one pay period will be created. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun employeeSize(employeeSize: Optional) = - employeeSize(employeeSize.orElse(null) as Long?) + fun products(products: List) = products(JsonField.of(products)) - fun products(products: List?) = apply { - this.products = products?.toMutableList() + fun products(products: JsonField>) = apply { + this.products = products.map { it.toMutableList() } } - fun products(products: Optional>) = products(products.orElse(null)) - fun addProduct(product: String) = apply { - products = (products ?: mutableListOf()).apply { add(product) } + products = + (products ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(product) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -179,7 +240,7 @@ constructor( checkNotNull(providerId) { "`providerId` is required but was not set" }, authenticationType, employeeSize, - products?.toImmutable(), + (products ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -227,42 +288,56 @@ constructor( /** The provider associated with the connection */ fun providerId(providerId: String) = apply { body.providerId(providerId) } - fun authenticationType(authenticationType: AuthenticationType?) = apply { + /** The provider associated with the connection */ + fun providerId(providerId: JsonField) = apply { body.providerId(providerId) } + + fun authenticationType(authenticationType: AuthenticationType) = apply { body.authenticationType(authenticationType) } - fun authenticationType(authenticationType: Optional) = - authenticationType(authenticationType.orElse(null)) - - /** - * Optional: the size of the employer to be created with this connection. Defaults to 20. - * Note that if this is higher than 100, historical payroll data will not be generated, and - * instead only one pay period will be created. - */ - fun employeeSize(employeeSize: Long?) = apply { body.employeeSize(employeeSize) } + fun authenticationType(authenticationType: JsonField) = apply { + body.authenticationType(authenticationType) + } /** * Optional: the size of the employer to be created with this connection. Defaults to 20. * Note that if this is higher than 100, historical payroll data will not be generated, and * instead only one pay period will be created. */ - fun employeeSize(employeeSize: Long) = employeeSize(employeeSize as Long?) + fun employeeSize(employeeSize: Long) = apply { body.employeeSize(employeeSize) } /** * Optional: the size of the employer to be created with this connection. Defaults to 20. * Note that if this is higher than 100, historical payroll data will not be generated, and * instead only one pay period will be created. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun employeeSize(employeeSize: Optional) = - employeeSize(employeeSize.orElse(null) as Long?) + fun employeeSize(employeeSize: JsonField) = apply { body.employeeSize(employeeSize) } - fun products(products: List?) = apply { body.products(products) } + fun products(products: List) = apply { body.products(products) } - fun products(products: Optional>) = products(products.orElse(null)) + fun products(products: JsonField>) = apply { body.products(products) } fun addProduct(product: String) = apply { body.addProduct(product) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -361,25 +436,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxConnectionCreateParams = SandboxConnectionCreateParams( body.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParams.kt index 5d24502e..c8633465 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxDirectoryCreateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -188,63 +189,216 @@ constructor( class IndividualOrEmployment @JsonCreator private constructor( - @JsonProperty("class_code") private val classCode: String?, - @JsonProperty("custom_fields") private val customFields: List?, - @JsonProperty("department") private val department: Department?, - @JsonProperty("dob") private val dob: String?, - @JsonProperty("emails") private val emails: List?, - @JsonProperty("employment") private val employment: Employment?, - @JsonProperty("employment_status") private val employmentStatus: EmploymentStatus?, - @JsonProperty("encrypted_ssn") private val encryptedSsn: String?, - @JsonProperty("end_date") private val endDate: String?, - @JsonProperty("ethnicity") private val ethnicity: Ethnicity?, - @JsonProperty("first_name") private val firstName: String?, - @JsonProperty("gender") private val gender: Gender?, - @JsonProperty("income") private val income: Income?, - @JsonProperty("income_history") private val incomeHistory: List?, - @JsonProperty("is_active") private val isActive: Boolean?, - @JsonProperty("last_name") private val lastName: String?, - @JsonProperty("latest_rehire_date") private val latestRehireDate: String?, - @JsonProperty("location") private val location: Location?, - @JsonProperty("manager") private val manager: Manager?, - @JsonProperty("middle_name") private val middleName: String?, - @JsonProperty("phone_numbers") private val phoneNumbers: List?, - @JsonProperty("preferred_name") private val preferredName: String?, - @JsonProperty("residence") private val residence: Location?, - @JsonProperty("source_id") private val sourceId: String?, - @JsonProperty("ssn") private val ssn: String?, - @JsonProperty("start_date") private val startDate: String?, - @JsonProperty("title") private val title: String?, + @JsonProperty("class_code") + @ExcludeMissing + private val classCode: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + private val customFields: JsonField> = JsonMissing.of(), + @JsonProperty("department") + @ExcludeMissing + private val department: JsonField = JsonMissing.of(), + @JsonProperty("dob") @ExcludeMissing private val dob: JsonField = JsonMissing.of(), + @JsonProperty("emails") + @ExcludeMissing + private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("employment") + @ExcludeMissing + private val employment: JsonField = JsonMissing.of(), + @JsonProperty("employment_status") + @ExcludeMissing + private val employmentStatus: JsonField = JsonMissing.of(), + @JsonProperty("encrypted_ssn") + @ExcludeMissing + private val encryptedSsn: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("ethnicity") + @ExcludeMissing + private val ethnicity: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + private val firstName: JsonField = JsonMissing.of(), + @JsonProperty("gender") + @ExcludeMissing + private val gender: JsonField = JsonMissing.of(), + @JsonProperty("income") + @ExcludeMissing + private val income: JsonField = JsonMissing.of(), + @JsonProperty("income_history") + @ExcludeMissing + private val incomeHistory: JsonField> = JsonMissing.of(), + @JsonProperty("is_active") + @ExcludeMissing + private val isActive: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + private val lastName: JsonField = JsonMissing.of(), + @JsonProperty("latest_rehire_date") + @ExcludeMissing + private val latestRehireDate: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("manager") + @ExcludeMissing + private val manager: JsonField = JsonMissing.of(), + @JsonProperty("middle_name") + @ExcludeMissing + private val middleName: JsonField = JsonMissing.of(), + @JsonProperty("phone_numbers") + @ExcludeMissing + private val phoneNumbers: JsonField> = JsonMissing.of(), + @JsonProperty("preferred_name") + @ExcludeMissing + private val preferredName: JsonField = JsonMissing.of(), + @JsonProperty("residence") + @ExcludeMissing + private val residence: JsonField = JsonMissing.of(), + @JsonProperty("source_id") + @ExcludeMissing + private val sourceId: JsonField = JsonMissing.of(), + @JsonProperty("ssn") @ExcludeMissing private val ssn: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("title") + @ExcludeMissing + private val title: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Worker's compensation classification code for this employee */ - @JsonProperty("class_code") - fun classCode(): Optional = Optional.ofNullable(classCode) + fun classCode(): Optional = Optional.ofNullable(classCode.getNullable("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. + */ + fun customFields(): Optional> = + Optional.ofNullable(customFields.getNullable("custom_fields")) + + /** The department object. */ + fun department(): Optional = + Optional.ofNullable(department.getNullable("department")) + + fun dob(): Optional = Optional.ofNullable(dob.getNullable("dob")) + + fun emails(): Optional> = Optional.ofNullable(emails.getNullable("emails")) + + /** The employment object. */ + fun employment(): Optional = + Optional.ofNullable(employment.getNullable("employment")) + + /** The detailed employment status of the individual. */ + fun employmentStatus(): Optional = + Optional.ofNullable(employmentStatus.getNullable("employment_status")) + + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set + * in the body. + */ + fun encryptedSsn(): Optional = + Optional.ofNullable(encryptedSsn.getNullable("encrypted_ssn")) + + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The EEOC-defined ethnicity of the individual. */ + fun ethnicity(): Optional = + Optional.ofNullable(ethnicity.getNullable("ethnicity")) + + /** The legal first name of the individual. */ + fun firstName(): Optional = Optional.ofNullable(firstName.getNullable("first_name")) + + /** The gender of the individual. */ + fun gender(): Optional = Optional.ofNullable(gender.getNullable("gender")) + + /** + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. + */ + fun income(): Optional = Optional.ofNullable(income.getNullable("income")) + + /** The array of income history. */ + fun incomeHistory(): Optional> = + Optional.ofNullable(incomeHistory.getNullable("income_history")) + + /** `true` if the individual an an active employee or contractor at the company. */ + fun isActive(): Optional = Optional.ofNullable(isActive.getNullable("is_active")) + + /** The legal last name of the individual. */ + fun lastName(): Optional = Optional.ofNullable(lastName.getNullable("last_name")) + + fun latestRehireDate(): Optional = + Optional.ofNullable(latestRehireDate.getNullable("latest_rehire_date")) + + fun location(): Optional = Optional.ofNullable(location.getNullable("location")) + + /** The manager object representing the manager of the individual within the org. */ + fun manager(): Optional = Optional.ofNullable(manager.getNullable("manager")) + + /** The legal middle name of the individual. */ + fun middleName(): Optional = + Optional.ofNullable(middleName.getNullable("middle_name")) + + fun phoneNumbers(): Optional> = + Optional.ofNullable(phoneNumbers.getNullable("phone_numbers")) + + /** The preferred name of the individual. */ + fun preferredName(): Optional = + Optional.ofNullable(preferredName.getNullable("preferred_name")) + + fun residence(): Optional = + Optional.ofNullable(residence.getNullable("residence")) + + /** The source system's unique employment identifier for this individual */ + fun sourceId(): Optional = Optional.ofNullable(sourceId.getNullable("source_id")) + + /** + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun ssn(): Optional = Optional.ofNullable(ssn.getNullable("ssn")) + + fun startDate(): Optional = Optional.ofNullable(startDate.getNullable("start_date")) + + /** The current title of the individual. */ + fun title(): Optional = Optional.ofNullable(title.getNullable("title")) + + /** Worker's compensation classification code for this employee */ + @JsonProperty("class_code") @ExcludeMissing fun _classCode(): JsonField = 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. */ @JsonProperty("custom_fields") - fun customFields(): Optional> = Optional.ofNullable(customFields) + @ExcludeMissing + fun _customFields(): JsonField> = customFields /** The department object. */ @JsonProperty("department") - fun department(): Optional = Optional.ofNullable(department) + @ExcludeMissing + fun _department(): JsonField = department - @JsonProperty("dob") fun dob(): Optional = Optional.ofNullable(dob) + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob - @JsonProperty("emails") fun emails(): Optional> = Optional.ofNullable(emails) + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails /** The employment object. */ @JsonProperty("employment") - fun employment(): Optional = Optional.ofNullable(employment) + @ExcludeMissing + fun _employment(): JsonField = employment /** The detailed employment status of the individual. */ @JsonProperty("employment_status") - fun employmentStatus(): Optional = Optional.ofNullable(employmentStatus) + @ExcludeMissing + fun _employmentStatus(): JsonField = employmentStatus /** * Social Security Number of the individual in **encrypted** format. This field is only @@ -252,80 +406,119 @@ constructor( * in the body. */ @JsonProperty("encrypted_ssn") - fun encryptedSsn(): Optional = Optional.ofNullable(encryptedSsn) + @ExcludeMissing + fun _encryptedSsn(): JsonField = encryptedSsn - @JsonProperty("end_date") fun endDate(): Optional = Optional.ofNullable(endDate) + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** The EEOC-defined ethnicity of the individual. */ @JsonProperty("ethnicity") - fun ethnicity(): Optional = Optional.ofNullable(ethnicity) + @ExcludeMissing + fun _ethnicity(): JsonField = ethnicity /** The legal first name of the individual. */ - @JsonProperty("first_name") - fun firstName(): Optional = Optional.ofNullable(firstName) + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** The gender of the individual. */ - @JsonProperty("gender") fun gender(): Optional = Optional.ofNullable(gender) + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender /** * The employee's income as reported by the provider. This may not always be annualized * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what * information the provider returns. */ - @JsonProperty("income") fun income(): Optional = Optional.ofNullable(income) + @JsonProperty("income") @ExcludeMissing fun _income(): JsonField = income /** The array of income history. */ @JsonProperty("income_history") - fun incomeHistory(): Optional> = Optional.ofNullable(incomeHistory) + @ExcludeMissing + fun _incomeHistory(): JsonField> = incomeHistory /** `true` if the individual an an active employee or contractor at the company. */ - @JsonProperty("is_active") fun isActive(): Optional = Optional.ofNullable(isActive) + @JsonProperty("is_active") @ExcludeMissing fun _isActive(): JsonField = isActive /** The legal last name of the individual. */ - @JsonProperty("last_name") fun lastName(): Optional = Optional.ofNullable(lastName) + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName @JsonProperty("latest_rehire_date") - fun latestRehireDate(): Optional = Optional.ofNullable(latestRehireDate) + @ExcludeMissing + fun _latestRehireDate(): JsonField = latestRehireDate - @JsonProperty("location") fun location(): Optional = Optional.ofNullable(location) + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location /** The manager object representing the manager of the individual within the org. */ - @JsonProperty("manager") fun manager(): Optional = Optional.ofNullable(manager) + @JsonProperty("manager") @ExcludeMissing fun _manager(): JsonField = manager /** The legal middle name of the individual. */ @JsonProperty("middle_name") - fun middleName(): Optional = Optional.ofNullable(middleName) + @ExcludeMissing + fun _middleName(): JsonField = middleName @JsonProperty("phone_numbers") - fun phoneNumbers(): Optional> = Optional.ofNullable(phoneNumbers) + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers /** The preferred name of the individual. */ @JsonProperty("preferred_name") - fun preferredName(): Optional = Optional.ofNullable(preferredName) + @ExcludeMissing + fun _preferredName(): JsonField = preferredName - @JsonProperty("residence") - fun residence(): Optional = Optional.ofNullable(residence) + @JsonProperty("residence") @ExcludeMissing fun _residence(): JsonField = residence /** The source system's unique employment identifier for this individual */ - @JsonProperty("source_id") fun sourceId(): Optional = Optional.ofNullable(sourceId) + @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId /** * Social Security Number of the individual. This field is only available with the `ssn` * scope enabled and the `options: { include: ['ssn'] }` param set in the body. * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). */ - @JsonProperty("ssn") fun ssn(): Optional = Optional.ofNullable(ssn) + @JsonProperty("ssn") @ExcludeMissing fun _ssn(): JsonField = ssn - @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate /** The current title of the individual. */ - @JsonProperty("title") fun title(): Optional = Optional.ofNullable(title) + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): IndividualOrEmployment = apply { + if (!validated) { + classCode() + customFields().map { it.forEach { it.validate() } } + department().map { it.validate() } + dob() + emails().map { it.forEach { it.validate() } } + employment().map { it.validate() } + employmentStatus() + encryptedSsn() + endDate() + ethnicity() + firstName() + gender() + income().map { it.validate() } + incomeHistory().map { it.forEach { it?.validate() } } + isActive() + lastName() + latestRehireDate() + location().map { it.validate() } + manager().map { it.validate() } + middleName() + phoneNumbers().map { it.forEach { it?.validate() } } + preferredName() + residence().map { it.validate() } + sourceId() + ssn() + startDate() + title() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -335,42 +528,42 @@ constructor( class Builder { - private var classCode: String? = null - private var customFields: MutableList? = null - private var department: Department? = null - private var dob: String? = null - private var emails: MutableList? = null - private var employment: Employment? = null - private var employmentStatus: EmploymentStatus? = null - private var encryptedSsn: String? = null - private var endDate: String? = null - private var ethnicity: Ethnicity? = null - private var firstName: String? = null - private var gender: Gender? = null - private var income: Income? = null - private var incomeHistory: MutableList? = null - private var isActive: Boolean? = null - private var lastName: String? = null - private var latestRehireDate: String? = null - private var location: Location? = null - private var manager: Manager? = null - private var middleName: String? = null - private var phoneNumbers: MutableList? = null - private var preferredName: String? = null - private var residence: Location? = null - private var sourceId: String? = null - private var ssn: String? = null - private var startDate: String? = null - private var title: String? = null + private var classCode: JsonField = JsonMissing.of() + private var customFields: JsonField>? = null + private var department: JsonField = JsonMissing.of() + private var dob: JsonField = JsonMissing.of() + private var emails: JsonField>? = null + private var employment: JsonField = JsonMissing.of() + private var employmentStatus: JsonField = JsonMissing.of() + private var encryptedSsn: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var ethnicity: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var gender: JsonField = JsonMissing.of() + private var income: JsonField = JsonMissing.of() + private var incomeHistory: JsonField>? = null + private var isActive: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var latestRehireDate: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var manager: JsonField = JsonMissing.of() + private var middleName: JsonField = JsonMissing.of() + private var phoneNumbers: JsonField>? = null + private var preferredName: JsonField = JsonMissing.of() + private var residence: JsonField = JsonMissing.of() + private var sourceId: JsonField = JsonMissing.of() + private var ssn: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var title: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(individualOrEmployment: IndividualOrEmployment) = apply { classCode = individualOrEmployment.classCode - customFields = individualOrEmployment.customFields?.toMutableList() + customFields = individualOrEmployment.customFields.map { it.toMutableList() } department = individualOrEmployment.department dob = individualOrEmployment.dob - emails = individualOrEmployment.emails?.toMutableList() + emails = individualOrEmployment.emails.map { it.toMutableList() } employment = individualOrEmployment.employment employmentStatus = individualOrEmployment.employmentStatus encryptedSsn = individualOrEmployment.encryptedSsn @@ -379,14 +572,14 @@ constructor( firstName = individualOrEmployment.firstName gender = individualOrEmployment.gender income = individualOrEmployment.income - incomeHistory = individualOrEmployment.incomeHistory?.toMutableList() + incomeHistory = individualOrEmployment.incomeHistory.map { it.toMutableList() } isActive = individualOrEmployment.isActive lastName = individualOrEmployment.lastName latestRehireDate = individualOrEmployment.latestRehireDate location = individualOrEmployment.location manager = individualOrEmployment.manager middleName = individualOrEmployment.middleName - phoneNumbers = individualOrEmployment.phoneNumbers?.toMutableList() + phoneNumbers = individualOrEmployment.phoneNumbers.map { it.toMutableList() } preferredName = individualOrEmployment.preferredName residence = individualOrEmployment.residence sourceId = individualOrEmployment.sourceId @@ -397,73 +590,115 @@ constructor( } /** Worker's compensation classification code for this employee */ - fun classCode(classCode: String?) = apply { this.classCode = classCode } + fun classCode(classCode: String?) = classCode(JsonField.ofNullable(classCode)) /** Worker's compensation classification code for this employee */ fun classCode(classCode: Optional) = classCode(classCode.orElse(null)) + /** Worker's compensation classification code for this employee */ + 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?) = apply { - this.customFields = customFields?.toMutableList() - } + fun customFields(customFields: List) = + customFields(JsonField.of(customFields)) /** * 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: Optional>) = - customFields(customFields.orElse(null)) + fun customFields(customFields: JsonField>) = apply { + this.customFields = customFields.map { it.toMutableList() } + } /** * 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 addCustomField(customField: CustomField) = apply { - customFields = (customFields ?: mutableListOf()).apply { add(customField) } + customFields = + (customFields ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(customField) + } } /** The department object. */ - fun department(department: Department?) = apply { this.department = department } + fun department(department: Department?) = department(JsonField.ofNullable(department)) /** The department object. */ fun department(department: Optional) = department(department.orElse(null)) - fun dob(dob: String?) = apply { this.dob = dob } + /** The department object. */ + fun department(department: JsonField) = apply { + this.department = department + } + + fun dob(dob: String?) = dob(JsonField.ofNullable(dob)) fun dob(dob: Optional) = dob(dob.orElse(null)) - fun emails(emails: List?) = apply { this.emails = emails?.toMutableList() } + fun dob(dob: JsonField) = apply { this.dob = dob } + + fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) fun emails(emails: Optional>) = emails(emails.orElse(null)) + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } + fun addEmail(email: Email) = apply { - emails = (emails ?: mutableListOf()).apply { add(email) } + emails = + (emails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(email) + } } /** The employment object. */ - fun employment(employment: Employment?) = apply { this.employment = employment } + fun employment(employment: Employment?) = employment(JsonField.ofNullable(employment)) /** The employment object. */ fun employment(employment: Optional) = employment(employment.orElse(null)) - /** The detailed employment status of the individual. */ - fun employmentStatus(employmentStatus: EmploymentStatus?) = apply { - this.employmentStatus = employmentStatus + /** The employment object. */ + fun employment(employment: JsonField) = apply { + this.employment = employment } + /** The detailed employment status of the individual. */ + fun employmentStatus(employmentStatus: EmploymentStatus?) = + employmentStatus(JsonField.ofNullable(employmentStatus)) + /** The detailed employment status of the individual. */ fun employmentStatus(employmentStatus: Optional) = employmentStatus(employmentStatus.orElse(null)) + /** The detailed employment status of the individual. */ + fun employmentStatus(employmentStatus: JsonField) = apply { + this.employmentStatus = employmentStatus + } + /** * Social Security Number of the individual in **encrypted** format. This field is only * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param * set in the body. */ - fun encryptedSsn(encryptedSsn: String?) = apply { this.encryptedSsn = encryptedSsn } + fun encryptedSsn(encryptedSsn: String?) = + encryptedSsn(JsonField.ofNullable(encryptedSsn)) /** * Social Security Number of the individual in **encrypted** format. This field is only @@ -473,34 +708,54 @@ constructor( fun encryptedSsn(encryptedSsn: Optional) = encryptedSsn(encryptedSsn.orElse(null)) - fun endDate(endDate: String?) = apply { this.endDate = endDate } + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param + * set in the body. + */ + fun encryptedSsn(encryptedSsn: JsonField) = apply { + this.encryptedSsn = encryptedSsn + } + + fun endDate(endDate: String?) = endDate(JsonField.ofNullable(endDate)) fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** The EEOC-defined ethnicity of the individual. */ - fun ethnicity(ethnicity: Ethnicity?) = apply { this.ethnicity = ethnicity } + fun ethnicity(ethnicity: Ethnicity?) = ethnicity(JsonField.ofNullable(ethnicity)) /** The EEOC-defined ethnicity of the individual. */ fun ethnicity(ethnicity: Optional) = ethnicity(ethnicity.orElse(null)) + /** The EEOC-defined ethnicity of the individual. */ + fun ethnicity(ethnicity: JsonField) = apply { this.ethnicity = ethnicity } + /** The legal first name of the individual. */ - fun firstName(firstName: String?) = apply { this.firstName = firstName } + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) /** The legal first name of the individual. */ fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) + /** The legal first name of the individual. */ + fun firstName(firstName: JsonField) = apply { this.firstName = firstName } + /** The gender of the individual. */ - fun gender(gender: Gender?) = apply { this.gender = gender } + fun gender(gender: Gender?) = gender(JsonField.ofNullable(gender)) /** The gender of the individual. */ fun gender(gender: Optional) = gender(gender.orElse(null)) + /** The gender of the individual. */ + fun gender(gender: JsonField) = apply { this.gender = gender } + /** * The employee's income as reported by the provider. This may not always be annualized * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what * information the provider returns. */ - fun income(income: Income?) = apply { this.income = income } + fun income(income: Income?) = income(JsonField.ofNullable(income)) /** * The employee's income as reported by the provider. This may not always be annualized @@ -509,23 +764,42 @@ constructor( */ fun income(income: Optional) = income(income.orElse(null)) + /** + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. + */ + fun income(income: JsonField) = apply { this.income = income } + /** The array of income history. */ - fun incomeHistory(incomeHistory: List?) = apply { - this.incomeHistory = incomeHistory?.toMutableList() - } + fun incomeHistory(incomeHistory: List?) = + incomeHistory(JsonField.ofNullable(incomeHistory)) /** The array of income history. */ fun incomeHistory(incomeHistory: Optional>) = incomeHistory(incomeHistory.orElse(null)) + /** The array of income history. */ + fun incomeHistory(incomeHistory: JsonField>) = apply { + this.incomeHistory = incomeHistory.map { it.toMutableList() } + } + /** The array of income history. */ fun addIncomeHistory(incomeHistory: Income) = apply { this.incomeHistory = - (this.incomeHistory ?: mutableListOf()).apply { add(incomeHistory) } + (this.incomeHistory ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(incomeHistory) + } } /** `true` if the individual an an active employee or contractor at the company. */ - fun isActive(isActive: Boolean?) = apply { this.isActive = isActive } + fun isActive(isActive: Boolean?) = isActive(JsonField.ofNullable(isActive)) /** `true` if the individual an an active employee or contractor at the company. */ fun isActive(isActive: Boolean) = isActive(isActive as Boolean?) @@ -534,69 +808,106 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun isActive(isActive: Optional) = isActive(isActive.orElse(null) as Boolean?) + /** `true` if the individual an an active employee or contractor at the company. */ + fun isActive(isActive: JsonField) = apply { this.isActive = isActive } + /** The legal last name of the individual. */ - fun lastName(lastName: String?) = apply { this.lastName = lastName } + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) /** The legal last name of the individual. */ fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) - fun latestRehireDate(latestRehireDate: String?) = apply { - this.latestRehireDate = latestRehireDate - } + /** The legal last name of the individual. */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + fun latestRehireDate(latestRehireDate: String?) = + latestRehireDate(JsonField.ofNullable(latestRehireDate)) fun latestRehireDate(latestRehireDate: Optional) = latestRehireDate(latestRehireDate.orElse(null)) - fun location(location: Location?) = apply { this.location = location } + fun latestRehireDate(latestRehireDate: JsonField) = apply { + this.latestRehireDate = latestRehireDate + } + + fun location(location: Location?) = location(JsonField.ofNullable(location)) fun location(location: Optional) = location(location.orElse(null)) + fun location(location: JsonField) = apply { this.location = location } + /** The manager object representing the manager of the individual within the org. */ - fun manager(manager: Manager?) = apply { this.manager = manager } + fun manager(manager: Manager?) = manager(JsonField.ofNullable(manager)) /** The manager object representing the manager of the individual within the org. */ fun manager(manager: Optional) = manager(manager.orElse(null)) + /** The manager object representing the manager of the individual within the org. */ + fun manager(manager: JsonField) = apply { this.manager = manager } + /** The legal middle name of the individual. */ - fun middleName(middleName: String?) = apply { this.middleName = middleName } + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) /** The legal middle name of the individual. */ fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) - fun phoneNumbers(phoneNumbers: List?) = apply { - this.phoneNumbers = phoneNumbers?.toMutableList() - } + /** The legal middle name of the individual. */ + fun middleName(middleName: JsonField) = apply { this.middleName = middleName } + + fun phoneNumbers(phoneNumbers: List?) = + phoneNumbers(JsonField.ofNullable(phoneNumbers)) fun phoneNumbers(phoneNumbers: Optional>) = phoneNumbers(phoneNumbers.orElse(null)) + fun phoneNumbers(phoneNumbers: JsonField>) = apply { + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } + } + fun addPhoneNumber(phoneNumber: PhoneNumber) = apply { - phoneNumbers = (phoneNumbers ?: mutableListOf()).apply { add(phoneNumber) } + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(phoneNumber) + } } /** The preferred name of the individual. */ - fun preferredName(preferredName: String?) = apply { this.preferredName = preferredName } + fun preferredName(preferredName: String?) = + preferredName(JsonField.ofNullable(preferredName)) /** The preferred name of the individual. */ fun preferredName(preferredName: Optional) = preferredName(preferredName.orElse(null)) - fun residence(residence: Location?) = apply { this.residence = residence } + /** The preferred name of the individual. */ + fun preferredName(preferredName: JsonField) = apply { + this.preferredName = preferredName + } + + fun residence(residence: Location?) = residence(JsonField.ofNullable(residence)) fun residence(residence: Optional) = residence(residence.orElse(null)) + fun residence(residence: JsonField) = apply { this.residence = residence } + /** The source system's unique employment identifier for this individual */ - fun sourceId(sourceId: String?) = apply { this.sourceId = sourceId } + fun sourceId(sourceId: String) = sourceId(JsonField.of(sourceId)) /** The source system's unique employment identifier for this individual */ - fun sourceId(sourceId: Optional) = sourceId(sourceId.orElse(null)) + fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } /** * Social Security Number of the individual. This field is only available with the `ssn` * scope enabled and the `options: { include: ['ssn'] }` param set in the body. * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). */ - fun ssn(ssn: String?) = apply { this.ssn = ssn } + fun ssn(ssn: String?) = ssn(JsonField.ofNullable(ssn)) /** * Social Security Number of the individual. This field is only available with the `ssn` @@ -605,16 +916,28 @@ constructor( */ fun ssn(ssn: Optional) = ssn(ssn.orElse(null)) - fun startDate(startDate: String?) = apply { this.startDate = startDate } + /** + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun ssn(ssn: JsonField) = apply { this.ssn = ssn } + + fun startDate(startDate: String?) = startDate(JsonField.ofNullable(startDate)) fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + /** The current title of the individual. */ - fun title(title: String?) = apply { this.title = title } + fun title(title: String?) = title(JsonField.ofNullable(title)) /** The current title of the individual. */ fun title(title: Optional) = title(title.orElse(null)) + /** The current title of the individual. */ + fun title(title: JsonField) = apply { this.title = title } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -637,10 +960,10 @@ constructor( fun build(): IndividualOrEmployment = IndividualOrEmployment( classCode, - customFields?.toImmutable(), + (customFields ?: JsonMissing.of()).map { it.toImmutable() }, department, dob, - emails?.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, employment, employmentStatus, encryptedSsn, @@ -649,14 +972,14 @@ constructor( firstName, gender, income, - incomeHistory?.toImmutable(), + (incomeHistory ?: JsonMissing.of()).map { it.toImmutable() }, isActive, lastName, latestRehireDate, location, manager, middleName, - phoneNumbers?.toImmutable(), + (phoneNumbers ?: JsonMissing.of()).map { it.toImmutable() }, preferredName, residence, sourceId, @@ -671,20 +994,33 @@ constructor( class CustomField @JsonCreator private constructor( - @JsonProperty("name") private val name: String?, - @JsonProperty("value") private val value: JsonValue?, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + @JsonProperty("value") @ExcludeMissing fun _value(): JsonValue = value - @JsonProperty("value") fun value(): Optional = Optional.ofNullable(value) + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CustomField = apply { + if (!validated) { + name() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -694,8 +1030,8 @@ constructor( class Builder { - private var name: String? = null - private var value: JsonValue? = null + private var name: JsonField = JsonMissing.of() + private var value: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -705,13 +1041,13 @@ constructor( additionalProperties = customField.additionalProperties.toMutableMap() } - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.orElse(null)) - fun value(value: JsonValue?) = apply { this.value = value } + fun name(name: JsonField) = apply { this.name = name } - fun value(value: Optional) = value(value.orElse(null)) + fun value(value: JsonValue) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -766,18 +1102,32 @@ constructor( class Department @JsonCreator private constructor( - @JsonProperty("name") private val name: String?, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the department associated with the individual. */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** The name of the department associated with the individual. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Department = apply { + if (!validated) { + name() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -787,7 +1137,7 @@ constructor( class Builder { - private var name: String? = null + private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -797,11 +1147,14 @@ constructor( } /** The name of the department associated with the individual. */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name of the department associated with the individual. */ fun name(name: Optional) = name(name.orElse(null)) + /** The name of the department associated with the individual. */ + fun name(name: JsonField) = apply { this.name = name } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -849,20 +1202,38 @@ constructor( class Email @JsonCreator private constructor( - @JsonProperty("data") private val data: String?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("data") fun data(): Optional = Optional.ofNullable(data) + fun data(): Optional = Optional.ofNullable(data.getNullable("data")) + + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Email = apply { + if (!validated) { + data() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -872,8 +1243,8 @@ constructor( class Builder { - private var data: String? = null - private var type: Type? = null + private var data: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -883,14 +1254,16 @@ constructor( additionalProperties = email.additionalProperties.toMutableMap() } - fun data(data: String?) = apply { this.data = data } + fun data(data: String) = data(JsonField.of(data)) - fun data(data: Optional) = data(data.orElse(null)) + fun data(data: JsonField) = apply { this.data = data } - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.orElse(null)) + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1001,8 +1374,12 @@ constructor( class Employment @JsonCreator private constructor( - @JsonProperty("subtype") private val subtype: Subtype?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("subtype") + @ExcludeMissing + private val subtype: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1011,15 +1388,34 @@ constructor( * The secondary employment type of the individual. Options: `full_time`, `part_time`, * `intern`, `temp`, `seasonal` and `individual_contractor`. */ - @JsonProperty("subtype") fun subtype(): Optional = Optional.ofNullable(subtype) + fun subtype(): Optional = Optional.ofNullable(subtype.getNullable("subtype")) + + /** The main employment type of the individual. */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** The main employment type of the individual. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Employment = apply { + if (!validated) { + subtype() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1029,8 +1425,8 @@ constructor( class Builder { - private var subtype: Subtype? = null - private var type: Type? = null + private var subtype: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1044,7 +1440,7 @@ constructor( * The secondary employment type of the individual. Options: `full_time`, * `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`. */ - fun subtype(subtype: Subtype?) = apply { this.subtype = subtype } + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) /** * The secondary employment type of the individual. Options: `full_time`, @@ -1052,12 +1448,21 @@ constructor( */ fun subtype(subtype: Optional) = subtype(subtype.orElse(null)) + /** + * The secondary employment type of the individual. Options: `full_time`, + * `part_time`, `intern`, `temp`, `seasonal` and `individual_contractor`. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + /** The main employment type of the individual. */ - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) /** The main employment type of the individual. */ fun type(type: Optional) = type(type.orElse(null)) + /** The main employment type of the individual. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1500,18 +1905,32 @@ constructor( class Manager @JsonCreator private constructor( - @JsonProperty("id") private val id: String?, + @JsonProperty("id") + @ExcludeMissing + private val id: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") fun id(): Optional = Optional.ofNullable(id) + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** A stable Finch `id` (UUID v4) for an individual in the company. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Manager = apply { + if (!validated) { + id() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1521,7 +1940,7 @@ constructor( class Builder { - private var id: String? = null + private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1531,10 +1950,10 @@ constructor( } /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: String?) = apply { this.id = id } + fun id(id: String) = id(JsonField.of(id)) /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: Optional) = id(id.orElse(null)) + fun id(id: JsonField) = apply { this.id = id } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1582,20 +2001,38 @@ constructor( class PhoneNumber @JsonCreator private constructor( - @JsonProperty("data") private val data: String?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("data") fun data(): Optional = Optional.ofNullable(data) + fun data(): Optional = Optional.ofNullable(data.getNullable("data")) + + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PhoneNumber = apply { + if (!validated) { + data() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1605,8 +2042,8 @@ constructor( class Builder { - private var data: String? = null - private var type: Type? = null + private var data: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1616,14 +2053,16 @@ constructor( additionalProperties = phoneNumber.additionalProperties.toMutableMap() } - fun data(data: String?) = apply { this.data = data } + fun data(data: String) = data(JsonField.of(data)) - fun data(data: Optional) = data(data.orElse(null)) + fun data(data: JsonField) = apply { this.data = data } - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.orElse(null)) + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParams.kt index c5a6048e..1b4eda05 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxEmploymentUpdateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -87,12 +88,69 @@ constructor( /** The current title of the individual. */ fun title(): Optional = body.title() - fun _additionalHeaders(): Headers = additionalHeaders + /** Worker's compensation classification code for this employee */ + fun _classCode(): JsonField = body._classCode() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * 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(): JsonField> = body._customFields() + + /** The department object. */ + fun _department(): JsonField = body._department() + + /** The employment object. */ + fun _employment(): JsonField = body._employment() + + /** The detailed employment status of the individual. */ + fun _employmentStatus(): JsonField = body._employmentStatus() + + fun _endDate(): JsonField = body._endDate() + + /** The legal first name of the individual. */ + fun _firstName(): JsonField = body._firstName() + + /** + * The employee's income as reported by the provider. This may not always be annualized income, + * but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what information the + * provider returns. + */ + fun _income(): JsonField = body._income() + + /** The array of income history. */ + fun _incomeHistory(): JsonField> = body._incomeHistory() + + /** `true` if the individual an an active employee or contractor at the company. */ + fun _isActive(): JsonField = body._isActive() + + /** The legal last name of the individual. */ + fun _lastName(): JsonField = body._lastName() + + fun _latestRehireDate(): JsonField = body._latestRehireDate() + + fun _location(): JsonField = body._location() + + /** The manager object representing the manager of the individual within the org. */ + fun _manager(): JsonField = body._manager() + + /** The legal middle name of the individual. */ + fun _middleName(): JsonField = body._middleName() + + /** The source system's unique employment identifier for this individual */ + fun _sourceId(): JsonField = body._sourceId() + + fun _startDate(): JsonField = body._startDate() + + /** The current title of the individual. */ + fun _title(): JsonField = body._title() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SandboxEmploymentUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -110,99 +168,229 @@ constructor( class SandboxEmploymentUpdateBody @JsonCreator internal constructor( - @JsonProperty("class_code") private val classCode: String?, - @JsonProperty("custom_fields") private val customFields: List?, - @JsonProperty("department") private val department: Department?, - @JsonProperty("employment") private val employment: Employment?, - @JsonProperty("employment_status") private val employmentStatus: EmploymentStatus?, - @JsonProperty("end_date") private val endDate: String?, - @JsonProperty("first_name") private val firstName: String?, - @JsonProperty("income") private val income: Income?, - @JsonProperty("income_history") private val incomeHistory: List?, - @JsonProperty("is_active") private val isActive: Boolean?, - @JsonProperty("last_name") private val lastName: String?, - @JsonProperty("latest_rehire_date") private val latestRehireDate: String?, - @JsonProperty("location") private val location: Location?, - @JsonProperty("manager") private val manager: Manager?, - @JsonProperty("middle_name") private val middleName: String?, - @JsonProperty("source_id") private val sourceId: String?, - @JsonProperty("start_date") private val startDate: String?, - @JsonProperty("title") private val title: String?, + @JsonProperty("class_code") + @ExcludeMissing + private val classCode: JsonField = JsonMissing.of(), + @JsonProperty("custom_fields") + @ExcludeMissing + private val customFields: JsonField> = JsonMissing.of(), + @JsonProperty("department") + @ExcludeMissing + private val department: JsonField = JsonMissing.of(), + @JsonProperty("employment") + @ExcludeMissing + private val employment: JsonField = JsonMissing.of(), + @JsonProperty("employment_status") + @ExcludeMissing + private val employmentStatus: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + private val firstName: JsonField = JsonMissing.of(), + @JsonProperty("income") + @ExcludeMissing + private val income: JsonField = JsonMissing.of(), + @JsonProperty("income_history") + @ExcludeMissing + private val incomeHistory: JsonField> = JsonMissing.of(), + @JsonProperty("is_active") + @ExcludeMissing + private val isActive: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + private val lastName: JsonField = JsonMissing.of(), + @JsonProperty("latest_rehire_date") + @ExcludeMissing + private val latestRehireDate: JsonField = JsonMissing.of(), + @JsonProperty("location") + @ExcludeMissing + private val location: JsonField = JsonMissing.of(), + @JsonProperty("manager") + @ExcludeMissing + private val manager: JsonField = JsonMissing.of(), + @JsonProperty("middle_name") + @ExcludeMissing + private val middleName: JsonField = JsonMissing.of(), + @JsonProperty("source_id") + @ExcludeMissing + private val sourceId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("title") + @ExcludeMissing + private val title: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Worker's compensation classification code for this employee */ - @JsonProperty("class_code") - fun classCode(): Optional = Optional.ofNullable(classCode) + fun classCode(): Optional = Optional.ofNullable(classCode.getNullable("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. + */ + fun customFields(): Optional> = + Optional.ofNullable(customFields.getNullable("custom_fields")) + + /** The department object. */ + fun department(): Optional = + Optional.ofNullable(department.getNullable("department")) + + /** The employment object. */ + fun employment(): Optional = + Optional.ofNullable(employment.getNullable("employment")) + + /** The detailed employment status of the individual. */ + fun employmentStatus(): Optional = + Optional.ofNullable(employmentStatus.getNullable("employment_status")) + + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The legal first name of the individual. */ + fun firstName(): Optional = Optional.ofNullable(firstName.getNullable("first_name")) + + /** + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. + */ + fun income(): Optional = Optional.ofNullable(income.getNullable("income")) + + /** The array of income history. */ + fun incomeHistory(): Optional> = + Optional.ofNullable(incomeHistory.getNullable("income_history")) + + /** `true` if the individual an an active employee or contractor at the company. */ + fun isActive(): Optional = Optional.ofNullable(isActive.getNullable("is_active")) + + /** The legal last name of the individual. */ + fun lastName(): Optional = Optional.ofNullable(lastName.getNullable("last_name")) + + fun latestRehireDate(): Optional = + Optional.ofNullable(latestRehireDate.getNullable("latest_rehire_date")) + + fun location(): Optional = Optional.ofNullable(location.getNullable("location")) + + /** The manager object representing the manager of the individual within the org. */ + fun manager(): Optional = Optional.ofNullable(manager.getNullable("manager")) + + /** The legal middle name of the individual. */ + fun middleName(): Optional = + Optional.ofNullable(middleName.getNullable("middle_name")) + + /** The source system's unique employment identifier for this individual */ + fun sourceId(): Optional = Optional.ofNullable(sourceId.getNullable("source_id")) + + fun startDate(): Optional = Optional.ofNullable(startDate.getNullable("start_date")) + + /** The current title of the individual. */ + fun title(): Optional = Optional.ofNullable(title.getNullable("title")) + + /** Worker's compensation classification code for this employee */ + @JsonProperty("class_code") @ExcludeMissing fun _classCode(): JsonField = 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. */ @JsonProperty("custom_fields") - fun customFields(): Optional> = Optional.ofNullable(customFields) + @ExcludeMissing + fun _customFields(): JsonField> = customFields /** The department object. */ @JsonProperty("department") - fun department(): Optional = Optional.ofNullable(department) + @ExcludeMissing + fun _department(): JsonField = department /** The employment object. */ @JsonProperty("employment") - fun employment(): Optional = Optional.ofNullable(employment) + @ExcludeMissing + fun _employment(): JsonField = employment /** The detailed employment status of the individual. */ @JsonProperty("employment_status") - fun employmentStatus(): Optional = Optional.ofNullable(employmentStatus) + @ExcludeMissing + fun _employmentStatus(): JsonField = employmentStatus - @JsonProperty("end_date") fun endDate(): Optional = Optional.ofNullable(endDate) + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** The legal first name of the individual. */ - @JsonProperty("first_name") - fun firstName(): Optional = Optional.ofNullable(firstName) + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** * The employee's income as reported by the provider. This may not always be annualized * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what * information the provider returns. */ - @JsonProperty("income") fun income(): Optional = Optional.ofNullable(income) + @JsonProperty("income") @ExcludeMissing fun _income(): JsonField = income /** The array of income history. */ @JsonProperty("income_history") - fun incomeHistory(): Optional> = Optional.ofNullable(incomeHistory) + @ExcludeMissing + fun _incomeHistory(): JsonField> = incomeHistory /** `true` if the individual an an active employee or contractor at the company. */ - @JsonProperty("is_active") fun isActive(): Optional = Optional.ofNullable(isActive) + @JsonProperty("is_active") @ExcludeMissing fun _isActive(): JsonField = isActive /** The legal last name of the individual. */ - @JsonProperty("last_name") fun lastName(): Optional = Optional.ofNullable(lastName) + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName @JsonProperty("latest_rehire_date") - fun latestRehireDate(): Optional = Optional.ofNullable(latestRehireDate) + @ExcludeMissing + fun _latestRehireDate(): JsonField = latestRehireDate - @JsonProperty("location") fun location(): Optional = Optional.ofNullable(location) + @JsonProperty("location") @ExcludeMissing fun _location(): JsonField = location /** The manager object representing the manager of the individual within the org. */ - @JsonProperty("manager") fun manager(): Optional = Optional.ofNullable(manager) + @JsonProperty("manager") @ExcludeMissing fun _manager(): JsonField = manager /** The legal middle name of the individual. */ @JsonProperty("middle_name") - fun middleName(): Optional = Optional.ofNullable(middleName) + @ExcludeMissing + fun _middleName(): JsonField = middleName /** The source system's unique employment identifier for this individual */ - @JsonProperty("source_id") fun sourceId(): Optional = Optional.ofNullable(sourceId) + @JsonProperty("source_id") @ExcludeMissing fun _sourceId(): JsonField = sourceId - @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate /** The current title of the individual. */ - @JsonProperty("title") fun title(): Optional = Optional.ofNullable(title) + @JsonProperty("title") @ExcludeMissing fun _title(): JsonField = title @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxEmploymentUpdateBody = apply { + if (!validated) { + classCode() + customFields().map { it.forEach { it.validate() } } + department().map { it.validate() } + employment().map { it.validate() } + employmentStatus() + endDate() + firstName() + income().map { it.validate() } + incomeHistory().map { it.forEach { it?.validate() } } + isActive() + lastName() + latestRehireDate() + location().map { it.validate() } + manager().map { it.validate() } + middleName() + sourceId() + startDate() + title() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -212,37 +400,37 @@ constructor( class Builder { - private var classCode: String? = null - private var customFields: MutableList? = null - private var department: Department? = null - private var employment: Employment? = null - private var employmentStatus: EmploymentStatus? = null - private var endDate: String? = null - private var firstName: String? = null - private var income: Income? = null - private var incomeHistory: MutableList? = null - private var isActive: Boolean? = null - private var lastName: String? = null - private var latestRehireDate: String? = null - private var location: Location? = null - private var manager: Manager? = null - private var middleName: String? = null - private var sourceId: String? = null - private var startDate: String? = null - private var title: String? = null + private var classCode: JsonField = JsonMissing.of() + private var customFields: JsonField>? = null + private var department: JsonField = JsonMissing.of() + private var employment: JsonField = JsonMissing.of() + private var employmentStatus: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var income: JsonField = JsonMissing.of() + private var incomeHistory: JsonField>? = null + private var isActive: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var latestRehireDate: JsonField = JsonMissing.of() + private var location: JsonField = JsonMissing.of() + private var manager: JsonField = JsonMissing.of() + private var middleName: JsonField = JsonMissing.of() + private var sourceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() + private var title: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(sandboxEmploymentUpdateBody: SandboxEmploymentUpdateBody) = apply { classCode = sandboxEmploymentUpdateBody.classCode - customFields = sandboxEmploymentUpdateBody.customFields?.toMutableList() + customFields = sandboxEmploymentUpdateBody.customFields.map { it.toMutableList() } department = sandboxEmploymentUpdateBody.department employment = sandboxEmploymentUpdateBody.employment employmentStatus = sandboxEmploymentUpdateBody.employmentStatus endDate = sandboxEmploymentUpdateBody.endDate firstName = sandboxEmploymentUpdateBody.firstName income = sandboxEmploymentUpdateBody.income - incomeHistory = sandboxEmploymentUpdateBody.incomeHistory?.toMutableList() + incomeHistory = sandboxEmploymentUpdateBody.incomeHistory.map { it.toMutableList() } isActive = sandboxEmploymentUpdateBody.isActive lastName = sandboxEmploymentUpdateBody.lastName latestRehireDate = sandboxEmploymentUpdateBody.latestRehireDate @@ -257,71 +445,102 @@ constructor( } /** Worker's compensation classification code for this employee */ - fun classCode(classCode: String?) = apply { this.classCode = classCode } + fun classCode(classCode: String?) = classCode(JsonField.ofNullable(classCode)) /** Worker's compensation classification code for this employee */ fun classCode(classCode: Optional) = classCode(classCode.orElse(null)) + /** Worker's compensation classification code for this employee */ + 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?) = apply { - this.customFields = customFields?.toMutableList() - } + fun customFields(customFields: List) = + customFields(JsonField.of(customFields)) /** * 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: Optional>) = - customFields(customFields.orElse(null)) + fun customFields(customFields: JsonField>) = apply { + this.customFields = customFields.map { it.toMutableList() } + } /** * 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 addCustomField(customField: CustomField) = apply { - customFields = (customFields ?: mutableListOf()).apply { add(customField) } + customFields = + (customFields ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(customField) + } } /** The department object. */ - fun department(department: Department?) = apply { this.department = department } + fun department(department: Department?) = department(JsonField.ofNullable(department)) /** The department object. */ fun department(department: Optional) = department(department.orElse(null)) + /** The department object. */ + fun department(department: JsonField) = apply { + this.department = department + } + /** The employment object. */ - fun employment(employment: Employment?) = apply { this.employment = employment } + fun employment(employment: Employment?) = employment(JsonField.ofNullable(employment)) /** The employment object. */ fun employment(employment: Optional) = employment(employment.orElse(null)) - /** The detailed employment status of the individual. */ - fun employmentStatus(employmentStatus: EmploymentStatus?) = apply { - this.employmentStatus = employmentStatus + /** The employment object. */ + fun employment(employment: JsonField) = apply { + this.employment = employment } + /** The detailed employment status of the individual. */ + fun employmentStatus(employmentStatus: EmploymentStatus?) = + employmentStatus(JsonField.ofNullable(employmentStatus)) + /** The detailed employment status of the individual. */ fun employmentStatus(employmentStatus: Optional) = employmentStatus(employmentStatus.orElse(null)) - fun endDate(endDate: String?) = apply { this.endDate = endDate } + /** The detailed employment status of the individual. */ + fun employmentStatus(employmentStatus: JsonField) = apply { + this.employmentStatus = employmentStatus + } + + fun endDate(endDate: String?) = endDate(JsonField.ofNullable(endDate)) fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** The legal first name of the individual. */ - fun firstName(firstName: String?) = apply { this.firstName = firstName } + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) /** The legal first name of the individual. */ fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) + /** The legal first name of the individual. */ + fun firstName(firstName: JsonField) = apply { this.firstName = firstName } + /** * The employee's income as reported by the provider. This may not always be annualized * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what * information the provider returns. */ - fun income(income: Income?) = apply { this.income = income } + fun income(income: Income?) = income(JsonField.ofNullable(income)) /** * The employee's income as reported by the provider. This may not always be annualized @@ -330,23 +549,42 @@ constructor( */ fun income(income: Optional) = income(income.orElse(null)) + /** + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. + */ + fun income(income: JsonField) = apply { this.income = income } + /** The array of income history. */ - fun incomeHistory(incomeHistory: List?) = apply { - this.incomeHistory = incomeHistory?.toMutableList() - } + fun incomeHistory(incomeHistory: List?) = + incomeHistory(JsonField.ofNullable(incomeHistory)) /** The array of income history. */ fun incomeHistory(incomeHistory: Optional>) = incomeHistory(incomeHistory.orElse(null)) + /** The array of income history. */ + fun incomeHistory(incomeHistory: JsonField>) = apply { + this.incomeHistory = incomeHistory.map { it.toMutableList() } + } + /** The array of income history. */ fun addIncomeHistory(incomeHistory: Income) = apply { this.incomeHistory = - (this.incomeHistory ?: mutableListOf()).apply { add(incomeHistory) } + (this.incomeHistory ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(incomeHistory) + } } /** `true` if the individual an an active employee or contractor at the company. */ - fun isActive(isActive: Boolean?) = apply { this.isActive = isActive } + fun isActive(isActive: Boolean?) = isActive(JsonField.ofNullable(isActive)) /** `true` if the individual an an active employee or contractor at the company. */ fun isActive(isActive: Boolean) = isActive(isActive as Boolean?) @@ -355,51 +593,73 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun isActive(isActive: Optional) = isActive(isActive.orElse(null) as Boolean?) + /** `true` if the individual an an active employee or contractor at the company. */ + fun isActive(isActive: JsonField) = apply { this.isActive = isActive } + /** The legal last name of the individual. */ - fun lastName(lastName: String?) = apply { this.lastName = lastName } + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) /** The legal last name of the individual. */ fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) - fun latestRehireDate(latestRehireDate: String?) = apply { - this.latestRehireDate = latestRehireDate - } + /** The legal last name of the individual. */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + + fun latestRehireDate(latestRehireDate: String?) = + latestRehireDate(JsonField.ofNullable(latestRehireDate)) fun latestRehireDate(latestRehireDate: Optional) = latestRehireDate(latestRehireDate.orElse(null)) - fun location(location: Location?) = apply { this.location = location } + fun latestRehireDate(latestRehireDate: JsonField) = apply { + this.latestRehireDate = latestRehireDate + } + + fun location(location: Location?) = location(JsonField.ofNullable(location)) fun location(location: Optional) = location(location.orElse(null)) + fun location(location: JsonField) = apply { this.location = location } + /** The manager object representing the manager of the individual within the org. */ - fun manager(manager: Manager?) = apply { this.manager = manager } + fun manager(manager: Manager?) = manager(JsonField.ofNullable(manager)) /** The manager object representing the manager of the individual within the org. */ fun manager(manager: Optional) = manager(manager.orElse(null)) + /** The manager object representing the manager of the individual within the org. */ + fun manager(manager: JsonField) = apply { this.manager = manager } + /** The legal middle name of the individual. */ - fun middleName(middleName: String?) = apply { this.middleName = middleName } + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) /** The legal middle name of the individual. */ fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) + /** The legal middle name of the individual. */ + fun middleName(middleName: JsonField) = apply { this.middleName = middleName } + /** The source system's unique employment identifier for this individual */ - fun sourceId(sourceId: String?) = apply { this.sourceId = sourceId } + fun sourceId(sourceId: String) = sourceId(JsonField.of(sourceId)) /** The source system's unique employment identifier for this individual */ - fun sourceId(sourceId: Optional) = sourceId(sourceId.orElse(null)) + fun sourceId(sourceId: JsonField) = apply { this.sourceId = sourceId } - fun startDate(startDate: String?) = apply { this.startDate = startDate } + fun startDate(startDate: String?) = startDate(JsonField.ofNullable(startDate)) fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } + /** The current title of the individual. */ - fun title(title: String?) = apply { this.title = title } + fun title(title: String?) = title(JsonField.ofNullable(title)) /** The current title of the individual. */ fun title(title: Optional) = title(title.orElse(null)) + /** The current title of the individual. */ + fun title(title: JsonField) = apply { this.title = title } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -422,14 +682,14 @@ constructor( fun build(): SandboxEmploymentUpdateBody = SandboxEmploymentUpdateBody( classCode, - customFields?.toImmutable(), + (customFields ?: JsonMissing.of()).map { it.toImmutable() }, department, employment, employmentStatus, endDate, firstName, income, - incomeHistory?.toImmutable(), + (incomeHistory ?: JsonMissing.of()).map { it.toImmutable() }, isActive, lastName, latestRehireDate, @@ -493,11 +753,14 @@ constructor( /** Worker's compensation classification code for this employee */ fun classCode(classCode: Optional) = classCode(classCode.orElse(null)) + /** Worker's compensation classification code for this employee */ + fun classCode(classCode: JsonField) = apply { body.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?) = apply { + fun customFields(customFields: List) = apply { body.customFields(customFields) } @@ -505,8 +768,9 @@ constructor( * 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: Optional>) = - customFields(customFields.orElse(null)) + fun customFields(customFields: JsonField>) = apply { + body.customFields(customFields) + } /** * Custom fields for the individual. These are fields which are defined by the employer in @@ -520,12 +784,18 @@ constructor( /** The department object. */ fun department(department: Optional) = department(department.orElse(null)) + /** The department object. */ + fun department(department: JsonField) = apply { body.department(department) } + /** The employment object. */ fun employment(employment: Employment?) = apply { body.employment(employment) } /** The employment object. */ fun employment(employment: Optional) = employment(employment.orElse(null)) + /** The employment object. */ + fun employment(employment: JsonField) = apply { body.employment(employment) } + /** The detailed employment status of the individual. */ fun employmentStatus(employmentStatus: EmploymentStatus?) = apply { body.employmentStatus(employmentStatus) @@ -535,16 +805,26 @@ constructor( fun employmentStatus(employmentStatus: Optional) = employmentStatus(employmentStatus.orElse(null)) + /** The detailed employment status of the individual. */ + fun employmentStatus(employmentStatus: JsonField) = apply { + body.employmentStatus(employmentStatus) + } + fun endDate(endDate: String?) = apply { body.endDate(endDate) } fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + /** The legal first name of the individual. */ fun firstName(firstName: String?) = apply { body.firstName(firstName) } /** The legal first name of the individual. */ fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) + /** The legal first name of the individual. */ + fun firstName(firstName: JsonField) = apply { body.firstName(firstName) } + /** * The employee's income as reported by the provider. This may not always be annualized * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what @@ -559,6 +839,13 @@ constructor( */ fun income(income: Optional) = income(income.orElse(null)) + /** + * The employee's income as reported by the provider. This may not always be annualized + * income, but may be in units of bi-weekly, semi-monthly, daily, etc, depending on what + * information the provider returns. + */ + fun income(income: JsonField) = apply { body.income(income) } + /** The array of income history. */ fun incomeHistory(incomeHistory: List?) = apply { body.incomeHistory(incomeHistory) @@ -568,6 +855,11 @@ constructor( fun incomeHistory(incomeHistory: Optional>) = incomeHistory(incomeHistory.orElse(null)) + /** The array of income history. */ + fun incomeHistory(incomeHistory: JsonField>) = apply { + body.incomeHistory(incomeHistory) + } + /** The array of income history. */ fun addIncomeHistory(incomeHistory: Income) = apply { body.addIncomeHistory(incomeHistory) } @@ -581,12 +873,18 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun isActive(isActive: Optional) = isActive(isActive.orElse(null) as Boolean?) + /** `true` if the individual an an active employee or contractor at the company. */ + fun isActive(isActive: JsonField) = apply { body.isActive(isActive) } + /** The legal last name of the individual. */ fun lastName(lastName: String?) = apply { body.lastName(lastName) } /** The legal last name of the individual. */ fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) + /** The legal last name of the individual. */ + fun lastName(lastName: JsonField) = apply { body.lastName(lastName) } + fun latestRehireDate(latestRehireDate: String?) = apply { body.latestRehireDate(latestRehireDate) } @@ -594,38 +892,74 @@ constructor( fun latestRehireDate(latestRehireDate: Optional) = latestRehireDate(latestRehireDate.orElse(null)) + fun latestRehireDate(latestRehireDate: JsonField) = apply { + body.latestRehireDate(latestRehireDate) + } + fun location(location: Location?) = apply { body.location(location) } fun location(location: Optional) = location(location.orElse(null)) + fun location(location: JsonField) = apply { body.location(location) } + /** The manager object representing the manager of the individual within the org. */ fun manager(manager: Manager?) = apply { body.manager(manager) } /** The manager object representing the manager of the individual within the org. */ fun manager(manager: Optional) = manager(manager.orElse(null)) + /** The manager object representing the manager of the individual within the org. */ + fun manager(manager: JsonField) = apply { body.manager(manager) } + /** The legal middle name of the individual. */ fun middleName(middleName: String?) = apply { body.middleName(middleName) } /** The legal middle name of the individual. */ fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) + /** The legal middle name of the individual. */ + fun middleName(middleName: JsonField) = apply { body.middleName(middleName) } + /** The source system's unique employment identifier for this individual */ - fun sourceId(sourceId: String?) = apply { body.sourceId(sourceId) } + fun sourceId(sourceId: String) = apply { body.sourceId(sourceId) } /** The source system's unique employment identifier for this individual */ - fun sourceId(sourceId: Optional) = sourceId(sourceId.orElse(null)) + fun sourceId(sourceId: JsonField) = apply { body.sourceId(sourceId) } fun startDate(startDate: String?) = apply { body.startDate(startDate) } fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + /** The current title of the individual. */ fun title(title: String?) = apply { body.title(title) } /** The current title of the individual. */ fun title(title: Optional) = title(title.orElse(null)) + /** The current title of the individual. */ + fun title(title: JsonField) = apply { body.title(title) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -724,25 +1058,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxEmploymentUpdateParams = SandboxEmploymentUpdateParams( checkNotNull(individualId) { "`individualId` is required but was not set" }, @@ -756,20 +1071,33 @@ constructor( class CustomField @JsonCreator private constructor( - @JsonProperty("name") private val name: String?, - @JsonProperty("value") private val value: JsonValue?, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing private val value: JsonValue = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("value") fun value(): Optional = Optional.ofNullable(value) + @JsonProperty("value") @ExcludeMissing fun _value(): JsonValue = value + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CustomField = apply { + if (!validated) { + name() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -779,8 +1107,8 @@ constructor( class Builder { - private var name: String? = null - private var value: JsonValue? = null + private var name: JsonField = JsonMissing.of() + private var value: JsonValue = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -790,13 +1118,13 @@ constructor( additionalProperties = customField.additionalProperties.toMutableMap() } - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.orElse(null)) - fun value(value: JsonValue?) = apply { this.value = value } + fun name(name: JsonField) = apply { this.name = name } - fun value(value: Optional) = value(value.orElse(null)) + fun value(value: JsonValue) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -848,18 +1176,32 @@ constructor( class Department @JsonCreator private constructor( - @JsonProperty("name") private val name: String?, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the department associated with the individual. */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** The name of the department associated with the individual. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Department = apply { + if (!validated) { + name() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -869,7 +1211,7 @@ constructor( class Builder { - private var name: String? = null + private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -879,11 +1221,14 @@ constructor( } /** The name of the department associated with the individual. */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The name of the department associated with the individual. */ fun name(name: Optional) = name(name.orElse(null)) + /** The name of the department associated with the individual. */ + fun name(name: JsonField) = apply { this.name = name } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -929,8 +1274,10 @@ constructor( class Employment @JsonCreator private constructor( - @JsonProperty("subtype") private val subtype: Subtype?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("subtype") + @ExcludeMissing + private val subtype: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -939,15 +1286,34 @@ constructor( * The secondary employment type of the individual. Options: `full_time`, `part_time`, * `intern`, `temp`, `seasonal` and `individual_contractor`. */ - @JsonProperty("subtype") fun subtype(): Optional = Optional.ofNullable(subtype) + fun subtype(): Optional = Optional.ofNullable(subtype.getNullable("subtype")) + + /** The main employment type of the individual. */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ + @JsonProperty("subtype") @ExcludeMissing fun _subtype(): JsonField = subtype /** The main employment type of the individual. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Employment = apply { + if (!validated) { + subtype() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -957,8 +1323,8 @@ constructor( class Builder { - private var subtype: Subtype? = null - private var type: Type? = null + private var subtype: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -972,7 +1338,7 @@ constructor( * The secondary employment type of the individual. Options: `full_time`, `part_time`, * `intern`, `temp`, `seasonal` and `individual_contractor`. */ - fun subtype(subtype: Subtype?) = apply { this.subtype = subtype } + fun subtype(subtype: Subtype?) = subtype(JsonField.ofNullable(subtype)) /** * The secondary employment type of the individual. Options: `full_time`, `part_time`, @@ -980,12 +1346,21 @@ constructor( */ fun subtype(subtype: Optional) = subtype(subtype.orElse(null)) + /** + * The secondary employment type of the individual. Options: `full_time`, `part_time`, + * `intern`, `temp`, `seasonal` and `individual_contractor`. + */ + fun subtype(subtype: JsonField) = apply { this.subtype = subtype } + /** The main employment type of the individual. */ - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) /** The main employment type of the individual. */ fun type(type: Optional) = type(type.orElse(null)) + /** The main employment type of the individual. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1261,18 +1636,30 @@ constructor( class Manager @JsonCreator private constructor( - @JsonProperty("id") private val id: String?, + @JsonProperty("id") @ExcludeMissing private val id: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A stable Finch `id` (UUID v4) for an individual in the company. */ - @JsonProperty("id") fun id(): Optional = Optional.ofNullable(id) + fun id(): Optional = Optional.ofNullable(id.getNullable("id")) + + /** A stable Finch `id` (UUID v4) for an individual in the company. */ + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Manager = apply { + if (!validated) { + id() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1282,7 +1669,7 @@ constructor( class Builder { - private var id: String? = null + private var id: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1292,10 +1679,10 @@ constructor( } /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: String?) = apply { this.id = id } + fun id(id: String) = id(JsonField.of(id)) /** A stable Finch `id` (UUID v4) for an individual in the company. */ - fun id(id: Optional) = id(id.orElse(null)) + fun id(id: JsonField) = apply { this.id = id } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParams.kt index 920b1758..536b4c89 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxIndividualUpdateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -70,12 +71,52 @@ constructor( */ fun ssn(): Optional = body.ssn() - fun _additionalHeaders(): Headers = additionalHeaders + fun _dob(): JsonField = body._dob() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _emails(): JsonField> = body._emails() + + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set in + * the body. + */ + fun _encryptedSsn(): JsonField = body._encryptedSsn() + + /** The EEOC-defined ethnicity of the individual. */ + fun _ethnicity(): JsonField = body._ethnicity() + + /** The legal first name of the individual. */ + fun _firstName(): JsonField = body._firstName() + + /** The gender of the individual. */ + fun _gender(): JsonField = body._gender() + + /** The legal last name of the individual. */ + fun _lastName(): JsonField = body._lastName() + + /** The legal middle name of the individual. */ + fun _middleName(): JsonField = body._middleName() + + fun _phoneNumbers(): JsonField> = body._phoneNumbers() + + /** The preferred name of the individual. */ + fun _preferredName(): JsonField = body._preferredName() + + fun _residence(): JsonField = body._residence() + + /** + * Social Security Number of the individual. This field is only available with the `ssn` scope + * enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun _ssn(): JsonField = body._ssn() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SandboxIndividualUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -93,25 +134,91 @@ constructor( class SandboxIndividualUpdateBody @JsonCreator internal constructor( - @JsonProperty("dob") private val dob: String?, - @JsonProperty("emails") private val emails: List?, - @JsonProperty("encrypted_ssn") private val encryptedSsn: String?, - @JsonProperty("ethnicity") private val ethnicity: Ethnicity?, - @JsonProperty("first_name") private val firstName: String?, - @JsonProperty("gender") private val gender: Gender?, - @JsonProperty("last_name") private val lastName: String?, - @JsonProperty("middle_name") private val middleName: String?, - @JsonProperty("phone_numbers") private val phoneNumbers: List?, - @JsonProperty("preferred_name") private val preferredName: String?, - @JsonProperty("residence") private val residence: Location?, - @JsonProperty("ssn") private val ssn: String?, + @JsonProperty("dob") @ExcludeMissing private val dob: JsonField = JsonMissing.of(), + @JsonProperty("emails") + @ExcludeMissing + private val emails: JsonField> = JsonMissing.of(), + @JsonProperty("encrypted_ssn") + @ExcludeMissing + private val encryptedSsn: JsonField = JsonMissing.of(), + @JsonProperty("ethnicity") + @ExcludeMissing + private val ethnicity: JsonField = JsonMissing.of(), + @JsonProperty("first_name") + @ExcludeMissing + private val firstName: JsonField = JsonMissing.of(), + @JsonProperty("gender") + @ExcludeMissing + private val gender: JsonField = JsonMissing.of(), + @JsonProperty("last_name") + @ExcludeMissing + private val lastName: JsonField = JsonMissing.of(), + @JsonProperty("middle_name") + @ExcludeMissing + private val middleName: JsonField = JsonMissing.of(), + @JsonProperty("phone_numbers") + @ExcludeMissing + private val phoneNumbers: JsonField> = JsonMissing.of(), + @JsonProperty("preferred_name") + @ExcludeMissing + private val preferredName: JsonField = JsonMissing.of(), + @JsonProperty("residence") + @ExcludeMissing + private val residence: JsonField = JsonMissing.of(), + @JsonProperty("ssn") @ExcludeMissing private val ssn: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("dob") fun dob(): Optional = Optional.ofNullable(dob) + fun dob(): Optional = Optional.ofNullable(dob.getNullable("dob")) - @JsonProperty("emails") fun emails(): Optional> = Optional.ofNullable(emails) + fun emails(): Optional> = Optional.ofNullable(emails.getNullable("emails")) + + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set + * in the body. + */ + fun encryptedSsn(): Optional = + Optional.ofNullable(encryptedSsn.getNullable("encrypted_ssn")) + + /** The EEOC-defined ethnicity of the individual. */ + fun ethnicity(): Optional = + Optional.ofNullable(ethnicity.getNullable("ethnicity")) + + /** The legal first name of the individual. */ + fun firstName(): Optional = Optional.ofNullable(firstName.getNullable("first_name")) + + /** The gender of the individual. */ + fun gender(): Optional = Optional.ofNullable(gender.getNullable("gender")) + + /** The legal last name of the individual. */ + fun lastName(): Optional = Optional.ofNullable(lastName.getNullable("last_name")) + + /** The legal middle name of the individual. */ + fun middleName(): Optional = + Optional.ofNullable(middleName.getNullable("middle_name")) + + fun phoneNumbers(): Optional> = + Optional.ofNullable(phoneNumbers.getNullable("phone_numbers")) + + /** The preferred name of the individual. */ + fun preferredName(): Optional = + Optional.ofNullable(preferredName.getNullable("preferred_name")) + + fun residence(): Optional = + Optional.ofNullable(residence.getNullable("residence")) + + /** + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun ssn(): Optional = Optional.ofNullable(ssn.getNullable("ssn")) + + @JsonProperty("dob") @ExcludeMissing fun _dob(): JsonField = dob + + @JsonProperty("emails") @ExcludeMissing fun _emails(): JsonField> = emails /** * Social Security Number of the individual in **encrypted** format. This field is only @@ -119,47 +226,70 @@ constructor( * in the body. */ @JsonProperty("encrypted_ssn") - fun encryptedSsn(): Optional = Optional.ofNullable(encryptedSsn) + @ExcludeMissing + fun _encryptedSsn(): JsonField = encryptedSsn /** The EEOC-defined ethnicity of the individual. */ @JsonProperty("ethnicity") - fun ethnicity(): Optional = Optional.ofNullable(ethnicity) + @ExcludeMissing + fun _ethnicity(): JsonField = ethnicity /** The legal first name of the individual. */ - @JsonProperty("first_name") - fun firstName(): Optional = Optional.ofNullable(firstName) + @JsonProperty("first_name") @ExcludeMissing fun _firstName(): JsonField = firstName /** The gender of the individual. */ - @JsonProperty("gender") fun gender(): Optional = Optional.ofNullable(gender) + @JsonProperty("gender") @ExcludeMissing fun _gender(): JsonField = gender /** The legal last name of the individual. */ - @JsonProperty("last_name") fun lastName(): Optional = Optional.ofNullable(lastName) + @JsonProperty("last_name") @ExcludeMissing fun _lastName(): JsonField = lastName /** The legal middle name of the individual. */ @JsonProperty("middle_name") - fun middleName(): Optional = Optional.ofNullable(middleName) + @ExcludeMissing + fun _middleName(): JsonField = middleName @JsonProperty("phone_numbers") - fun phoneNumbers(): Optional> = Optional.ofNullable(phoneNumbers) + @ExcludeMissing + fun _phoneNumbers(): JsonField> = phoneNumbers /** The preferred name of the individual. */ @JsonProperty("preferred_name") - fun preferredName(): Optional = Optional.ofNullable(preferredName) + @ExcludeMissing + fun _preferredName(): JsonField = preferredName - @JsonProperty("residence") - fun residence(): Optional = Optional.ofNullable(residence) + @JsonProperty("residence") @ExcludeMissing fun _residence(): JsonField = residence /** * Social Security Number of the individual. This field is only available with the `ssn` * scope enabled and the `options: { include: ['ssn'] }` param set in the body. * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). */ - @JsonProperty("ssn") fun ssn(): Optional = Optional.ofNullable(ssn) + @JsonProperty("ssn") @ExcludeMissing fun _ssn(): JsonField = ssn @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxIndividualUpdateBody = apply { + if (!validated) { + dob() + emails().map { it.forEach { it.validate() } } + encryptedSsn() + ethnicity() + firstName() + gender() + lastName() + middleName() + phoneNumbers().map { it.forEach { it?.validate() } } + preferredName() + residence().map { it.validate() } + ssn() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -169,31 +299,31 @@ constructor( class Builder { - private var dob: String? = null - private var emails: MutableList? = null - private var encryptedSsn: String? = null - private var ethnicity: Ethnicity? = null - private var firstName: String? = null - private var gender: Gender? = null - private var lastName: String? = null - private var middleName: String? = null - private var phoneNumbers: MutableList? = null - private var preferredName: String? = null - private var residence: Location? = null - private var ssn: String? = null + private var dob: JsonField = JsonMissing.of() + private var emails: JsonField>? = null + private var encryptedSsn: JsonField = JsonMissing.of() + private var ethnicity: JsonField = JsonMissing.of() + private var firstName: JsonField = JsonMissing.of() + private var gender: JsonField = JsonMissing.of() + private var lastName: JsonField = JsonMissing.of() + private var middleName: JsonField = JsonMissing.of() + private var phoneNumbers: JsonField>? = null + private var preferredName: JsonField = JsonMissing.of() + private var residence: JsonField = JsonMissing.of() + private var ssn: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(sandboxIndividualUpdateBody: SandboxIndividualUpdateBody) = apply { dob = sandboxIndividualUpdateBody.dob - emails = sandboxIndividualUpdateBody.emails?.toMutableList() + emails = sandboxIndividualUpdateBody.emails.map { it.toMutableList() } encryptedSsn = sandboxIndividualUpdateBody.encryptedSsn ethnicity = sandboxIndividualUpdateBody.ethnicity firstName = sandboxIndividualUpdateBody.firstName gender = sandboxIndividualUpdateBody.gender lastName = sandboxIndividualUpdateBody.lastName middleName = sandboxIndividualUpdateBody.middleName - phoneNumbers = sandboxIndividualUpdateBody.phoneNumbers?.toMutableList() + phoneNumbers = sandboxIndividualUpdateBody.phoneNumbers.map { it.toMutableList() } preferredName = sandboxIndividualUpdateBody.preferredName residence = sandboxIndividualUpdateBody.residence ssn = sandboxIndividualUpdateBody.ssn @@ -201,16 +331,31 @@ constructor( sandboxIndividualUpdateBody.additionalProperties.toMutableMap() } - fun dob(dob: String?) = apply { this.dob = dob } + fun dob(dob: String?) = dob(JsonField.ofNullable(dob)) fun dob(dob: Optional) = dob(dob.orElse(null)) - fun emails(emails: List?) = apply { this.emails = emails?.toMutableList() } + fun dob(dob: JsonField) = apply { this.dob = dob } + + fun emails(emails: List?) = emails(JsonField.ofNullable(emails)) fun emails(emails: Optional>) = emails(emails.orElse(null)) + fun emails(emails: JsonField>) = apply { + this.emails = emails.map { it.toMutableList() } + } + fun addEmail(email: Email) = apply { - emails = (emails ?: mutableListOf()).apply { add(email) } + emails = + (emails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(email) + } } /** @@ -218,7 +363,8 @@ constructor( * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param * set in the body. */ - fun encryptedSsn(encryptedSsn: String?) = apply { this.encryptedSsn = encryptedSsn } + fun encryptedSsn(encryptedSsn: String?) = + encryptedSsn(JsonField.ofNullable(encryptedSsn)) /** * Social Security Number of the individual in **encrypted** format. This field is only @@ -228,64 +374,108 @@ constructor( fun encryptedSsn(encryptedSsn: Optional) = encryptedSsn(encryptedSsn.orElse(null)) + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param + * set in the body. + */ + fun encryptedSsn(encryptedSsn: JsonField) = apply { + this.encryptedSsn = encryptedSsn + } + /** The EEOC-defined ethnicity of the individual. */ - fun ethnicity(ethnicity: Ethnicity?) = apply { this.ethnicity = ethnicity } + fun ethnicity(ethnicity: Ethnicity?) = ethnicity(JsonField.ofNullable(ethnicity)) /** The EEOC-defined ethnicity of the individual. */ fun ethnicity(ethnicity: Optional) = ethnicity(ethnicity.orElse(null)) + /** The EEOC-defined ethnicity of the individual. */ + fun ethnicity(ethnicity: JsonField) = apply { this.ethnicity = ethnicity } + /** The legal first name of the individual. */ - fun firstName(firstName: String?) = apply { this.firstName = firstName } + fun firstName(firstName: String?) = firstName(JsonField.ofNullable(firstName)) /** The legal first name of the individual. */ fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) + /** The legal first name of the individual. */ + fun firstName(firstName: JsonField) = apply { this.firstName = firstName } + /** The gender of the individual. */ - fun gender(gender: Gender?) = apply { this.gender = gender } + fun gender(gender: Gender?) = gender(JsonField.ofNullable(gender)) /** The gender of the individual. */ fun gender(gender: Optional) = gender(gender.orElse(null)) + /** The gender of the individual. */ + fun gender(gender: JsonField) = apply { this.gender = gender } + /** The legal last name of the individual. */ - fun lastName(lastName: String?) = apply { this.lastName = lastName } + fun lastName(lastName: String?) = lastName(JsonField.ofNullable(lastName)) /** The legal last name of the individual. */ fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) + /** The legal last name of the individual. */ + fun lastName(lastName: JsonField) = apply { this.lastName = lastName } + /** The legal middle name of the individual. */ - fun middleName(middleName: String?) = apply { this.middleName = middleName } + fun middleName(middleName: String?) = middleName(JsonField.ofNullable(middleName)) /** The legal middle name of the individual. */ fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) - fun phoneNumbers(phoneNumbers: List?) = apply { - this.phoneNumbers = phoneNumbers?.toMutableList() - } + /** The legal middle name of the individual. */ + fun middleName(middleName: JsonField) = apply { this.middleName = middleName } + + fun phoneNumbers(phoneNumbers: List?) = + phoneNumbers(JsonField.ofNullable(phoneNumbers)) fun phoneNumbers(phoneNumbers: Optional>) = phoneNumbers(phoneNumbers.orElse(null)) + fun phoneNumbers(phoneNumbers: JsonField>) = apply { + this.phoneNumbers = phoneNumbers.map { it.toMutableList() } + } + fun addPhoneNumber(phoneNumber: PhoneNumber) = apply { - phoneNumbers = (phoneNumbers ?: mutableListOf()).apply { add(phoneNumber) } + phoneNumbers = + (phoneNumbers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(phoneNumber) + } } /** The preferred name of the individual. */ - fun preferredName(preferredName: String?) = apply { this.preferredName = preferredName } + fun preferredName(preferredName: String?) = + preferredName(JsonField.ofNullable(preferredName)) /** The preferred name of the individual. */ fun preferredName(preferredName: Optional) = preferredName(preferredName.orElse(null)) - fun residence(residence: Location?) = apply { this.residence = residence } + /** The preferred name of the individual. */ + fun preferredName(preferredName: JsonField) = apply { + this.preferredName = preferredName + } + + fun residence(residence: Location?) = residence(JsonField.ofNullable(residence)) fun residence(residence: Optional) = residence(residence.orElse(null)) + fun residence(residence: JsonField) = apply { this.residence = residence } + /** * Social Security Number of the individual. This field is only available with the `ssn` * scope enabled and the `options: { include: ['ssn'] }` param set in the body. * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). */ - fun ssn(ssn: String?) = apply { this.ssn = ssn } + fun ssn(ssn: String?) = ssn(JsonField.ofNullable(ssn)) /** * Social Security Number of the individual. This field is only available with the `ssn` @@ -294,6 +484,13 @@ constructor( */ fun ssn(ssn: Optional) = ssn(ssn.orElse(null)) + /** + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun ssn(ssn: JsonField) = apply { this.ssn = ssn } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -316,14 +513,14 @@ constructor( fun build(): SandboxIndividualUpdateBody = SandboxIndividualUpdateBody( dob, - emails?.toImmutable(), + (emails ?: JsonMissing.of()).map { it.toImmutable() }, encryptedSsn, ethnicity, firstName, gender, lastName, middleName, - phoneNumbers?.toImmutable(), + (phoneNumbers ?: JsonMissing.of()).map { it.toImmutable() }, preferredName, residence, ssn, @@ -379,10 +576,14 @@ constructor( fun dob(dob: Optional) = dob(dob.orElse(null)) + fun dob(dob: JsonField) = apply { body.dob(dob) } + fun emails(emails: List?) = apply { body.emails(emails) } fun emails(emails: Optional>) = emails(emails.orElse(null)) + fun emails(emails: JsonField>) = apply { body.emails(emails) } + fun addEmail(email: Email) = apply { body.addEmail(email) } /** @@ -399,36 +600,60 @@ constructor( */ fun encryptedSsn(encryptedSsn: Optional) = encryptedSsn(encryptedSsn.orElse(null)) + /** + * Social Security Number of the individual in **encrypted** format. This field is only + * available with the `ssn` scope enabled and the `options: { include: ['ssn'] }` param set + * in the body. + */ + fun encryptedSsn(encryptedSsn: JsonField) = apply { + body.encryptedSsn(encryptedSsn) + } + /** The EEOC-defined ethnicity of the individual. */ fun ethnicity(ethnicity: Ethnicity?) = apply { body.ethnicity(ethnicity) } /** The EEOC-defined ethnicity of the individual. */ fun ethnicity(ethnicity: Optional) = ethnicity(ethnicity.orElse(null)) + /** The EEOC-defined ethnicity of the individual. */ + fun ethnicity(ethnicity: JsonField) = apply { body.ethnicity(ethnicity) } + /** The legal first name of the individual. */ fun firstName(firstName: String?) = apply { body.firstName(firstName) } /** The legal first name of the individual. */ fun firstName(firstName: Optional) = firstName(firstName.orElse(null)) + /** The legal first name of the individual. */ + fun firstName(firstName: JsonField) = apply { body.firstName(firstName) } + /** The gender of the individual. */ fun gender(gender: Gender?) = apply { body.gender(gender) } /** The gender of the individual. */ fun gender(gender: Optional) = gender(gender.orElse(null)) + /** The gender of the individual. */ + fun gender(gender: JsonField) = apply { body.gender(gender) } + /** The legal last name of the individual. */ fun lastName(lastName: String?) = apply { body.lastName(lastName) } /** The legal last name of the individual. */ fun lastName(lastName: Optional) = lastName(lastName.orElse(null)) + /** The legal last name of the individual. */ + fun lastName(lastName: JsonField) = apply { body.lastName(lastName) } + /** The legal middle name of the individual. */ fun middleName(middleName: String?) = apply { body.middleName(middleName) } /** The legal middle name of the individual. */ fun middleName(middleName: Optional) = middleName(middleName.orElse(null)) + /** The legal middle name of the individual. */ + fun middleName(middleName: JsonField) = apply { body.middleName(middleName) } + fun phoneNumbers(phoneNumbers: List?) = apply { body.phoneNumbers(phoneNumbers) } @@ -436,6 +661,10 @@ constructor( fun phoneNumbers(phoneNumbers: Optional>) = phoneNumbers(phoneNumbers.orElse(null)) + fun phoneNumbers(phoneNumbers: JsonField>) = apply { + body.phoneNumbers(phoneNumbers) + } + fun addPhoneNumber(phoneNumber: PhoneNumber) = apply { body.addPhoneNumber(phoneNumber) } /** The preferred name of the individual. */ @@ -445,10 +674,17 @@ constructor( fun preferredName(preferredName: Optional) = preferredName(preferredName.orElse(null)) + /** The preferred name of the individual. */ + fun preferredName(preferredName: JsonField) = apply { + body.preferredName(preferredName) + } + fun residence(residence: Location?) = apply { body.residence(residence) } fun residence(residence: Optional) = residence(residence.orElse(null)) + fun residence(residence: JsonField) = apply { body.residence(residence) } + /** * Social Security Number of the individual. This field is only available with the `ssn` * scope enabled and the `options: { include: ['ssn'] }` param set in the body. @@ -463,6 +699,32 @@ constructor( */ fun ssn(ssn: Optional) = ssn(ssn.orElse(null)) + /** + * Social Security Number of the individual. This field is only available with the `ssn` + * scope enabled and the `options: { include: ['ssn'] }` param set in the body. + * [Click here to learn more about enabling the SSN field](/developer-resources/Enable-SSN-Field). + */ + fun ssn(ssn: JsonField) = apply { body.ssn(ssn) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -561,25 +823,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxIndividualUpdateParams = SandboxIndividualUpdateParams( checkNotNull(individualId) { "`individualId` is required but was not set" }, @@ -593,20 +836,36 @@ constructor( class Email @JsonCreator private constructor( - @JsonProperty("data") private val data: String?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("data") fun data(): Optional = Optional.ofNullable(data) + fun data(): Optional = Optional.ofNullable(data.getNullable("data")) - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Email = apply { + if (!validated) { + data() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -616,8 +875,8 @@ constructor( class Builder { - private var data: String? = null - private var type: Type? = null + private var data: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -627,14 +886,16 @@ constructor( additionalProperties = email.additionalProperties.toMutableMap() } - fun data(data: String?) = apply { this.data = data } + fun data(data: String) = data(JsonField.of(data)) - fun data(data: Optional) = data(data.orElse(null)) + fun data(data: JsonField) = apply { this.data = data } - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.orElse(null)) + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -904,20 +1165,36 @@ constructor( class PhoneNumber @JsonCreator private constructor( - @JsonProperty("data") private val data: String?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("data") + @ExcludeMissing + private val data: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("data") fun data(): Optional = Optional.ofNullable(data) + fun data(): Optional = Optional.ofNullable(data.getNullable("data")) + + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data + + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PhoneNumber = apply { + if (!validated) { + data() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -927,8 +1204,8 @@ constructor( class Builder { - private var data: String? = null - private var type: Type? = null + private var data: JsonField = JsonMissing.of() + private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -938,14 +1215,16 @@ constructor( additionalProperties = phoneNumber.additionalProperties.toMutableMap() } - fun data(data: String?) = apply { this.data = data } + fun data(data: String) = data(JsonField.of(data)) - fun data(data: Optional) = data(data.orElse(null)) + fun data(data: JsonField) = apply { this.data = data } - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) fun type(type: Optional) = type(type.orElse(null)) + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfiguration.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfiguration.kt index 395bd5c9..3a260bdd 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfiguration.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfiguration.kt @@ -32,9 +32,11 @@ private constructor( fun type(): Type = type.getRequired("type") - @JsonProperty("completion_status") @ExcludeMissing fun _completionStatus() = completionStatus + @JsonProperty("completion_status") + @ExcludeMissing + fun _completionStatus(): JsonField = completionStatus - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -59,8 +61,8 @@ private constructor( class Builder { - private var completionStatus: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var completionStatus: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -102,8 +104,8 @@ private constructor( fun build(): SandboxJobConfiguration = SandboxJobConfiguration( - completionStatus, - type, + checkNotNull(completionStatus) { "`completionStatus` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParams.kt index 7a610a6c..0ccd3dcf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobConfigurationUpdateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -30,12 +31,16 @@ constructor( fun type(): Type = body.type() - fun _additionalHeaders(): Headers = additionalHeaders + fun _completionStatus(): JsonField = body._completionStatus() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _type(): JsonField = body._type() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SandboxJobConfigurationUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -46,21 +51,38 @@ constructor( class SandboxJobConfigurationUpdateBody @JsonCreator internal constructor( - @JsonProperty("completion_status") private val completionStatus: CompletionStatus, - @JsonProperty("type") private val type: Type, + @JsonProperty("completion_status") + @ExcludeMissing + private val completionStatus: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun completionStatus(): CompletionStatus = completionStatus.getRequired("completion_status") + + fun type(): Type = type.getRequired("type") + @JsonProperty("completion_status") - fun completionStatus(): CompletionStatus = completionStatus + @ExcludeMissing + fun _completionStatus(): JsonField = completionStatus - @JsonProperty("type") fun type(): Type = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxJobConfigurationUpdateBody = apply { + if (!validated) { + completionStatus() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -70,8 +92,8 @@ constructor( class Builder { - private var completionStatus: CompletionStatus? = null - private var type: Type? = null + private var completionStatus: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,11 +106,16 @@ constructor( sandboxJobConfigurationUpdateBody.additionalProperties.toMutableMap() } - fun completionStatus(completionStatus: CompletionStatus) = apply { + fun completionStatus(completionStatus: CompletionStatus) = + completionStatus(JsonField.of(completionStatus)) + + fun completionStatus(completionStatus: JsonField) = apply { this.completionStatus = completionStatus } - fun type(type: Type) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -166,8 +193,33 @@ constructor( body.completionStatus(completionStatus) } + fun completionStatus(completionStatus: JsonField) = apply { + body.completionStatus(completionStatus) + } + fun type(type: Type) = apply { body.type(type) } + fun type(type: JsonField) = apply { body.type(type) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -266,25 +318,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxJobConfigurationUpdateParams = SandboxJobConfigurationUpdateParams( body.build(), diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobCreateParams.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobCreateParams.kt index ea4ca54d..23c24cf8 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobCreateParams.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SandboxJobCreateParams.kt @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -29,12 +30,15 @@ constructor( /** The type of job to start. Currently the only supported type is `data_sync_all` */ fun type(): Type = body.type() + /** The type of job to start. Currently the only supported type is `data_sync_all` */ + fun _type(): JsonField = body._type() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): SandboxJobCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -45,18 +49,30 @@ constructor( class SandboxJobCreateBody @JsonCreator internal constructor( - @JsonProperty("type") private val type: Type, + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The type of job to start. Currently the only supported type is `data_sync_all` */ - @JsonProperty("type") fun type(): Type = type + fun type(): Type = type.getRequired("type") + + /** The type of job to start. Currently the only supported type is `data_sync_all` */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxJobCreateBody = apply { + if (!validated) { + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -66,7 +82,7 @@ constructor( class Builder { - private var type: Type? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -76,7 +92,10 @@ constructor( } /** The type of job to start. Currently the only supported type is `data_sync_all` */ - fun type(type: Type) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + /** The type of job to start. Currently the only supported type is `data_sync_all` */ + fun type(type: JsonField) = apply { this.type = type } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -146,6 +165,28 @@ constructor( /** The type of job to start. Currently the only supported type is `data_sync_all` */ fun type(type: Type) = apply { body.type(type) } + /** The type of job to start. Currently the only supported type is `data_sync_all` */ + fun type(type: JsonField) = apply { body.type(type) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -244,25 +285,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxJobCreateParams = SandboxJobCreateParams( body.build(), 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 2067bf79..3aefbc7b 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 @@ -9,6 +9,7 @@ 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.NoAutoDetect import com.tryfinch.api.core.http.Headers @@ -33,12 +34,18 @@ constructor( fun startDate(): Optional = body.startDate() - fun _additionalHeaders(): Headers = additionalHeaders + fun _endDate(): JsonField = body._endDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _payStatements(): JsonField> = body._payStatements() + + fun _startDate(): JsonField = body._startDate() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SandboxPaymentCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -53,25 +60,49 @@ constructor( class SandboxPaymentCreateBody @JsonCreator internal constructor( - @JsonProperty("end_date") private val endDate: String?, - @JsonProperty("pay_statements") private val payStatements: List?, - @JsonProperty("start_date") private val startDate: String?, + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("pay_statements") + @ExcludeMissing + private val payStatements: JsonField> = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("end_date") fun endDate(): Optional = Optional.ofNullable(endDate) + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + fun payStatements(): Optional> = + Optional.ofNullable(payStatements.getNullable("pay_statements")) + + fun startDate(): Optional = Optional.ofNullable(startDate.getNullable("start_date")) + + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("pay_statements") - fun payStatements(): Optional> = Optional.ofNullable(payStatements) + @ExcludeMissing + fun _payStatements(): JsonField> = payStatements - @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @JsonProperty("start_date") @ExcludeMissing fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SandboxPaymentCreateBody = apply { + if (!validated) { + endDate() + payStatements().map { it.forEach { it.validate() } } + startDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -81,37 +112,46 @@ constructor( class Builder { - private var endDate: String? = null - private var payStatements: MutableList? = null - private var startDate: String? = null + private var endDate: JsonField = JsonMissing.of() + private var payStatements: JsonField>? = null + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(sandboxPaymentCreateBody: SandboxPaymentCreateBody) = apply { endDate = sandboxPaymentCreateBody.endDate - payStatements = sandboxPaymentCreateBody.payStatements?.toMutableList() + payStatements = sandboxPaymentCreateBody.payStatements.map { it.toMutableList() } startDate = sandboxPaymentCreateBody.startDate additionalProperties = sandboxPaymentCreateBody.additionalProperties.toMutableMap() } - fun endDate(endDate: String?) = apply { this.endDate = endDate } + fun endDate(endDate: String) = endDate(JsonField.of(endDate)) - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - fun payStatements(payStatements: List?) = apply { - this.payStatements = payStatements?.toMutableList() - } + fun payStatements(payStatements: List) = + payStatements(JsonField.of(payStatements)) - fun payStatements(payStatements: Optional>) = - payStatements(payStatements.orElse(null)) + fun payStatements(payStatements: JsonField>) = apply { + this.payStatements = payStatements.map { it.toMutableList() } + } fun addPayStatement(payStatement: PayStatement) = apply { - payStatements = (payStatements ?: mutableListOf()).apply { add(payStatement) } + payStatements = + (payStatements ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(payStatement) + } } - fun startDate(startDate: String?) = apply { this.startDate = startDate } + fun startDate(startDate: String) = startDate(JsonField.of(startDate)) - fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -135,7 +175,7 @@ constructor( fun build(): SandboxPaymentCreateBody = SandboxPaymentCreateBody( endDate, - payStatements?.toImmutable(), + (payStatements ?: JsonMissing.of()).map { it.toImmutable() }, startDate, additionalProperties.toImmutable(), ) @@ -180,24 +220,44 @@ constructor( additionalQueryParams = sandboxPaymentCreateParams.additionalQueryParams.toBuilder() } - fun endDate(endDate: String?) = apply { body.endDate(endDate) } + fun endDate(endDate: String) = apply { body.endDate(endDate) } - fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } - fun payStatements(payStatements: List?) = apply { + fun payStatements(payStatements: List) = apply { body.payStatements(payStatements) } - fun payStatements(payStatements: Optional>) = - payStatements(payStatements.orElse(null)) + fun payStatements(payStatements: JsonField>) = apply { + body.payStatements(payStatements) + } fun addPayStatement(payStatement: PayStatement) = apply { body.addPayStatement(payStatement) } - fun startDate(startDate: String?) = apply { body.startDate(startDate) } + fun startDate(startDate: String) = apply { body.startDate(startDate) } - fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -297,25 +357,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SandboxPaymentCreateParams = SandboxPaymentCreateParams( body.build(), @@ -328,61 +369,133 @@ constructor( class PayStatement @JsonCreator private constructor( - @JsonProperty("earnings") private val earnings: List?, + @JsonProperty("earnings") + @ExcludeMissing + private val earnings: JsonField> = JsonMissing.of(), @JsonProperty("employee_deductions") - private val employeeDeductions: List?, + @ExcludeMissing + private val employeeDeductions: JsonField> = JsonMissing.of(), @JsonProperty("employer_contributions") - private val employerContributions: List?, - @JsonProperty("gross_pay") private val grossPay: Money?, - @JsonProperty("individual_id") private val individualId: String?, - @JsonProperty("net_pay") private val netPay: Money?, - @JsonProperty("payment_method") private val paymentMethod: PaymentMethod?, - @JsonProperty("taxes") private val taxes: List?, - @JsonProperty("total_hours") private val totalHours: Double?, - @JsonProperty("type") private val type: Type?, + @ExcludeMissing + private val employerContributions: JsonField> = + JsonMissing.of(), + @JsonProperty("gross_pay") + @ExcludeMissing + private val grossPay: JsonField = JsonMissing.of(), + @JsonProperty("individual_id") + @ExcludeMissing + private val individualId: JsonField = JsonMissing.of(), + @JsonProperty("net_pay") + @ExcludeMissing + private val netPay: JsonField = JsonMissing.of(), + @JsonProperty("payment_method") + @ExcludeMissing + private val paymentMethod: JsonField = JsonMissing.of(), + @JsonProperty("taxes") + @ExcludeMissing + private val taxes: JsonField> = JsonMissing.of(), + @JsonProperty("total_hours") + @ExcludeMissing + private val totalHours: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The array of earnings objects associated with this pay statement */ + fun earnings(): Optional> = + Optional.ofNullable(earnings.getNullable("earnings")) + + /** The array of deductions objects associated with this pay statement. */ + fun employeeDeductions(): Optional> = + Optional.ofNullable(employeeDeductions.getNullable("employee_deductions")) + + fun employerContributions(): Optional> = + Optional.ofNullable(employerContributions.getNullable("employer_contributions")) + + fun grossPay(): Optional = Optional.ofNullable(grossPay.getNullable("gross_pay")) + + /** A stable Finch `id` (UUID v4) for an individual in the company */ + fun individualId(): Optional = + Optional.ofNullable(individualId.getNullable("individual_id")) + + fun netPay(): Optional = Optional.ofNullable(netPay.getNullable("net_pay")) + + /** The payment method. */ + fun paymentMethod(): Optional = + Optional.ofNullable(paymentMethod.getNullable("payment_method")) + + /** The array of taxes objects associated with this pay statement. */ + fun taxes(): Optional> = Optional.ofNullable(taxes.getNullable("taxes")) + + /** The number of hours worked for this pay period */ + fun totalHours(): Optional = + Optional.ofNullable(totalHours.getNullable("total_hours")) + + /** The type of the payment associated with the pay statement. */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + /** The array of earnings objects associated with this pay statement */ @JsonProperty("earnings") - fun earnings(): Optional> = Optional.ofNullable(earnings) + @ExcludeMissing + fun _earnings(): JsonField> = earnings /** The array of deductions objects associated with this pay statement. */ @JsonProperty("employee_deductions") - fun employeeDeductions(): Optional> = - Optional.ofNullable(employeeDeductions) + @ExcludeMissing + fun _employeeDeductions(): JsonField> = employeeDeductions @JsonProperty("employer_contributions") - fun employerContributions(): Optional> = - Optional.ofNullable(employerContributions) + @ExcludeMissing + fun _employerContributions(): JsonField> = employerContributions - @JsonProperty("gross_pay") fun grossPay(): Optional = Optional.ofNullable(grossPay) + @JsonProperty("gross_pay") @ExcludeMissing fun _grossPay(): JsonField = grossPay /** A stable Finch `id` (UUID v4) for an individual in the company */ @JsonProperty("individual_id") - fun individualId(): Optional = Optional.ofNullable(individualId) + @ExcludeMissing + fun _individualId(): JsonField = individualId - @JsonProperty("net_pay") fun netPay(): Optional = Optional.ofNullable(netPay) + @JsonProperty("net_pay") @ExcludeMissing fun _netPay(): JsonField = netPay /** The payment method. */ @JsonProperty("payment_method") - fun paymentMethod(): Optional = Optional.ofNullable(paymentMethod) + @ExcludeMissing + fun _paymentMethod(): JsonField = paymentMethod /** The array of taxes objects associated with this pay statement. */ - @JsonProperty("taxes") fun taxes(): Optional> = Optional.ofNullable(taxes) + @JsonProperty("taxes") @ExcludeMissing fun _taxes(): JsonField> = taxes /** The number of hours worked for this pay period */ @JsonProperty("total_hours") - fun totalHours(): Optional = Optional.ofNullable(totalHours) + @ExcludeMissing + fun _totalHours(): JsonField = totalHours /** The type of the payment associated with the pay statement. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PayStatement = apply { + if (!validated) { + earnings().map { it.forEach { it?.validate() } } + employeeDeductions().map { it.forEach { it?.validate() } } + employerContributions().map { it.forEach { it?.validate() } } + grossPay().map { it.validate() } + individualId() + netPay().map { it.validate() } + paymentMethod() + taxes().map { it.forEach { it?.validate() } } + totalHours() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -392,109 +505,173 @@ constructor( class Builder { - private var earnings: MutableList? = null - private var employeeDeductions: MutableList? = null - private var employerContributions: MutableList? = null - private var grossPay: Money? = null - private var individualId: String? = null - private var netPay: Money? = null - private var paymentMethod: PaymentMethod? = null - private var taxes: MutableList? = null - private var totalHours: Double? = null - private var type: Type? = null + 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?.toMutableList() - employeeDeductions = payStatement.employeeDeductions?.toMutableList() - employerContributions = payStatement.employerContributions?.toMutableList() + 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?.toMutableList() + 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?) = apply { - this.earnings = earnings?.toMutableList() - } + fun earnings(earnings: List?) = earnings(JsonField.ofNullable(earnings)) /** The array of earnings objects associated with this pay statement */ fun earnings(earnings: Optional>) = earnings(earnings.orElse(null)) + /** The array of earnings objects associated with this pay statement */ + fun earnings(earnings: JsonField>) = apply { + this.earnings = earnings.map { it.toMutableList() } + } + /** The array of earnings objects associated with this pay statement */ fun addEarning(earning: Earning) = apply { - earnings = (earnings ?: mutableListOf()).apply { add(earning) } + earnings = + (earnings ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(earning) + } } /** The array of deductions objects associated with this pay statement. */ - fun employeeDeductions(employeeDeductions: List?) = apply { - this.employeeDeductions = employeeDeductions?.toMutableList() - } + fun employeeDeductions(employeeDeductions: List?) = + employeeDeductions(JsonField.ofNullable(employeeDeductions)) /** The array of deductions objects associated with this pay statement. */ fun employeeDeductions(employeeDeductions: Optional>) = employeeDeductions(employeeDeductions.orElse(null)) + /** The array of deductions objects associated with this pay statement. */ + fun employeeDeductions(employeeDeductions: JsonField>) = + apply { + this.employeeDeductions = employeeDeductions.map { it.toMutableList() } + } + /** The array of deductions objects associated with this pay statement. */ fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { employeeDeductions = - (employeeDeductions ?: mutableListOf()).apply { add(employeeDeduction) } + (employeeDeductions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(employeeDeduction) + } } - fun employerContributions(employerContributions: List?) = apply { - this.employerContributions = employerContributions?.toMutableList() - } + fun employerContributions(employerContributions: List?) = + employerContributions(JsonField.ofNullable(employerContributions)) fun employerContributions( employerContributions: Optional> ) = employerContributions(employerContributions.orElse(null)) + fun employerContributions( + employerContributions: JsonField> + ) = apply { + this.employerContributions = employerContributions.map { it.toMutableList() } + } + fun addEmployerContribution(employerContribution: EmployerContribution) = apply { employerContributions = - (employerContributions ?: mutableListOf()).apply { add(employerContribution) } + (employerContributions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(employerContribution) + } } - fun grossPay(grossPay: Money?) = apply { this.grossPay = grossPay } + fun grossPay(grossPay: Money?) = grossPay(JsonField.ofNullable(grossPay)) fun grossPay(grossPay: Optional) = grossPay(grossPay.orElse(null)) + fun grossPay(grossPay: JsonField) = apply { this.grossPay = grossPay } + /** A stable Finch `id` (UUID v4) for an individual in the company */ - fun individualId(individualId: String?) = apply { this.individualId = individualId } + fun individualId(individualId: String) = individualId(JsonField.of(individualId)) /** A stable Finch `id` (UUID v4) for an individual in the company */ - fun individualId(individualId: Optional) = - individualId(individualId.orElse(null)) + fun individualId(individualId: JsonField) = apply { + this.individualId = individualId + } - fun netPay(netPay: Money?) = apply { this.netPay = netPay } + fun netPay(netPay: Money?) = netPay(JsonField.ofNullable(netPay)) fun netPay(netPay: Optional) = netPay(netPay.orElse(null)) + fun netPay(netPay: JsonField) = apply { this.netPay = netPay } + /** The payment method. */ - fun paymentMethod(paymentMethod: PaymentMethod?) = apply { - this.paymentMethod = paymentMethod - } + fun paymentMethod(paymentMethod: PaymentMethod?) = + paymentMethod(JsonField.ofNullable(paymentMethod)) /** The payment method. */ fun paymentMethod(paymentMethod: Optional) = paymentMethod(paymentMethod.orElse(null)) + /** The payment method. */ + fun paymentMethod(paymentMethod: JsonField) = apply { + this.paymentMethod = paymentMethod + } + /** The array of taxes objects associated with this pay statement. */ - fun taxes(taxes: List?) = apply { this.taxes = taxes?.toMutableList() } + fun taxes(taxes: List?) = taxes(JsonField.ofNullable(taxes)) /** The array of taxes objects associated with this pay statement. */ fun taxes(taxes: Optional>) = taxes(taxes.orElse(null)) /** The array of taxes objects associated with this pay statement. */ - fun addTax(tax: Tax) = apply { taxes = (taxes ?: mutableListOf()).apply { add(tax) } } + fun taxes(taxes: JsonField>) = apply { + this.taxes = taxes.map { it.toMutableList() } + } + + /** The array of taxes objects associated with this pay statement. */ + fun addTax(tax: Tax) = apply { + taxes = + (taxes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tax) + } + } /** The number of hours worked for this pay period */ - fun totalHours(totalHours: Double?) = apply { this.totalHours = totalHours } + fun totalHours(totalHours: Double?) = totalHours(JsonField.ofNullable(totalHours)) /** The number of hours worked for this pay period */ fun totalHours(totalHours: Double) = totalHours(totalHours as Double?) @@ -504,12 +681,18 @@ constructor( fun totalHours(totalHours: Optional) = totalHours(totalHours.orElse(null) as Double?) + /** The number of hours worked for this pay period */ + fun totalHours(totalHours: JsonField) = apply { this.totalHours = totalHours } + /** The type of the payment associated with the pay statement. */ - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) /** The type of the payment associated with the pay statement. */ fun type(type: Optional) = type(type.orElse(null)) + /** The type of the payment associated with the pay statement. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -531,14 +714,14 @@ constructor( fun build(): PayStatement = PayStatement( - earnings?.toImmutable(), - employeeDeductions?.toImmutable(), - employerContributions?.toImmutable(), + (earnings ?: JsonMissing.of()).map { it.toImmutable() }, + (employeeDeductions ?: JsonMissing.of()).map { it.toImmutable() }, + (employerContributions ?: JsonMissing.of()).map { it.toImmutable() }, grossPay, individualId, netPay, paymentMethod, - taxes?.toImmutable(), + (taxes ?: JsonMissing.of()).map { it.toImmutable() }, totalHours, type, additionalProperties.toImmutable(), @@ -549,38 +732,78 @@ constructor( class Earning @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Long?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("hours") private val hours: Double?, - @JsonProperty("name") private val name: String?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("hours") + @ExcludeMissing + private val hours: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The earnings amount in cents. */ - @JsonProperty("amount") fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) /** The earnings currency code. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("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(): Optional = Optional.ofNullable(hours.getNullable("hours")) + + /** The exact name of the deduction from the pay statement. */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** The type of earning. */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** The earnings amount in cents. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The earnings currency code. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = 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). */ - @JsonProperty("hours") fun hours(): Optional = Optional.ofNullable(hours) + @JsonProperty("hours") @ExcludeMissing fun _hours(): JsonField = hours /** The exact name of the deduction from the pay statement. */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The type of earning. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Earning = apply { + if (!validated) { + amount() + currency() + hours() + name() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -590,11 +813,11 @@ constructor( class Builder { - private var amount: Long? = null - private var currency: String? = null - private var hours: Double? = null - private var name: String? = null - private var type: Type? = null + private var amount: 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 @@ -608,7 +831,7 @@ constructor( } /** The earnings amount in cents. */ - fun amount(amount: Long?) = apply { this.amount = amount } + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) /** The earnings amount in cents. */ fun amount(amount: Long) = amount(amount as Long?) @@ -617,17 +840,23 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) + /** The earnings amount in cents. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + /** The earnings currency code. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** The earnings currency code. */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** The earnings currency code. */ + 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?) = apply { this.hours = hours } + fun hours(hours: Double?) = hours(JsonField.ofNullable(hours)) /** * The number of hours associated with this earning. (For salaried employees, this @@ -642,18 +871,30 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun hours(hours: Optional) = hours(hours.orElse(null) as Double?) + /** + * 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: JsonField) = apply { this.hours = hours } + /** The exact name of the deduction from the pay statement. */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The exact name of the deduction from the pay statement. */ fun name(name: Optional) = name(name.orElse(null)) + /** The exact name of the deduction from the pay statement. */ + fun name(name: JsonField) = apply { this.name = name } + /** The type of earning. */ - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) /** The type of earning. */ fun type(type: Optional) = type(type.orElse(null)) + /** The type of earning. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -832,35 +1073,72 @@ constructor( class EmployeeDeduction @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Long?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("name") private val name: String?, - @JsonProperty("pre_tax") private val preTax: Boolean?, - @JsonProperty("type") private val type: BenefitType?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("pre_tax") + @ExcludeMissing + private val preTax: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The deduction amount in cents. */ - @JsonProperty("amount") fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) /** The deduction currency. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** The deduction name from the pay statement. */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** Boolean indicating if the deduction is pre-tax. */ - @JsonProperty("pre_tax") fun preTax(): Optional = Optional.ofNullable(preTax) + fun preTax(): Optional = Optional.ofNullable(preTax.getNullable("pre_tax")) /** Type of benefit. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** The deduction amount in cents. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The deduction currency. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The deduction name from the pay statement. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** Boolean indicating if the deduction is pre-tax. */ + @JsonProperty("pre_tax") @ExcludeMissing fun _preTax(): JsonField = preTax + + /** Type of benefit. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EmployeeDeduction = apply { + if (!validated) { + amount() + currency() + name() + preTax() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -870,11 +1148,11 @@ constructor( class Builder { - private var amount: Long? = null - private var currency: String? = null - private var name: String? = null - private var preTax: Boolean? = null - private var type: BenefitType? = null + private var amount: 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 @@ -888,7 +1166,7 @@ constructor( } /** The deduction amount in cents. */ - fun amount(amount: Long?) = apply { this.amount = amount } + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) /** The deduction amount in cents. */ fun amount(amount: Long) = amount(amount as Long?) @@ -897,20 +1175,29 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) + /** The deduction amount in cents. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + /** The deduction currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** The deduction currency. */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** The deduction currency. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** The deduction name from the pay statement. */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The deduction name from the pay statement. */ fun name(name: Optional) = name(name.orElse(null)) + /** The deduction name from the pay statement. */ + fun name(name: JsonField) = apply { this.name = name } + /** Boolean indicating if the deduction is pre-tax. */ - fun preTax(preTax: Boolean?) = apply { this.preTax = preTax } + fun preTax(preTax: Boolean?) = preTax(JsonField.ofNullable(preTax)) /** Boolean indicating if the deduction is pre-tax. */ fun preTax(preTax: Boolean) = preTax(preTax as Boolean?) @@ -919,12 +1206,18 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun preTax(preTax: Optional) = preTax(preTax.orElse(null) as Boolean?) + /** Boolean indicating if the deduction is pre-tax. */ + fun preTax(preTax: JsonField) = apply { this.preTax = preTax } + /** Type of benefit. */ - fun type(type: BenefitType?) = apply { this.type = type } + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) /** Type of benefit. */ fun type(type: Optional) = type(type.orElse(null)) + /** Type of benefit. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -980,31 +1273,62 @@ constructor( class EmployerContribution @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Long?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("name") private val name: String?, - @JsonProperty("type") private val type: BenefitType?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The contribution amount in cents. */ - @JsonProperty("amount") fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) /** The contribution currency. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** The contribution name from the pay statement. */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** Type of benefit. */ + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** The contribution amount in cents. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The contribution currency. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The contribution name from the pay statement. */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Type of benefit. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EmployerContribution = apply { + if (!validated) { + amount() + currency() + name() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1014,10 +1338,10 @@ constructor( class Builder { - private var amount: Long? = null - private var currency: String? = null - private var name: String? = null - private var type: BenefitType? = null + private var amount: 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 @@ -1030,7 +1354,7 @@ constructor( } /** The contribution amount in cents. */ - fun amount(amount: Long?) = apply { this.amount = amount } + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) /** The contribution amount in cents. */ fun amount(amount: Long) = amount(amount as Long?) @@ -1039,24 +1363,36 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) + /** The contribution amount in cents. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + /** The contribution currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** The contribution currency. */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** The contribution currency. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** The contribution name from the pay statement. */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The contribution name from the pay statement. */ fun name(name: Optional) = name(name.orElse(null)) + /** The contribution name from the pay statement. */ + fun name(name: JsonField) = apply { this.name = name } + /** Type of benefit. */ - fun type(type: BenefitType?) = apply { this.type = type } + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) /** Type of benefit. */ fun type(type: Optional) = type(type.orElse(null)) + /** Type of benefit. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1168,36 +1504,73 @@ constructor( class Tax @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Long?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("employer") private val employer: Boolean?, - @JsonProperty("name") private val name: String?, - @JsonProperty("type") private val type: Type?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("employer") + @ExcludeMissing + private val employer: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("type") + @ExcludeMissing + private val type: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The tax amount in cents. */ - @JsonProperty("amount") fun amount(): Optional = Optional.ofNullable(amount) + fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) /** The currency code. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** `true` if the amount is paid by the employers. */ - @JsonProperty("employer") - fun employer(): Optional = Optional.ofNullable(employer) + fun employer(): Optional = + Optional.ofNullable(employer.getNullable("employer")) /** The exact name of tax from the pay statement. */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** The type of taxes. */ - @JsonProperty("type") fun type(): Optional = Optional.ofNullable(type) + fun type(): Optional = Optional.ofNullable(type.getNullable("type")) + + /** The tax amount in cents. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The currency code. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** `true` if the amount is paid by the employers. */ + @JsonProperty("employer") @ExcludeMissing fun _employer(): JsonField = employer + + /** The exact name of tax from the pay statement. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The type of taxes. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tax = apply { + if (!validated) { + amount() + currency() + employer() + name() + type() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1207,11 +1580,11 @@ constructor( class Builder { - private var amount: Long? = null - private var currency: String? = null - private var employer: Boolean? = null - private var name: String? = null - private var type: Type? = null + private var amount: 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 @@ -1225,7 +1598,7 @@ constructor( } /** The tax amount in cents. */ - fun amount(amount: Long?) = apply { this.amount = amount } + fun amount(amount: Long?) = amount(JsonField.ofNullable(amount)) /** The tax amount in cents. */ fun amount(amount: Long) = amount(amount as Long?) @@ -1234,14 +1607,20 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun amount(amount: Optional) = amount(amount.orElse(null) as Long?) + /** The tax amount in cents. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + /** The currency code. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** The currency code. */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** The currency code. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** `true` if the amount is paid by the employers. */ - fun employer(employer: Boolean?) = apply { this.employer = employer } + fun employer(employer: Boolean?) = employer(JsonField.ofNullable(employer)) /** `true` if the amount is paid by the employers. */ fun employer(employer: Boolean) = employer(employer as Boolean?) @@ -1251,18 +1630,27 @@ constructor( fun employer(employer: Optional) = employer(employer.orElse(null) as Boolean?) + /** `true` if the amount is paid by the employers. */ + fun employer(employer: JsonField) = apply { this.employer = employer } + /** The exact name of tax from the pay statement. */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The exact name of tax from the pay statement. */ fun name(name: Optional) = name(name.orElse(null)) + /** The exact name of tax from the pay statement. */ + fun name(name: JsonField) = apply { this.name = name } + /** The type of taxes. */ - fun type(type: Type?) = apply { this.type = type } + fun type(type: Type?) = type(JsonField.ofNullable(type)) /** The type of taxes. */ fun type(type: Optional) = type(type.orElse(null)) + /** The type of taxes. */ + fun type(type: JsonField) = apply { this.type = type } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionNewResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionNewResponse.kt index d9f50133..9a9624c4 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionNewResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionNewResponse.kt @@ -35,10 +35,10 @@ private constructor( fun sessionId(): String = sessionId.getRequired("session_id") /** The Connect URL to redirect the user to for authentication */ - @JsonProperty("connect_url") @ExcludeMissing fun _connectUrl() = connectUrl + @JsonProperty("connect_url") @ExcludeMissing fun _connectUrl(): JsonField = connectUrl /** The unique identifier for the created connect session */ - @JsonProperty("session_id") @ExcludeMissing fun _sessionId() = sessionId + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId @JsonAnyGetter @ExcludeMissing @@ -63,8 +63,8 @@ private constructor( class Builder { - private var connectUrl: JsonField = JsonMissing.of() - private var sessionId: JsonField = JsonMissing.of() + private var connectUrl: JsonField? = null + private var sessionId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -107,8 +107,8 @@ private constructor( fun build(): SessionNewResponse = SessionNewResponse( - connectUrl, - sessionId, + checkNotNull(connectUrl) { "`connectUrl` is required but was not set" }, + checkNotNull(sessionId) { "`sessionId` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionReauthenticateResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionReauthenticateResponse.kt index 5cbb526d..0de2251e 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionReauthenticateResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SessionReauthenticateResponse.kt @@ -35,10 +35,10 @@ private constructor( fun sessionId(): String = sessionId.getRequired("session_id") /** The Connect URL to redirect the user to for reauthentication */ - @JsonProperty("connect_url") @ExcludeMissing fun _connectUrl() = connectUrl + @JsonProperty("connect_url") @ExcludeMissing fun _connectUrl(): JsonField = connectUrl /** The unique identifier for the created connect session */ - @JsonProperty("session_id") @ExcludeMissing fun _sessionId() = sessionId + @JsonProperty("session_id") @ExcludeMissing fun _sessionId(): JsonField = sessionId @JsonAnyGetter @ExcludeMissing @@ -63,8 +63,8 @@ private constructor( class Builder { - private var connectUrl: JsonField = JsonMissing.of() - private var sessionId: JsonField = JsonMissing.of() + private var connectUrl: JsonField? = null + private var sessionId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -107,8 +107,8 @@ private constructor( fun build(): SessionReauthenticateResponse = SessionReauthenticateResponse( - connectUrl, - sessionId, + checkNotNull(connectUrl) { "`connectUrl` is required but was not set" }, + checkNotNull(sessionId) { "`sessionId` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportPerBenefitType.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportPerBenefitType.kt index 7cb4d5fa..48530069 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportPerBenefitType.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportPerBenefitType.kt @@ -35,11 +35,13 @@ private constructor( fun individualBenefits(): Optional = Optional.ofNullable(individualBenefits.getNullable("individual_benefits")) - @JsonProperty("company_benefits") @ExcludeMissing fun _companyBenefits() = companyBenefits + @JsonProperty("company_benefits") + @ExcludeMissing + fun _companyBenefits(): JsonField = companyBenefits @JsonProperty("individual_benefits") @ExcludeMissing - fun _individualBenefits() = individualBenefits + fun _individualBenefits(): JsonField = individualBenefits @JsonAnyGetter @ExcludeMissing diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt index 8fba0666..34cf0cd6 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/SupportedBenefit.kt @@ -85,26 +85,32 @@ private constructor( fun type(): Optional = Optional.ofNullable(type.getNullable("type")) /** Whether the provider supports an annual maximum for this benefit. */ - @JsonProperty("annual_maximum") @ExcludeMissing fun _annualMaximum() = annualMaximum + @JsonProperty("annual_maximum") + @ExcludeMissing + fun _annualMaximum(): JsonField = annualMaximum /** * Whether the provider supports catch up for this benefit. This field will only be true for * retirement benefits. */ - @JsonProperty("catch_up") @ExcludeMissing fun _catchUp() = catchUp + @JsonProperty("catch_up") @ExcludeMissing fun _catchUp(): JsonField = catchUp /** Supported contribution types. An empty array indicates contributions are not supported. */ @JsonProperty("company_contribution") @ExcludeMissing - fun _companyContribution() = companyContribution + fun _companyContribution(): JsonField> = companyContribution - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** Supported deduction types. An empty array indicates deductions are not supported. */ - @JsonProperty("employee_deduction") @ExcludeMissing fun _employeeDeduction() = employeeDeduction + @JsonProperty("employee_deduction") + @ExcludeMissing + fun _employeeDeduction(): JsonField> = employeeDeduction /** The list of frequencies supported by the provider for this benefit */ - @JsonProperty("frequencies") @ExcludeMissing fun _frequencies() = frequencies + @JsonProperty("frequencies") + @ExcludeMissing + fun _frequencies(): JsonField> = frequencies /** * Whether the provider supports HSA contribution limits. Empty if this feature is not supported @@ -112,10 +118,10 @@ private constructor( */ @JsonProperty("hsa_contribution_limit") @ExcludeMissing - fun _hsaContributionLimit() = hsaContributionLimit + fun _hsaContributionLimit(): JsonField> = hsaContributionLimit /** Type of benefit. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -148,11 +154,11 @@ private constructor( private var annualMaximum: JsonField = JsonMissing.of() private var catchUp: JsonField = JsonMissing.of() - private var companyContribution: JsonField> = JsonMissing.of() + private var companyContribution: JsonField>? = null private var description: JsonField = JsonMissing.of() - private var employeeDeduction: JsonField> = JsonMissing.of() - private var frequencies: JsonField> = JsonMissing.of() - private var hsaContributionLimit: JsonField> = JsonMissing.of() + private var employeeDeduction: JsonField>? = null + private var frequencies: JsonField>? = null + private var hsaContributionLimit: JsonField>? = null private var type: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -160,17 +166,26 @@ private constructor( internal fun from(supportedBenefit: SupportedBenefit) = apply { annualMaximum = supportedBenefit.annualMaximum catchUp = supportedBenefit.catchUp - companyContribution = supportedBenefit.companyContribution + companyContribution = supportedBenefit.companyContribution.map { it.toMutableList() } description = supportedBenefit.description - employeeDeduction = supportedBenefit.employeeDeduction - frequencies = supportedBenefit.frequencies - hsaContributionLimit = supportedBenefit.hsaContributionLimit + employeeDeduction = supportedBenefit.employeeDeduction.map { it.toMutableList() } + frequencies = supportedBenefit.frequencies.map { it.toMutableList() } + hsaContributionLimit = supportedBenefit.hsaContributionLimit.map { it.toMutableList() } type = supportedBenefit.type additionalProperties = supportedBenefit.additionalProperties.toMutableMap() } /** Whether the provider supports an annual maximum for this benefit. */ - fun annualMaximum(annualMaximum: Boolean) = annualMaximum(JsonField.of(annualMaximum)) + fun annualMaximum(annualMaximum: Boolean?) = + annualMaximum(JsonField.ofNullable(annualMaximum)) + + /** Whether the provider supports an annual maximum for this benefit. */ + fun annualMaximum(annualMaximum: Boolean) = annualMaximum(annualMaximum as Boolean?) + + /** Whether the provider supports an annual maximum for this benefit. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun annualMaximum(annualMaximum: Optional) = + annualMaximum(annualMaximum.orElse(null) as Boolean?) /** Whether the provider supports an annual maximum for this benefit. */ fun annualMaximum(annualMaximum: JsonField) = apply { @@ -181,7 +196,20 @@ private constructor( * Whether the provider supports catch up for this benefit. This field will only be true for * retirement benefits. */ - fun catchUp(catchUp: Boolean) = catchUp(JsonField.of(catchUp)) + fun catchUp(catchUp: Boolean?) = catchUp(JsonField.ofNullable(catchUp)) + + /** + * Whether the provider supports catch up for this benefit. This field will only be true for + * retirement benefits. + */ + fun catchUp(catchUp: Boolean) = catchUp(catchUp as Boolean?) + + /** + * Whether the provider supports catch up for this benefit. This field will only be true for + * retirement benefits. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun catchUp(catchUp: Optional) = catchUp(catchUp.orElse(null) as Boolean?) /** * Whether the provider supports catch up for this benefit. This field will only be true for @@ -192,28 +220,70 @@ private constructor( /** * Supported contribution types. An empty array indicates contributions are not supported. */ - fun companyContribution(companyContribution: List) = - companyContribution(JsonField.of(companyContribution)) + fun companyContribution(companyContribution: List?) = + companyContribution(JsonField.ofNullable(companyContribution)) + + /** + * Supported contribution types. An empty array indicates contributions are not supported. + */ + fun companyContribution(companyContribution: Optional>) = + companyContribution(companyContribution.orElse(null)) /** * Supported contribution types. An empty array indicates contributions are not supported. */ fun companyContribution(companyContribution: JsonField>) = apply { - this.companyContribution = companyContribution + this.companyContribution = companyContribution.map { it.toMutableList() } } - fun description(description: String) = description(JsonField.of(description)) + /** + * Supported contribution types. An empty array indicates contributions are not supported. + */ + fun addCompanyContribution(companyContribution: CompanyContribution) = apply { + this.companyContribution = + (this.companyContribution ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(companyContribution) + } + } + + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) 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.of(employeeDeduction)) + fun employeeDeduction(employeeDeduction: List?) = + employeeDeduction(JsonField.ofNullable(employeeDeduction)) + + /** Supported deduction types. An empty array indicates deductions are not supported. */ + fun employeeDeduction(employeeDeduction: Optional>) = + employeeDeduction(employeeDeduction.orElse(null)) /** Supported deduction types. An empty array indicates deductions are not supported. */ fun employeeDeduction(employeeDeduction: JsonField>) = apply { - this.employeeDeduction = employeeDeduction + this.employeeDeduction = employeeDeduction.map { it.toMutableList() } + } + + /** Supported deduction types. An empty array indicates deductions are not supported. */ + fun addEmployeeDeduction(employeeDeduction: EmployeeDeduction) = apply { + this.employeeDeduction = + (this.employeeDeduction ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(employeeDeduction) + } } /** The list of frequencies supported by the provider for this benefit */ @@ -222,15 +292,36 @@ private constructor( /** The list of frequencies supported by the provider for this benefit */ fun frequencies(frequencies: JsonField>) = apply { - this.frequencies = frequencies + this.frequencies = frequencies.map { it.toMutableList() } + } + + /** The list of frequencies supported by the provider for this benefit */ + fun addFrequency(frequency: BenefitFrequency) = apply { + frequencies = + (frequencies ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .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.of(hsaContributionLimit)) + fun hsaContributionLimit(hsaContributionLimit: List?) = + hsaContributionLimit(JsonField.ofNullable(hsaContributionLimit)) + + /** + * 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: Optional>) = + hsaContributionLimit(hsaContributionLimit.orElse(null)) /** * Whether the provider supports HSA contribution limits. Empty if this feature is not @@ -238,11 +329,31 @@ private constructor( */ fun hsaContributionLimit(hsaContributionLimit: JsonField>) = apply { - this.hsaContributionLimit = hsaContributionLimit + this.hsaContributionLimit = hsaContributionLimit.map { it.toMutableList() } } + /** + * 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 addHsaContributionLimit(hsaContributionLimit: HsaContributionLimit) = apply { + this.hsaContributionLimit = + (this.hsaContributionLimit ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(hsaContributionLimit) + } + } + + /** Type of benefit. */ + fun type(type: BenefitType?) = type(JsonField.ofNullable(type)) + /** Type of benefit. */ - fun type(type: BenefitType) = type(JsonField.of(type)) + fun type(type: Optional) = type(type.orElse(null)) /** Type of benefit. */ fun type(type: JsonField) = apply { this.type = type } @@ -270,11 +381,11 @@ private constructor( SupportedBenefit( annualMaximum, catchUp, - companyContribution.map { it.toImmutable() }, + (companyContribution ?: JsonMissing.of()).map { it.toImmutable() }, description, - employeeDeduction.map { it.toImmutable() }, - frequencies.map { it.toImmutable() }, - hsaContributionLimit.map { it.toImmutable() }, + (employeeDeduction ?: JsonMissing.of()).map { it.toImmutable() }, + (frequencies ?: JsonMissing.of()).map { it.toImmutable() }, + (hsaContributionLimit ?: JsonMissing.of()).map { it.toImmutable() }, type, additionalProperties.toImmutable(), ) diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt index d381cf19..4902ebb5 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UnenrolledIndividual.kt @@ -36,12 +36,14 @@ private constructor( fun individualId(): Optional = Optional.ofNullable(individualId.getNullable("individual_id")) - @JsonProperty("body") @ExcludeMissing fun _body() = body + @JsonProperty("body") @ExcludeMissing fun _body(): JsonField = body /** HTTP status code */ - @JsonProperty("code") @ExcludeMissing fun _code() = code + @JsonProperty("code") @ExcludeMissing fun _code(): JsonField = code - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId @JsonAnyGetter @ExcludeMissing @@ -151,13 +153,13 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) /** A descriptive identifier for the response. */ - @JsonProperty("finch_code") @ExcludeMissing fun _finchCode() = finchCode + @JsonProperty("finch_code") @ExcludeMissing fun _finchCode(): JsonField = finchCode /** Short description in English that provides more information about the response. */ - @JsonProperty("message") @ExcludeMissing fun _message() = message + @JsonProperty("message") @ExcludeMissing fun _message(): JsonField = message /** Identifier indicating whether the benefit was newly enrolled or updated. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -197,19 +199,28 @@ private constructor( } /** A descriptive identifier for the response. */ - fun finchCode(finchCode: String) = finchCode(JsonField.of(finchCode)) + fun finchCode(finchCode: String?) = finchCode(JsonField.ofNullable(finchCode)) + + /** A descriptive identifier for the response. */ + fun finchCode(finchCode: Optional) = finchCode(finchCode.orElse(null)) /** A descriptive identifier for the response. */ fun finchCode(finchCode: JsonField) = apply { this.finchCode = finchCode } /** Short description in English that provides more information about the response. */ - fun message(message: String) = message(JsonField.of(message)) + fun message(message: String?) = message(JsonField.ofNullable(message)) + + /** Short description in English that provides more information about the response. */ + fun message(message: Optional) = message(message.orElse(null)) /** Short description in English that provides more information about the response. */ fun message(message: JsonField) = apply { this.message = message } /** Identifier indicating whether the benefit was newly enrolled or updated. */ - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + /** Identifier indicating whether the benefit was newly enrolled or updated. */ + fun name(name: Optional) = name(name.orElse(null)) /** Identifier indicating whether the benefit was newly enrolled or updated. */ fun name(name: JsonField) = apply { this.name = name } diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt index c039218a..e6f3e0ad 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/UpdateCompanyBenefitResponse.kt @@ -27,7 +27,7 @@ private constructor( fun benefitId(): String = benefitId.getRequired("benefit_id") - @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId() = benefitId + @JsonProperty("benefit_id") @ExcludeMissing fun _benefitId(): JsonField = benefitId @JsonAnyGetter @ExcludeMissing @@ -51,7 +51,7 @@ private constructor( class Builder { - private var benefitId: JsonField = JsonMissing.of() + private var benefitId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,7 +84,10 @@ private constructor( } fun build(): UpdateCompanyBenefitResponse = - UpdateCompanyBenefitResponse(benefitId, additionalProperties.toImmutable()) + UpdateCompanyBenefitResponse( + checkNotNull(benefitId) { "`benefitId` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42005.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42005.kt index fb83cef0..6cdb84bf 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42005.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42005.kt @@ -42,13 +42,13 @@ private constructor( fun year(): Optional = Optional.ofNullable(year.getNullable("year")) /** Detailed information specific to the 2005 W4 form. */ - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data /** Specifies the form type, indicating that this document is a 2005 W4 form. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The tax year this W4 document applies to. */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -100,7 +100,14 @@ private constructor( fun type(type: JsonField) = apply { this.type = type } /** The tax year this W4 document applies to. */ - fun year(year: Double) = year(JsonField.of(year)) + fun year(year: Double?) = year(JsonField.ofNullable(year)) + + /** The tax year this W4 document applies to. */ + fun year(year: Double) = year(year as Double?) + + /** The tax year this W4 document applies to. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Double?) /** The tax year this W4 document applies to. */ fun year(year: JsonField) = apply { this.year = year } @@ -180,21 +187,27 @@ private constructor( /** Additional withholding amount (in cents). */ @JsonProperty("additional_withholding") @ExcludeMissing - fun _additionalWithholding() = additionalWithholding + fun _additionalWithholding(): JsonField = additionalWithholding /** Indicates exemption status from federal tax withholding. */ - @JsonProperty("exemption") @ExcludeMissing fun _exemption() = exemption + @JsonProperty("exemption") + @ExcludeMissing + fun _exemption(): JsonField = exemption /** The individual's filing status for tax purposes. */ - @JsonProperty("filing_status") @ExcludeMissing fun _filingStatus() = filingStatus + @JsonProperty("filing_status") + @ExcludeMissing + fun _filingStatus(): JsonField = filingStatus /** The unique identifier for the individual associated with this 2005 W4 form. */ - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId /** Total number of allowances claimed (in cents). */ @JsonProperty("total_number_of_allowances") @ExcludeMissing - fun _totalNumberOfAllowances() = totalNumberOfAllowances + fun _totalNumberOfAllowances(): JsonField = totalNumberOfAllowances @JsonAnyGetter @ExcludeMissing @@ -239,9 +252,18 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } + /** Additional withholding amount (in cents). */ + fun additionalWithholding(additionalWithholding: Long?) = + additionalWithholding(JsonField.ofNullable(additionalWithholding)) + /** Additional withholding amount (in cents). */ fun additionalWithholding(additionalWithholding: Long) = - additionalWithholding(JsonField.of(additionalWithholding)) + additionalWithholding(additionalWithholding as Long?) + + /** Additional withholding amount (in cents). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun additionalWithholding(additionalWithholding: Optional) = + additionalWithholding(additionalWithholding.orElse(null) as Long?) /** Additional withholding amount (in cents). */ fun additionalWithholding(additionalWithholding: JsonField) = apply { @@ -270,9 +292,18 @@ private constructor( this.individualId = individualId } + /** Total number of allowances claimed (in cents). */ + fun totalNumberOfAllowances(totalNumberOfAllowances: Long?) = + totalNumberOfAllowances(JsonField.ofNullable(totalNumberOfAllowances)) + /** Total number of allowances claimed (in cents). */ fun totalNumberOfAllowances(totalNumberOfAllowances: Long) = - totalNumberOfAllowances(JsonField.of(totalNumberOfAllowances)) + totalNumberOfAllowances(totalNumberOfAllowances as Long?) + + /** Total number of allowances claimed (in cents). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun totalNumberOfAllowances(totalNumberOfAllowances: Optional) = + totalNumberOfAllowances(totalNumberOfAllowances.orElse(null) as Long?) /** Total number of allowances claimed (in cents). */ fun totalNumberOfAllowances(totalNumberOfAllowances: JsonField) = apply { diff --git a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42020.kt b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42020.kt index 499da6a8..7314afca 100644 --- a/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42020.kt +++ b/finch-java-core/src/main/kotlin/com/tryfinch/api/models/W42020.kt @@ -42,13 +42,13 @@ private constructor( fun year(): Optional = Optional.ofNullable(year.getNullable("year")) /** Detailed information specific to the 2020 W4 form. */ - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField = data /** Specifies the form type, indicating that this document is a 2020 W4 form. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The tax year this W4 document applies to. */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -100,7 +100,14 @@ private constructor( fun type(type: JsonField) = apply { this.type = type } /** The tax year this W4 document applies to. */ - fun year(year: Double) = year(JsonField.of(year)) + fun year(year: Double?) = year(JsonField.ofNullable(year)) + + /** The tax year this W4 document applies to. */ + fun year(year: Double) = year(year as Double?) + + /** The tax year this W4 document applies to. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Double?) /** The tax year this W4 document applies to. */ fun year(year: JsonField) = apply { this.year = year } @@ -208,34 +215,42 @@ private constructor( /** Amount claimed for dependents other than qualifying children under 17 (in cents). */ @JsonProperty("amount_for_other_dependents") @ExcludeMissing - fun _amountForOtherDependents() = amountForOtherDependents + fun _amountForOtherDependents(): JsonField = amountForOtherDependents /** Amount claimed for dependents under 17 years old (in cents). */ @JsonProperty("amount_for_qualifying_children_under_17") @ExcludeMissing - fun _amountForQualifyingChildrenUnder17() = amountForQualifyingChildrenUnder17 + fun _amountForQualifyingChildrenUnder17(): JsonField = + amountForQualifyingChildrenUnder17 /** Deductible expenses (in cents). */ - @JsonProperty("deductions") @ExcludeMissing fun _deductions() = deductions + @JsonProperty("deductions") @ExcludeMissing fun _deductions(): JsonField = deductions /** Additional withholding amount (in cents). */ @JsonProperty("extra_withholding") @ExcludeMissing - fun _extraWithholding() = extraWithholding + fun _extraWithholding(): JsonField = extraWithholding /** The individual's filing status for tax purposes. */ - @JsonProperty("filing_status") @ExcludeMissing fun _filingStatus() = filingStatus + @JsonProperty("filing_status") + @ExcludeMissing + fun _filingStatus(): JsonField = filingStatus /** The unique identifier for the individual associated with this document. */ - @JsonProperty("individual_id") @ExcludeMissing fun _individualId() = individualId + @JsonProperty("individual_id") + @ExcludeMissing + fun _individualId(): JsonField = individualId /** Additional income from sources outside of primary employment (in cents). */ - @JsonProperty("other_income") @ExcludeMissing fun _otherIncome() = otherIncome + @JsonProperty("other_income") + @ExcludeMissing + fun _otherIncome(): JsonField = otherIncome /** Total amount claimed for dependents and other credits (in cents). */ @JsonProperty("total_claim_dependent_and_other_credits") @ExcludeMissing - fun _totalClaimDependentAndOtherCredits() = totalClaimDependentAndOtherCredits + fun _totalClaimDependentAndOtherCredits(): JsonField = + totalClaimDependentAndOtherCredits @JsonAnyGetter @ExcludeMissing @@ -289,18 +304,42 @@ private constructor( additionalProperties = data.additionalProperties.toMutableMap() } + /** Amount claimed for dependents other than qualifying children under 17 (in cents). */ + fun amountForOtherDependents(amountForOtherDependents: Long?) = + amountForOtherDependents(JsonField.ofNullable(amountForOtherDependents)) + /** Amount claimed for dependents other than qualifying children under 17 (in cents). */ fun amountForOtherDependents(amountForOtherDependents: Long) = - amountForOtherDependents(JsonField.of(amountForOtherDependents)) + amountForOtherDependents(amountForOtherDependents as Long?) + + /** Amount claimed for dependents other than qualifying children under 17 (in cents). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amountForOtherDependents(amountForOtherDependents: Optional) = + amountForOtherDependents(amountForOtherDependents.orElse(null) as Long?) /** Amount claimed for dependents other than qualifying children under 17 (in cents). */ fun amountForOtherDependents(amountForOtherDependents: JsonField) = apply { this.amountForOtherDependents = amountForOtherDependents } + /** Amount claimed for dependents under 17 years old (in cents). */ + fun amountForQualifyingChildrenUnder17(amountForQualifyingChildrenUnder17: Long?) = + amountForQualifyingChildrenUnder17( + JsonField.ofNullable(amountForQualifyingChildrenUnder17) + ) + /** Amount claimed for dependents under 17 years old (in cents). */ fun amountForQualifyingChildrenUnder17(amountForQualifyingChildrenUnder17: Long) = - amountForQualifyingChildrenUnder17(JsonField.of(amountForQualifyingChildrenUnder17)) + amountForQualifyingChildrenUnder17(amountForQualifyingChildrenUnder17 as Long?) + + /** Amount claimed for dependents under 17 years old (in cents). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun amountForQualifyingChildrenUnder17( + amountForQualifyingChildrenUnder17: Optional + ) = + amountForQualifyingChildrenUnder17( + amountForQualifyingChildrenUnder17.orElse(null) as Long? + ) /** Amount claimed for dependents under 17 years old (in cents). */ fun amountForQualifyingChildrenUnder17( @@ -310,14 +349,31 @@ private constructor( } /** Deductible expenses (in cents). */ - fun deductions(deductions: Long) = deductions(JsonField.of(deductions)) + fun deductions(deductions: Long?) = deductions(JsonField.ofNullable(deductions)) + + /** Deductible expenses (in cents). */ + fun deductions(deductions: Long) = deductions(deductions as Long?) + + /** Deductible expenses (in cents). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun deductions(deductions: Optional) = + deductions(deductions.orElse(null) as Long?) /** Deductible expenses (in cents). */ fun deductions(deductions: JsonField) = apply { this.deductions = deductions } + /** Additional withholding amount (in cents). */ + fun extraWithholding(extraWithholding: Long?) = + extraWithholding(JsonField.ofNullable(extraWithholding)) + /** Additional withholding amount (in cents). */ fun extraWithholding(extraWithholding: Long) = - extraWithholding(JsonField.of(extraWithholding)) + extraWithholding(extraWithholding as Long?) + + /** Additional withholding amount (in cents). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun extraWithholding(extraWithholding: Optional) = + extraWithholding(extraWithholding.orElse(null) as Long?) /** Additional withholding amount (in cents). */ fun extraWithholding(extraWithholding: JsonField) = apply { @@ -325,7 +381,12 @@ private constructor( } /** The individual's filing status for tax purposes. */ - fun filingStatus(filingStatus: FilingStatus) = filingStatus(JsonField.of(filingStatus)) + fun filingStatus(filingStatus: FilingStatus?) = + filingStatus(JsonField.ofNullable(filingStatus)) + + /** The individual's filing status for tax purposes. */ + fun filingStatus(filingStatus: Optional) = + filingStatus(filingStatus.orElse(null)) /** The individual's filing status for tax purposes. */ fun filingStatus(filingStatus: JsonField) = apply { @@ -341,14 +402,37 @@ private constructor( } /** Additional income from sources outside of primary employment (in cents). */ - fun otherIncome(otherIncome: Long) = otherIncome(JsonField.of(otherIncome)) + fun otherIncome(otherIncome: Long?) = otherIncome(JsonField.ofNullable(otherIncome)) + + /** Additional income from sources outside of primary employment (in cents). */ + fun otherIncome(otherIncome: Long) = otherIncome(otherIncome as Long?) + + /** Additional income from sources outside of primary employment (in cents). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun otherIncome(otherIncome: Optional) = + otherIncome(otherIncome.orElse(null) as Long?) /** Additional income from sources outside of primary employment (in cents). */ fun otherIncome(otherIncome: JsonField) = apply { this.otherIncome = otherIncome } + /** Total amount claimed for dependents and other credits (in cents). */ + fun totalClaimDependentAndOtherCredits(totalClaimDependentAndOtherCredits: Long?) = + totalClaimDependentAndOtherCredits( + JsonField.ofNullable(totalClaimDependentAndOtherCredits) + ) + /** Total amount claimed for dependents and other credits (in cents). */ fun totalClaimDependentAndOtherCredits(totalClaimDependentAndOtherCredits: Long) = - totalClaimDependentAndOtherCredits(JsonField.of(totalClaimDependentAndOtherCredits)) + totalClaimDependentAndOtherCredits(totalClaimDependentAndOtherCredits as Long?) + + /** Total amount claimed for dependents and other credits (in cents). */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun totalClaimDependentAndOtherCredits( + totalClaimDependentAndOtherCredits: Optional + ) = + totalClaimDependentAndOtherCredits( + totalClaimDependentAndOtherCredits.orElse(null) as Long? + ) /** Total amount claimed for dependents and other credits (in cents). */ fun totalClaimDependentAndOtherCredits( diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardParamsTest.kt index 9c384e5e..7cf03bd5 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/RequestForwardingForwardParamsTest.kt @@ -13,6 +13,7 @@ class RequestForwardingForwardParamsTest { RequestForwardingForwardParams.builder() .method("POST") .route("/people/search") + .data(null) .headers(JsonValue.from(mapOf("content-type" to "application/json"))) .params(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) .build() @@ -24,6 +25,7 @@ class RequestForwardingForwardParamsTest { RequestForwardingForwardParams.builder() .method("POST") .route("/people/search") + .data(null) .headers(JsonValue.from(mapOf("content-type" to "application/json"))) .params(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) .build() @@ -31,10 +33,11 @@ class RequestForwardingForwardParamsTest { assertThat(body).isNotNull assertThat(body.method()).isEqualTo("POST") assertThat(body.route()).isEqualTo("/people/search") - assertThat(body.headers()) - .contains(JsonValue.from(mapOf("content-type" to "application/json"))) - assertThat(body.params()) - .contains(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) + assertThat(body.data()).isEmpty + assertThat(body._headers()) + .isEqualTo(JsonValue.from(mapOf("content-type" to "application/json"))) + assertThat(body._params()) + .isEqualTo(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) } @Test diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt index 78f95dbe..451fe763 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/models/SandboxCompanyUpdateParamsTest.kt @@ -169,8 +169,28 @@ class SandboxCompanyUpdateParamsTest { @Test fun getBodyWithoutOptionalFields() { - val params = SandboxCompanyUpdateParams.builder().build() + val params = + SandboxCompanyUpdateParams.builder() + .accounts(listOf(SandboxCompanyUpdateParams.Account.builder().build())) + .departments(listOf(SandboxCompanyUpdateParams.Department.builder().build())) + .ein("ein") + .entity(SandboxCompanyUpdateParams.Entity.builder().build()) + .legalName("legal_name") + .locations(listOf(Location.builder().build())) + .primaryEmail("primary_email") + .primaryPhoneNumber("primary_phone_number") + .build() val body = params.getBody() assertThat(body).isNotNull + assertThat(body.accounts()) + .contains(listOf(SandboxCompanyUpdateParams.Account.builder().build())) + assertThat(body.departments()) + .contains(listOf(SandboxCompanyUpdateParams.Department.builder().build())) + assertThat(body.ein()).contains("ein") + assertThat(body.entity()).contains(SandboxCompanyUpdateParams.Entity.builder().build()) + assertThat(body.legalName()).contains("legal_name") + assertThat(body.locations()).contains(listOf(Location.builder().build())) + assertThat(body.primaryEmail()).contains("primary_email") + assertThat(body.primaryPhoneNumber()).contains("primary_phone_number") } } diff --git a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceTest.kt b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceTest.kt index 2e70f732..86c16c24 100644 --- a/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceTest.kt +++ b/finch-java-core/src/test/kotlin/com/tryfinch/api/services/blocking/RequestForwardingServiceTest.kt @@ -25,6 +25,7 @@ class RequestForwardingServiceTest { RequestForwardingForwardParams.builder() .method("POST") .route("/people/search") + .data(null) .headers(JsonValue.from(mapOf("content-type" to "application/json"))) .params(JsonValue.from(mapOf("showInactive" to true, "humanReadable" to true))) .build() From 75e1dfd7cb81654e68221e8426d8d4d27ce8b6e6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:04:01 +0000 Subject: [PATCH 2/3] chore(internal): codegen related update (#389) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d69de054..345a709b 100644 --- a/README.md +++ b/README.md @@ -369,7 +369,7 @@ $ export FINCH_LOG=debug This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions: -1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_. +1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_ 2. Changes that we do not expect to impact the vast majority of users in practice. We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. From 27f9b56cfe85d68251e4c1e438add973cf02e827 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 8 Jan 2025 15:04:39 +0000 Subject: [PATCH 3/3] release: 3.2.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ README.md | 6 +++--- build.gradle.kts | 2 +- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 89c23bac..1f73031b 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.1.1" + ".": "3.2.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 524d097e..9b31127e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## 3.2.0 (2025-01-08) + +Full Changelog: [v3.1.1...v3.2.0](https://github.com/Finch-API/finch-api-java/compare/v3.1.1...v3.2.0) + +### Features + +* **client:** add various convenience setters to models ([#387](https://github.com/Finch-API/finch-api-java/issues/387)) ([051f37d](https://github.com/Finch-API/finch-api-java/commit/051f37d5ce901f5a05797d50dad3fc177a893012)) +* **client:** allow setting arbitrary JSON for top-level body params ([051f37d](https://github.com/Finch-API/finch-api-java/commit/051f37d5ce901f5a05797d50dad3fc177a893012)) +* **client:** expose getters for `JsonField` of body params ([051f37d](https://github.com/Finch-API/finch-api-java/commit/051f37d5ce901f5a05797d50dad3fc177a893012)) + + +### Bug Fixes + +* **client:** consistently throw on omitting required fields ([051f37d](https://github.com/Finch-API/finch-api-java/commit/051f37d5ce901f5a05797d50dad3fc177a893012)) +* **client:** convert `JsonField` containing list type to mutable in builder ([051f37d](https://github.com/Finch-API/finch-api-java/commit/051f37d5ce901f5a05797d50dad3fc177a893012)) + + +### Chores + +* **internal:** codegen related update ([#389](https://github.com/Finch-API/finch-api-java/issues/389)) ([75e1dfd](https://github.com/Finch-API/finch-api-java/commit/75e1dfd7cb81654e68221e8426d8d4d27ce8b6e6)) + + +### Styles + +* **internal:** explicitly add some method return types ([051f37d](https://github.com/Finch-API/finch-api-java/commit/051f37d5ce901f5a05797d50dad3fc177a893012)) +* **internal:** move headers and query params setters below others ([051f37d](https://github.com/Finch-API/finch-api-java/commit/051f37d5ce901f5a05797d50dad3fc177a893012)) +* **internal:** simplify existing convenience setters on params ([051f37d](https://github.com/Finch-API/finch-api-java/commit/051f37d5ce901f5a05797d50dad3fc177a893012)) + ## 3.1.1 (2025-01-07) Full Changelog: [v3.1.0...v3.1.1](https://github.com/Finch-API/finch-api-java/compare/v3.1.0...v3.1.1) diff --git a/README.md b/README.md index 345a709b..4850869b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/3.1.1) +[![Maven Central](https://img.shields.io/maven-central/v/com.tryfinch.api/finch-java)](https://central.sonatype.com/artifact/com.tryfinch.api/finch-java/3.2.0) @@ -27,7 +27,7 @@ The REST API documentation can be foundĀ [in the Finch Documentation Center](htt ```kotlin -implementation("com.tryfinch.api:finch-java:3.1.1") +implementation("com.tryfinch.api:finch-java:3.2.0") ``` #### Maven @@ -36,7 +36,7 @@ implementation("com.tryfinch.api:finch-java:3.1.1") com.tryfinch.api finch-java - 3.1.1 + 3.2.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 23a67a69..61e2ae01 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { allprojects { group = "com.tryfinch.api" - version = "3.1.1" // x-release-please-version + version = "3.2.0" // x-release-please-version }