From ba43250d4cee150fd036a99329898a01e5defdef Mon Sep 17 00:00:00 2001 From: Stainless Bot Date: Wed, 20 Nov 2024 00:20:07 +0000 Subject: [PATCH] feat(client): add methods for header params --- .../models/FinancialAccountCreateParams.kt | 22 +++++++++++++++---- .../FinancialAccountCreateParamsTest.kt | 2 ++ .../blocking/FinancialAccountServiceTest.kt | 1 + 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreateParams.kt index 5ea5dcf76..c8e5151c7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreateParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/FinancialAccountCreateParams.kt @@ -26,6 +26,7 @@ constructor( private val type: Type, private val accountToken: String?, private val isForBenefitOf: Boolean?, + private val idempotencyKey: String?, private val additionalHeaders: Headers, private val additionalQueryParams: QueryParams, private val additionalBodyProperties: Map, @@ -39,6 +40,8 @@ constructor( fun isForBenefitOf(): Optional = Optional.ofNullable(isForBenefitOf) + fun idempotencyKey(): Optional = Optional.ofNullable(idempotencyKey) + @JvmSynthetic internal fun getBody(): FinancialAccountCreateBody { return FinancialAccountCreateBody( @@ -50,7 +53,13 @@ constructor( ) } - @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders + @JvmSynthetic + internal fun getHeaders(): Headers { + val headers = Headers.builder() + this.idempotencyKey?.let { headers.put("Idempotency-Key", listOf(it.toString())) } + headers.putAll(additionalHeaders) + return headers.build() + } @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams @@ -170,15 +179,15 @@ constructor( return true } - return /* spotless:off */ other is FinancialAccountCreateParams && this.nickname == other.nickname && this.type == other.type && this.accountToken == other.accountToken && this.isForBenefitOf == other.isForBenefitOf && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ + return /* spotless:off */ other is FinancialAccountCreateParams && this.nickname == other.nickname && this.type == other.type && this.accountToken == other.accountToken && this.isForBenefitOf == other.isForBenefitOf && this.idempotencyKey == other.idempotencyKey && this.additionalHeaders == other.additionalHeaders && this.additionalQueryParams == other.additionalQueryParams && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */ } override fun hashCode(): Int { - return /* spotless:off */ Objects.hash(nickname, type, accountToken, isForBenefitOf, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ + return /* spotless:off */ Objects.hash(nickname, type, accountToken, isForBenefitOf, idempotencyKey, additionalHeaders, additionalQueryParams, additionalBodyProperties) /* spotless:on */ } override fun toString() = - "FinancialAccountCreateParams{nickname=$nickname, type=$type, accountToken=$accountToken, isForBenefitOf=$isForBenefitOf, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" + "FinancialAccountCreateParams{nickname=$nickname, type=$type, accountToken=$accountToken, isForBenefitOf=$isForBenefitOf, idempotencyKey=$idempotencyKey, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" fun toBuilder() = Builder().from(this) @@ -194,6 +203,7 @@ constructor( private var type: Type? = null private var accountToken: String? = null private var isForBenefitOf: Boolean? = null + private var idempotencyKey: String? = null private var additionalHeaders: Headers.Builder = Headers.builder() private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() private var additionalBodyProperties: MutableMap = mutableMapOf() @@ -204,6 +214,7 @@ constructor( this.type = financialAccountCreateParams.type this.accountToken = financialAccountCreateParams.accountToken this.isForBenefitOf = financialAccountCreateParams.isForBenefitOf + this.idempotencyKey = financialAccountCreateParams.idempotencyKey additionalHeaders(financialAccountCreateParams.additionalHeaders) additionalQueryParams(financialAccountCreateParams.additionalQueryParams) additionalBodyProperties(financialAccountCreateParams.additionalBodyProperties) @@ -217,6 +228,8 @@ constructor( fun isForBenefitOf(isForBenefitOf: Boolean) = apply { this.isForBenefitOf = isForBenefitOf } + fun idempotencyKey(idempotencyKey: String) = apply { this.idempotencyKey = idempotencyKey } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -343,6 +356,7 @@ constructor( checkNotNull(type) { "`type` is required but was not set" }, accountToken, isForBenefitOf, + idempotencyKey, additionalHeaders.build(), additionalQueryParams.build(), additionalBodyProperties.toImmutable(), diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreateParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreateParamsTest.kt index 57c5162e0..9f681c60e 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreateParamsTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/FinancialAccountCreateParamsTest.kt @@ -15,6 +15,7 @@ class FinancialAccountCreateParamsTest { .type(FinancialAccountCreateParams.Type.OPERATING) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .isForBenefitOf(true) + .idempotencyKey("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() } @@ -26,6 +27,7 @@ class FinancialAccountCreateParamsTest { .type(FinancialAccountCreateParams.Type.OPERATING) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .isForBenefitOf(true) + .idempotencyKey("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() val body = params.getBody() assertThat(body).isNotNull diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceTest.kt index a4dc3c6bc..1cd09253a 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/FinancialAccountServiceTest.kt @@ -27,6 +27,7 @@ class FinancialAccountServiceTest { .type(FinancialAccountCreateParams.Type.OPERATING) .accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .isForBenefitOf(true) + .idempotencyKey("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") .build() ) println(financialAccount)