From 421c44a12d3fbd141ae1f197cdd55eb95431582d Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 22:30:12 +0000 Subject: [PATCH 1/2] feat(api): api update --- .stats.yml | 8 +- ...rdAuthenticationChallengeAttemptsParams.kt | 455 ++++++ .../CardAuthenticationChallengesParams.kt | 249 ++++ .../CardAuthenticationCreateParams.kt | 1258 +++++++++++++++++ .../services/async/SimulationServiceAsync.kt | 5 + .../async/SimulationServiceAsyncImpl.kt | 15 + .../CardAuthenticationServiceAsync.kt | 220 +++ .../CardAuthenticationServiceAsyncImpl.kt | 186 +++ .../services/blocking/SimulationService.kt | 5 + .../blocking/SimulationServiceImpl.kt | 15 + .../simulations/CardAuthenticationService.kt | 222 +++ .../CardAuthenticationServiceImpl.kt | 172 +++ ...thenticationChallengeAttemptsParamsTest.kt | 43 + .../CardAuthenticationChallengesParamsTest.kt | 28 + .../CardAuthenticationCreateParamsTest.kt | 60 + .../CardAuthenticationServiceAsyncTest.kt | 78 + .../CardAuthenticationServiceTest.kt | 74 + 17 files changed, 3089 insertions(+), 4 deletions(-) create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengeAttemptsParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengesParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationCreateParams.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsync.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsyncImpl.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationService.kt create mode 100644 increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationServiceImpl.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengeAttemptsParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengesParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationCreateParamsTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsyncTest.kt create mode 100644 increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationServiceTest.kt diff --git a/.stats.yml b/.stats.yml index 8a9805b70..464498e14 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 232 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-fc32a84f69e813f34ad70b65dba1ac56957f3c69361935f50df26caadaae3fce.yml -openapi_spec_hash: 40b5bd3cc33a7002c1a6f36fe97377ef -config_hash: b881baa4e0bc537d0caf02152712bd28 +configured_endpoints: 235 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-e9d1e51ce8416b747bc7ee664bb2c2e2095e2c5e49bad9e3a9c9657f3fed5994.yml +openapi_spec_hash: db0318b3db534a5982ab89666b2e0117 +config_hash: 463c5cf7a7f13cf7db270b287814b56c diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengeAttemptsParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengeAttemptsParams.kt new file mode 100644 index 000000000..703f35513 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengeAttemptsParams.kt @@ -0,0 +1,455 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.cardauthentications + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.increase.api.core.ExcludeMissing +import com.increase.api.core.JsonField +import com.increase.api.core.JsonMissing +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.checkRequired +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.errors.IncreaseInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Simulates an attempt at a Card Authentication Challenge. This updates the `card_authentications` + * object under the [Card Payment](#card_payments). You can also attempt the challenge by navigating + * to https://dashboard.increase.com/card_authentication_simulation/:card_payment_id. + */ +class CardAuthenticationChallengeAttemptsParams +private constructor( + private val cardPaymentId: String?, + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** The identifier of the Card Payment to be challenged. */ + fun cardPaymentId(): Optional = Optional.ofNullable(cardPaymentId) + + /** + * The one-time code to be validated. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun oneTimeCode(): String = body.oneTimeCode() + + /** + * Returns the raw JSON value of [oneTimeCode]. + * + * Unlike [oneTimeCode], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _oneTimeCode(): JsonField = body._oneTimeCode() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CardAuthenticationChallengeAttemptsParams]. + * + * The following fields are required: + * ```java + * .oneTimeCode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardAuthenticationChallengeAttemptsParams]. */ + class Builder internal constructor() { + + private var cardPaymentId: String? = null + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from( + cardAuthenticationChallengeAttemptsParams: CardAuthenticationChallengeAttemptsParams + ) = apply { + cardPaymentId = cardAuthenticationChallengeAttemptsParams.cardPaymentId + body = cardAuthenticationChallengeAttemptsParams.body.toBuilder() + additionalHeaders = + cardAuthenticationChallengeAttemptsParams.additionalHeaders.toBuilder() + additionalQueryParams = + cardAuthenticationChallengeAttemptsParams.additionalQueryParams.toBuilder() + } + + /** The identifier of the Card Payment to be challenged. */ + fun cardPaymentId(cardPaymentId: String?) = apply { this.cardPaymentId = cardPaymentId } + + /** Alias for calling [Builder.cardPaymentId] with `cardPaymentId.orElse(null)`. */ + fun cardPaymentId(cardPaymentId: Optional) = + cardPaymentId(cardPaymentId.getOrNull()) + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [oneTimeCode] + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The one-time code to be validated. */ + fun oneTimeCode(oneTimeCode: String) = apply { body.oneTimeCode(oneTimeCode) } + + /** + * Sets [Builder.oneTimeCode] to an arbitrary JSON value. + * + * You should usually call [Builder.oneTimeCode] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun oneTimeCode(oneTimeCode: JsonField) = apply { body.oneTimeCode(oneTimeCode) } + + 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) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardAuthenticationChallengeAttemptsParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .oneTimeCode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardAuthenticationChallengeAttemptsParams = + CardAuthenticationChallengeAttemptsParams( + cardPaymentId, + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardPaymentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val oneTimeCode: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("one_time_code") + @ExcludeMissing + oneTimeCode: JsonField = JsonMissing.of() + ) : this(oneTimeCode, mutableMapOf()) + + /** + * The one-time code to be validated. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun oneTimeCode(): String = oneTimeCode.getRequired("one_time_code") + + /** + * Returns the raw JSON value of [oneTimeCode]. + * + * Unlike [oneTimeCode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("one_time_code") + @ExcludeMissing + fun _oneTimeCode(): JsonField = oneTimeCode + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .oneTimeCode() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var oneTimeCode: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + oneTimeCode = body.oneTimeCode + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The one-time code to be validated. */ + fun oneTimeCode(oneTimeCode: String) = oneTimeCode(JsonField.of(oneTimeCode)) + + /** + * Sets [Builder.oneTimeCode] to an arbitrary JSON value. + * + * You should usually call [Builder.oneTimeCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun oneTimeCode(oneTimeCode: JsonField) = apply { + this.oneTimeCode = oneTimeCode + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .oneTimeCode() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body(checkRequired("oneTimeCode", oneTimeCode), additionalProperties.toMutableMap()) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + oneTimeCode() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = (if (oneTimeCode.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + oneTimeCode == other.oneTimeCode && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(oneTimeCode, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{oneTimeCode=$oneTimeCode, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardAuthenticationChallengeAttemptsParams && + cardPaymentId == other.cardPaymentId && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = + Objects.hash(cardPaymentId, body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardAuthenticationChallengeAttemptsParams{cardPaymentId=$cardPaymentId, body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengesParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengesParams.kt new file mode 100644 index 000000000..42fcf99fc --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengesParams.kt @@ -0,0 +1,249 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.cardauthentications + +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.core.toImmutable +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Simulates starting a Card Authentication Challenge for an existing Card Authentication. This + * updates the `card_authentications` object under the [Card Payment](#card_payments). To attempt + * the challenge, use the `/simulations/card_authentications/:card_payment_id/challenge_attempts` + * endpoint or navigate to + * https://dashboard.increase.com/card_authentication_simulation/:card_payment_id. + */ +class CardAuthenticationChallengesParams +private constructor( + private val cardPaymentId: String?, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, + private val additionalBodyProperties: Map, +) : Params { + + /** The identifier of the Card Payment to be challenged. */ + fun cardPaymentId(): Optional = Optional.ofNullable(cardPaymentId) + + /** Additional body properties to send with the request. */ + fun _additionalBodyProperties(): Map = additionalBodyProperties + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun none(): CardAuthenticationChallengesParams = builder().build() + + /** + * Returns a mutable builder for constructing an instance of + * [CardAuthenticationChallengesParams]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardAuthenticationChallengesParams]. */ + class Builder internal constructor() { + + private var cardPaymentId: String? = null + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + private var additionalBodyProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardAuthenticationChallengesParams: CardAuthenticationChallengesParams) = + apply { + cardPaymentId = cardAuthenticationChallengesParams.cardPaymentId + additionalHeaders = cardAuthenticationChallengesParams.additionalHeaders.toBuilder() + additionalQueryParams = + cardAuthenticationChallengesParams.additionalQueryParams.toBuilder() + additionalBodyProperties = + cardAuthenticationChallengesParams.additionalBodyProperties.toMutableMap() + } + + /** The identifier of the Card Payment to be challenged. */ + fun cardPaymentId(cardPaymentId: String?) = apply { this.cardPaymentId = cardPaymentId } + + /** Alias for calling [Builder.cardPaymentId] with `cardPaymentId.orElse(null)`. */ + fun cardPaymentId(cardPaymentId: Optional) = + cardPaymentId(cardPaymentId.getOrNull()) + + fun additionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + this.additionalBodyProperties.clear() + putAllAdditionalBodyProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + additionalBodyProperties.put(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + this.additionalBodyProperties.putAll(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { + additionalBodyProperties.remove(key) + } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalBodyProperty) + } + + /** + * Returns an immutable instance of [CardAuthenticationChallengesParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): CardAuthenticationChallengesParams = + CardAuthenticationChallengesParams( + cardPaymentId, + additionalHeaders.build(), + additionalQueryParams.build(), + additionalBodyProperties.toImmutable(), + ) + } + + fun _body(): Optional> = + Optional.ofNullable(additionalBodyProperties.ifEmpty { null }) + + fun _pathParam(index: Int): String = + when (index) { + 0 -> cardPaymentId ?: "" + else -> "" + } + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardAuthenticationChallengesParams && + cardPaymentId == other.cardPaymentId && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams && + additionalBodyProperties == other.additionalBodyProperties + } + + override fun hashCode(): Int = + Objects.hash( + cardPaymentId, + additionalHeaders, + additionalQueryParams, + additionalBodyProperties, + ) + + override fun toString() = + "CardAuthenticationChallengesParams{cardPaymentId=$cardPaymentId, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams, additionalBodyProperties=$additionalBodyProperties}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationCreateParams.kt b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationCreateParams.kt new file mode 100644 index 000000000..5cbdce613 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationCreateParams.kt @@ -0,0 +1,1258 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.cardauthentications + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.increase.api.core.Enum +import com.increase.api.core.ExcludeMissing +import com.increase.api.core.JsonField +import com.increase.api.core.JsonMissing +import com.increase.api.core.JsonValue +import com.increase.api.core.Params +import com.increase.api.core.checkRequired +import com.increase.api.core.http.Headers +import com.increase.api.core.http.QueryParams +import com.increase.api.errors.IncreaseInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +/** + * Simulates a Card Authentication attempt on a [Card](#cards). The attempt always results in a + * [Card Payment](#card_payments) being created, either with a status that allows further action or + * a terminal failed status. + */ +class CardAuthenticationCreateParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * The identifier of the Card to be authorized. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardId(): String = body.cardId() + + /** + * The category of the card authentication attempt. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun category(): Optional = body.category() + + /** + * The device channel of the card authentication attempt. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun deviceChannel(): Optional = body.deviceChannel() + + /** + * The merchant identifier (commonly abbreviated as MID) of the merchant the card is transacting + * with. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun merchantAcceptorId(): Optional = body.merchantAcceptorId() + + /** + * The Merchant Category Code (commonly abbreviated as MCC) of the merchant the card is + * transacting with. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun merchantCategoryCode(): Optional = body.merchantCategoryCode() + + /** + * The country the merchant resides in. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun merchantCountry(): Optional = body.merchantCountry() + + /** + * The name of the merchant + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun merchantName(): Optional = body.merchantName() + + /** + * The purchase amount in cents. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun purchaseAmount(): Optional = body.purchaseAmount() + + /** + * Returns the raw JSON value of [cardId]. + * + * Unlike [cardId], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _cardId(): JsonField = body._cardId() + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _category(): JsonField = body._category() + + /** + * Returns the raw JSON value of [deviceChannel]. + * + * Unlike [deviceChannel], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _deviceChannel(): JsonField = body._deviceChannel() + + /** + * Returns the raw JSON value of [merchantAcceptorId]. + * + * Unlike [merchantAcceptorId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantAcceptorId(): JsonField = body._merchantAcceptorId() + + /** + * Returns the raw JSON value of [merchantCategoryCode]. + * + * Unlike [merchantCategoryCode], this method doesn't throw if the JSON field has an unexpected + * type. + */ + fun _merchantCategoryCode(): JsonField = body._merchantCategoryCode() + + /** + * Returns the raw JSON value of [merchantCountry]. + * + * Unlike [merchantCountry], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _merchantCountry(): JsonField = body._merchantCountry() + + /** + * Returns the raw JSON value of [merchantName]. + * + * Unlike [merchantName], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _merchantName(): JsonField = body._merchantName() + + /** + * Returns the raw JSON value of [purchaseAmount]. + * + * Unlike [purchaseAmount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _purchaseAmount(): JsonField = body._purchaseAmount() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + + /** Additional headers to send with the request. */ + fun _additionalHeaders(): Headers = additionalHeaders + + /** Additional query param to send with the request. */ + fun _additionalQueryParams(): QueryParams = additionalQueryParams + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of + * [CardAuthenticationCreateParams]. + * + * The following fields are required: + * ```java + * .cardId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardAuthenticationCreateParams]. */ + class Builder internal constructor() { + + private var body: Body.Builder = Body.builder() + private var additionalHeaders: Headers.Builder = Headers.builder() + private var additionalQueryParams: QueryParams.Builder = QueryParams.builder() + + @JvmSynthetic + internal fun from(cardAuthenticationCreateParams: CardAuthenticationCreateParams) = apply { + body = cardAuthenticationCreateParams.body.toBuilder() + additionalHeaders = cardAuthenticationCreateParams.additionalHeaders.toBuilder() + additionalQueryParams = cardAuthenticationCreateParams.additionalQueryParams.toBuilder() + } + + /** + * Sets the entire request body. + * + * This is generally only useful if you are already constructing the body separately. + * Otherwise, it's more convenient to use the top-level setters instead: + * - [cardId] + * - [category] + * - [deviceChannel] + * - [merchantAcceptorId] + * - [merchantCategoryCode] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** The identifier of the Card to be authorized. */ + fun cardId(cardId: String) = apply { body.cardId(cardId) } + + /** + * Sets [Builder.cardId] to an arbitrary JSON value. + * + * You should usually call [Builder.cardId] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun cardId(cardId: JsonField) = apply { body.cardId(cardId) } + + /** The category of the card authentication attempt. */ + fun category(category: Category) = apply { body.category(category) } + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [Category] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun category(category: JsonField) = apply { body.category(category) } + + /** The device channel of the card authentication attempt. */ + fun deviceChannel(deviceChannel: DeviceChannel) = apply { + body.deviceChannel(deviceChannel) + } + + /** + * Sets [Builder.deviceChannel] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceChannel] with a well-typed [DeviceChannel] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun deviceChannel(deviceChannel: JsonField) = apply { + body.deviceChannel(deviceChannel) + } + + /** + * The merchant identifier (commonly abbreviated as MID) of the merchant the card is + * transacting with. + */ + fun merchantAcceptorId(merchantAcceptorId: String) = apply { + body.merchantAcceptorId(merchantAcceptorId) + } + + /** + * Sets [Builder.merchantAcceptorId] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAcceptorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantAcceptorId(merchantAcceptorId: JsonField) = apply { + body.merchantAcceptorId(merchantAcceptorId) + } + + /** + * The Merchant Category Code (commonly abbreviated as MCC) of the merchant the card is + * transacting with. + */ + fun merchantCategoryCode(merchantCategoryCode: String) = apply { + body.merchantCategoryCode(merchantCategoryCode) + } + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCategoryCode(merchantCategoryCode: JsonField) = apply { + body.merchantCategoryCode(merchantCategoryCode) + } + + /** The country the merchant resides in. */ + fun merchantCountry(merchantCountry: String) = apply { + body.merchantCountry(merchantCountry) + } + + /** + * Sets [Builder.merchantCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCountry] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCountry(merchantCountry: JsonField) = apply { + body.merchantCountry(merchantCountry) + } + + /** The name of the merchant */ + fun merchantName(merchantName: String) = apply { body.merchantName(merchantName) } + + /** + * Sets [Builder.merchantName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantName] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun merchantName(merchantName: JsonField) = apply { + body.merchantName(merchantName) + } + + /** The purchase amount in cents. */ + fun purchaseAmount(purchaseAmount: Long) = apply { body.purchaseAmount(purchaseAmount) } + + /** + * Sets [Builder.purchaseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseAmount] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun purchaseAmount(purchaseAmount: JsonField) = apply { + body.purchaseAmount(purchaseAmount) + } + + 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) + } + + fun additionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.clear() + putAllAdditionalHeaders(additionalHeaders) + } + + fun putAdditionalHeader(name: String, value: String) = apply { + additionalHeaders.put(name, value) + } + + fun putAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.put(name, values) + } + + fun putAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun putAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.putAll(additionalHeaders) + } + + fun replaceAdditionalHeaders(name: String, value: String) = apply { + additionalHeaders.replace(name, value) + } + + fun replaceAdditionalHeaders(name: String, values: Iterable) = apply { + additionalHeaders.replace(name, values) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Headers) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun replaceAllAdditionalHeaders(additionalHeaders: Map>) = apply { + this.additionalHeaders.replaceAll(additionalHeaders) + } + + fun removeAdditionalHeaders(name: String) = apply { additionalHeaders.remove(name) } + + fun removeAllAdditionalHeaders(names: Set) = apply { + additionalHeaders.removeAll(names) + } + + fun additionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun additionalQueryParams(additionalQueryParams: Map>) = apply { + this.additionalQueryParams.clear() + putAllAdditionalQueryParams(additionalQueryParams) + } + + fun putAdditionalQueryParam(key: String, value: String) = apply { + additionalQueryParams.put(key, value) + } + + fun putAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.put(key, values) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun putAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.putAll(additionalQueryParams) + } + + fun replaceAdditionalQueryParams(key: String, value: String) = apply { + additionalQueryParams.replace(key, value) + } + + fun replaceAdditionalQueryParams(key: String, values: Iterable) = apply { + additionalQueryParams.replace(key, values) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: QueryParams) = apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun replaceAllAdditionalQueryParams(additionalQueryParams: Map>) = + apply { + this.additionalQueryParams.replaceAll(additionalQueryParams) + } + + fun removeAdditionalQueryParams(key: String) = apply { additionalQueryParams.remove(key) } + + fun removeAllAdditionalQueryParams(keys: Set) = apply { + additionalQueryParams.removeAll(keys) + } + + /** + * Returns an immutable instance of [CardAuthenticationCreateParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardAuthenticationCreateParams = + CardAuthenticationCreateParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val cardId: JsonField, + private val category: JsonField, + private val deviceChannel: JsonField, + private val merchantAcceptorId: JsonField, + private val merchantCategoryCode: JsonField, + private val merchantCountry: JsonField, + private val merchantName: JsonField, + private val purchaseAmount: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("card_id") @ExcludeMissing cardId: JsonField = JsonMissing.of(), + @JsonProperty("category") + @ExcludeMissing + category: JsonField = JsonMissing.of(), + @JsonProperty("device_channel") + @ExcludeMissing + deviceChannel: JsonField = JsonMissing.of(), + @JsonProperty("merchant_acceptor_id") + @ExcludeMissing + merchantAcceptorId: JsonField = JsonMissing.of(), + @JsonProperty("merchant_category_code") + @ExcludeMissing + merchantCategoryCode: JsonField = JsonMissing.of(), + @JsonProperty("merchant_country") + @ExcludeMissing + merchantCountry: JsonField = JsonMissing.of(), + @JsonProperty("merchant_name") + @ExcludeMissing + merchantName: JsonField = JsonMissing.of(), + @JsonProperty("purchase_amount") + @ExcludeMissing + purchaseAmount: JsonField = JsonMissing.of(), + ) : this( + cardId, + category, + deviceChannel, + merchantAcceptorId, + merchantCategoryCode, + merchantCountry, + merchantName, + purchaseAmount, + mutableMapOf(), + ) + + /** + * The identifier of the Card to be authorized. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected value). + */ + fun cardId(): String = cardId.getRequired("card_id") + + /** + * The category of the card authentication attempt. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun category(): Optional = category.getOptional("category") + + /** + * The device channel of the card authentication attempt. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun deviceChannel(): Optional = deviceChannel.getOptional("device_channel") + + /** + * The merchant identifier (commonly abbreviated as MID) of the merchant the card is + * transacting with. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantAcceptorId(): Optional = + merchantAcceptorId.getOptional("merchant_acceptor_id") + + /** + * The Merchant Category Code (commonly abbreviated as MCC) of the merchant the card is + * transacting with. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantCategoryCode(): Optional = + merchantCategoryCode.getOptional("merchant_category_code") + + /** + * The country the merchant resides in. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantCountry(): Optional = merchantCountry.getOptional("merchant_country") + + /** + * The name of the merchant + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun merchantName(): Optional = merchantName.getOptional("merchant_name") + + /** + * The purchase amount in cents. + * + * @throws IncreaseInvalidDataException if the JSON field has an unexpected type (e.g. if + * the server responded with an unexpected value). + */ + fun purchaseAmount(): Optional = purchaseAmount.getOptional("purchase_amount") + + /** + * Returns the raw JSON value of [cardId]. + * + * Unlike [cardId], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("card_id") @ExcludeMissing fun _cardId(): JsonField = cardId + + /** + * Returns the raw JSON value of [category]. + * + * Unlike [category], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("category") @ExcludeMissing fun _category(): JsonField = category + + /** + * Returns the raw JSON value of [deviceChannel]. + * + * Unlike [deviceChannel], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("device_channel") + @ExcludeMissing + fun _deviceChannel(): JsonField = deviceChannel + + /** + * Returns the raw JSON value of [merchantAcceptorId]. + * + * Unlike [merchantAcceptorId], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_acceptor_id") + @ExcludeMissing + fun _merchantAcceptorId(): JsonField = merchantAcceptorId + + /** + * Returns the raw JSON value of [merchantCategoryCode]. + * + * Unlike [merchantCategoryCode], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("merchant_category_code") + @ExcludeMissing + fun _merchantCategoryCode(): JsonField = merchantCategoryCode + + /** + * Returns the raw JSON value of [merchantCountry]. + * + * Unlike [merchantCountry], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_country") + @ExcludeMissing + fun _merchantCountry(): JsonField = merchantCountry + + /** + * Returns the raw JSON value of [merchantName]. + * + * Unlike [merchantName], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("merchant_name") + @ExcludeMissing + fun _merchantName(): JsonField = merchantName + + /** + * Returns the raw JSON value of [purchaseAmount]. + * + * Unlike [purchaseAmount], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("purchase_amount") + @ExcludeMissing + fun _purchaseAmount(): JsonField = purchaseAmount + + @JsonAnySetter + private fun putAdditionalProperty(key: String, value: JsonValue) { + additionalProperties.put(key, value) + } + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = + Collections.unmodifiableMap(additionalProperties) + + fun toBuilder() = Builder().from(this) + + companion object { + + /** + * Returns a mutable builder for constructing an instance of [Body]. + * + * The following fields are required: + * ```java + * .cardId() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var cardId: JsonField? = null + private var category: JsonField = JsonMissing.of() + private var deviceChannel: JsonField = JsonMissing.of() + private var merchantAcceptorId: JsonField = JsonMissing.of() + private var merchantCategoryCode: JsonField = JsonMissing.of() + private var merchantCountry: JsonField = JsonMissing.of() + private var merchantName: JsonField = JsonMissing.of() + private var purchaseAmount: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + cardId = body.cardId + category = body.category + deviceChannel = body.deviceChannel + merchantAcceptorId = body.merchantAcceptorId + merchantCategoryCode = body.merchantCategoryCode + merchantCountry = body.merchantCountry + merchantName = body.merchantName + purchaseAmount = body.purchaseAmount + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** The identifier of the Card to be authorized. */ + fun cardId(cardId: String) = cardId(JsonField.of(cardId)) + + /** + * Sets [Builder.cardId] to an arbitrary JSON value. + * + * You should usually call [Builder.cardId] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun cardId(cardId: JsonField) = apply { this.cardId = cardId } + + /** The category of the card authentication attempt. */ + fun category(category: Category) = category(JsonField.of(category)) + + /** + * Sets [Builder.category] to an arbitrary JSON value. + * + * You should usually call [Builder.category] with a well-typed [Category] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun category(category: JsonField) = apply { this.category = category } + + /** The device channel of the card authentication attempt. */ + fun deviceChannel(deviceChannel: DeviceChannel) = + deviceChannel(JsonField.of(deviceChannel)) + + /** + * Sets [Builder.deviceChannel] to an arbitrary JSON value. + * + * You should usually call [Builder.deviceChannel] with a well-typed [DeviceChannel] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun deviceChannel(deviceChannel: JsonField) = apply { + this.deviceChannel = deviceChannel + } + + /** + * The merchant identifier (commonly abbreviated as MID) of the merchant the card is + * transacting with. + */ + fun merchantAcceptorId(merchantAcceptorId: String) = + merchantAcceptorId(JsonField.of(merchantAcceptorId)) + + /** + * Sets [Builder.merchantAcceptorId] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantAcceptorId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantAcceptorId(merchantAcceptorId: JsonField) = apply { + this.merchantAcceptorId = merchantAcceptorId + } + + /** + * The Merchant Category Code (commonly abbreviated as MCC) of the merchant the card is + * transacting with. + */ + fun merchantCategoryCode(merchantCategoryCode: String) = + merchantCategoryCode(JsonField.of(merchantCategoryCode)) + + /** + * Sets [Builder.merchantCategoryCode] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCategoryCode] with a well-typed [String] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun merchantCategoryCode(merchantCategoryCode: JsonField) = apply { + this.merchantCategoryCode = merchantCategoryCode + } + + /** The country the merchant resides in. */ + fun merchantCountry(merchantCountry: String) = + merchantCountry(JsonField.of(merchantCountry)) + + /** + * Sets [Builder.merchantCountry] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantCountry] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantCountry(merchantCountry: JsonField) = apply { + this.merchantCountry = merchantCountry + } + + /** The name of the merchant */ + fun merchantName(merchantName: String) = merchantName(JsonField.of(merchantName)) + + /** + * Sets [Builder.merchantName] to an arbitrary JSON value. + * + * You should usually call [Builder.merchantName] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun merchantName(merchantName: JsonField) = apply { + this.merchantName = merchantName + } + + /** The purchase amount in cents. */ + fun purchaseAmount(purchaseAmount: Long) = purchaseAmount(JsonField.of(purchaseAmount)) + + /** + * Sets [Builder.purchaseAmount] to an arbitrary JSON value. + * + * You should usually call [Builder.purchaseAmount] with a well-typed [Long] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun purchaseAmount(purchaseAmount: JsonField) = apply { + this.purchaseAmount = purchaseAmount + } + + fun additionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.clear() + putAllAdditionalProperties(additionalProperties) + } + + fun putAdditionalProperty(key: String, value: JsonValue) = apply { + additionalProperties.put(key, value) + } + + fun putAllAdditionalProperties(additionalProperties: Map) = apply { + this.additionalProperties.putAll(additionalProperties) + } + + fun removeAdditionalProperty(key: String) = apply { additionalProperties.remove(key) } + + fun removeAllAdditionalProperties(keys: Set) = apply { + keys.forEach(::removeAdditionalProperty) + } + + /** + * Returns an immutable instance of [Body]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .cardId() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("cardId", cardId), + category, + deviceChannel, + merchantAcceptorId, + merchantCategoryCode, + merchantCountry, + merchantName, + purchaseAmount, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + cardId() + category().ifPresent { it.validate() } + deviceChannel().ifPresent { it.validate() } + merchantAcceptorId() + merchantCategoryCode() + merchantCountry() + merchantName() + purchaseAmount() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (cardId.asKnown().isPresent) 1 else 0) + + (category.asKnown().getOrNull()?.validity() ?: 0) + + (deviceChannel.asKnown().getOrNull()?.validity() ?: 0) + + (if (merchantAcceptorId.asKnown().isPresent) 1 else 0) + + (if (merchantCategoryCode.asKnown().isPresent) 1 else 0) + + (if (merchantCountry.asKnown().isPresent) 1 else 0) + + (if (merchantName.asKnown().isPresent) 1 else 0) + + (if (purchaseAmount.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + cardId == other.cardId && + category == other.category && + deviceChannel == other.deviceChannel && + merchantAcceptorId == other.merchantAcceptorId && + merchantCategoryCode == other.merchantCategoryCode && + merchantCountry == other.merchantCountry && + merchantName == other.merchantName && + purchaseAmount == other.purchaseAmount && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + cardId, + category, + deviceChannel, + merchantAcceptorId, + merchantCategoryCode, + merchantCountry, + merchantName, + purchaseAmount, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{cardId=$cardId, category=$category, deviceChannel=$deviceChannel, merchantAcceptorId=$merchantAcceptorId, merchantCategoryCode=$merchantCategoryCode, merchantCountry=$merchantCountry, merchantName=$merchantName, purchaseAmount=$purchaseAmount, additionalProperties=$additionalProperties}" + } + + /** The category of the card authentication attempt. */ + class Category @JsonCreator private constructor(private val value: JsonField) : Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** The authentication attempt is for a payment. */ + @JvmField val PAYMENT_AUTHENTICATION = of("payment_authentication") + + /** The authentication attempt is not for a payment. */ + @JvmField val NON_PAYMENT_AUTHENTICATION = of("non_payment_authentication") + + @JvmStatic fun of(value: String) = Category(JsonField.of(value)) + } + + /** An enum containing [Category]'s known values. */ + enum class Known { + /** The authentication attempt is for a payment. */ + PAYMENT_AUTHENTICATION, + /** The authentication attempt is not for a payment. */ + NON_PAYMENT_AUTHENTICATION, + } + + /** + * An enum containing [Category]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Category] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** The authentication attempt is for a payment. */ + PAYMENT_AUTHENTICATION, + /** The authentication attempt is not for a payment. */ + NON_PAYMENT_AUTHENTICATION, + /** An enum member indicating that [Category] was instantiated with an unknown value. */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + PAYMENT_AUTHENTICATION -> Value.PAYMENT_AUTHENTICATION + NON_PAYMENT_AUTHENTICATION -> Value.NON_PAYMENT_AUTHENTICATION + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + PAYMENT_AUTHENTICATION -> Known.PAYMENT_AUTHENTICATION + NON_PAYMENT_AUTHENTICATION -> Known.NON_PAYMENT_AUTHENTICATION + else -> throw IncreaseInvalidDataException("Unknown Category: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): Category = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Category && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The device channel of the card authentication attempt. */ + class DeviceChannel @JsonCreator private constructor(private val value: JsonField) : + Enum { + + /** + * Returns this class instance's raw value. + * + * This is usually only useful if this instance was deserialized from data that doesn't + * match any known member, and you want to know that value. For example, if the SDK is on an + * older version than the API, then the API may respond with new members that the SDK is + * unaware of. + */ + @com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value + + companion object { + + /** The authentication attempt was made from an app. */ + @JvmField val APP = of("app") + + /** The authentication attempt was made from a browser. */ + @JvmField val BROWSER = of("browser") + + /** The authentication attempt was initiated by the 3DS Requestor. */ + @JvmField val THREE_DS_REQUESTOR_INITIATED = of("three_ds_requestor_initiated") + + @JvmStatic fun of(value: String) = DeviceChannel(JsonField.of(value)) + } + + /** An enum containing [DeviceChannel]'s known values. */ + enum class Known { + /** The authentication attempt was made from an app. */ + APP, + /** The authentication attempt was made from a browser. */ + BROWSER, + /** The authentication attempt was initiated by the 3DS Requestor. */ + THREE_DS_REQUESTOR_INITIATED, + } + + /** + * An enum containing [DeviceChannel]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [DeviceChannel] can contain an unknown value in a couple of cases: + * - It was deserialized from data that doesn't match any known member. For example, if the + * SDK is on an older version than the API, then the API may respond with new members that + * the SDK is unaware of. + * - It was constructed with an arbitrary value using the [of] method. + */ + enum class Value { + /** The authentication attempt was made from an app. */ + APP, + /** The authentication attempt was made from a browser. */ + BROWSER, + /** The authentication attempt was initiated by the 3DS Requestor. */ + THREE_DS_REQUESTOR_INITIATED, + /** + * An enum member indicating that [DeviceChannel] was instantiated with an unknown + * value. + */ + _UNKNOWN, + } + + /** + * Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN] + * if the class was instantiated with an unknown value. + * + * Use the [known] method instead if you're certain the value is always known or if you want + * to throw for the unknown case. + */ + fun value(): Value = + when (this) { + APP -> Value.APP + BROWSER -> Value.BROWSER + THREE_DS_REQUESTOR_INITIATED -> Value.THREE_DS_REQUESTOR_INITIATED + else -> Value._UNKNOWN + } + + /** + * Returns an enum member corresponding to this class instance's value. + * + * Use the [value] method instead if you're uncertain the value is always known and don't + * want to throw for the unknown case. + * + * @throws IncreaseInvalidDataException if this class instance's value is a not a known + * member. + */ + fun known(): Known = + when (this) { + APP -> Known.APP + BROWSER -> Known.BROWSER + THREE_DS_REQUESTOR_INITIATED -> Known.THREE_DS_REQUESTOR_INITIATED + else -> throw IncreaseInvalidDataException("Unknown DeviceChannel: $value") + } + + /** + * Returns this class instance's primitive wire representation. + * + * This differs from the [toString] method because that method is primarily for debugging + * and generally doesn't throw. + * + * @throws IncreaseInvalidDataException if this class instance's value does not have the + * expected primitive type. + */ + fun asString(): String = + _value().asString().orElseThrow { + IncreaseInvalidDataException("Value is not a String") + } + + private var validated: Boolean = false + + fun validate(): DeviceChannel = apply { + if (validated) { + return@apply + } + + known() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: IncreaseInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic internal fun validity(): Int = if (value() == Value._UNKNOWN) 0 else 1 + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is DeviceChannel && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardAuthenticationCreateParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "CardAuthenticationCreateParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt index 016acdba8..d8234d4d4 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsync.kt @@ -6,6 +6,7 @@ import com.increase.api.core.ClientOptions import com.increase.api.services.async.simulations.AccountStatementServiceAsync import com.increase.api.services.async.simulations.AccountTransferServiceAsync import com.increase.api.services.async.simulations.AchTransferServiceAsync +import com.increase.api.services.async.simulations.CardAuthenticationServiceAsync import com.increase.api.services.async.simulations.CardAuthorizationExpirationServiceAsync import com.increase.api.services.async.simulations.CardAuthorizationServiceAsync import com.increase.api.services.async.simulations.CardBalanceInquiryServiceAsync @@ -70,6 +71,8 @@ interface SimulationServiceAsync { fun cardRefunds(): CardRefundServiceAsync + fun cardAuthentications(): CardAuthenticationServiceAsync + fun cardDisputes(): CardDisputeServiceAsync fun physicalCards(): PhysicalCardServiceAsync @@ -147,6 +150,8 @@ interface SimulationServiceAsync { fun cardRefunds(): CardRefundServiceAsync.WithRawResponse + fun cardAuthentications(): CardAuthenticationServiceAsync.WithRawResponse + fun cardDisputes(): CardDisputeServiceAsync.WithRawResponse fun physicalCards(): PhysicalCardServiceAsync.WithRawResponse diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt index de0424b9a..35bf5ded1 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/SimulationServiceAsyncImpl.kt @@ -9,6 +9,8 @@ import com.increase.api.services.async.simulations.AccountTransferServiceAsync import com.increase.api.services.async.simulations.AccountTransferServiceAsyncImpl import com.increase.api.services.async.simulations.AchTransferServiceAsync import com.increase.api.services.async.simulations.AchTransferServiceAsyncImpl +import com.increase.api.services.async.simulations.CardAuthenticationServiceAsync +import com.increase.api.services.async.simulations.CardAuthenticationServiceAsyncImpl import com.increase.api.services.async.simulations.CardAuthorizationExpirationServiceAsync import com.increase.api.services.async.simulations.CardAuthorizationExpirationServiceAsyncImpl import com.increase.api.services.async.simulations.CardAuthorizationServiceAsync @@ -114,6 +116,10 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: CardRefundServiceAsyncImpl(clientOptions) } + private val cardAuthentications: CardAuthenticationServiceAsync by lazy { + CardAuthenticationServiceAsyncImpl(clientOptions) + } + private val cardDisputes: CardDisputeServiceAsync by lazy { CardDisputeServiceAsyncImpl(clientOptions) } @@ -221,6 +227,8 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: override fun cardRefunds(): CardRefundServiceAsync = cardRefunds + override fun cardAuthentications(): CardAuthenticationServiceAsync = cardAuthentications + override fun cardDisputes(): CardDisputeServiceAsync = cardDisputes override fun physicalCards(): PhysicalCardServiceAsync = physicalCards @@ -313,6 +321,10 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: CardRefundServiceAsyncImpl.WithRawResponseImpl(clientOptions) } + private val cardAuthentications: CardAuthenticationServiceAsync.WithRawResponse by lazy { + CardAuthenticationServiceAsyncImpl.WithRawResponseImpl(clientOptions) + } + private val cardDisputes: CardDisputeServiceAsync.WithRawResponse by lazy { CardDisputeServiceAsyncImpl.WithRawResponseImpl(clientOptions) } @@ -435,6 +447,9 @@ class SimulationServiceAsyncImpl internal constructor(private val clientOptions: override fun cardRefunds(): CardRefundServiceAsync.WithRawResponse = cardRefunds + override fun cardAuthentications(): CardAuthenticationServiceAsync.WithRawResponse = + cardAuthentications + override fun cardDisputes(): CardDisputeServiceAsync.WithRawResponse = cardDisputes override fun physicalCards(): PhysicalCardServiceAsync.WithRawResponse = physicalCards diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsync.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsync.kt new file mode 100644 index 000000000..f0c7bddeb --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsync.kt @@ -0,0 +1,220 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardpayments.CardPayment +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengeAttemptsParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengesParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationCreateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer + +interface CardAuthenticationServiceAsync { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardAuthenticationServiceAsync + + /** + * Simulates a Card Authentication attempt on a [Card](#cards). The attempt always results in a + * [Card Payment](#card_payments) being created, either with a status that allows further action + * or a terminal failed status. + */ + fun create(params: CardAuthenticationCreateParams): CompletableFuture = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardAuthenticationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Simulates an attempt at a Card Authentication Challenge. This updates the + * `card_authentications` object under the [Card Payment](#card_payments). You can also attempt + * the challenge by navigating to + * https://dashboard.increase.com/card_authentication_simulation/:card_payment_id. + */ + fun challengeAttempts( + cardPaymentId: String, + params: CardAuthenticationChallengeAttemptsParams, + ): CompletableFuture = + challengeAttempts(cardPaymentId, params, RequestOptions.none()) + + /** @see challengeAttempts */ + fun challengeAttempts( + cardPaymentId: String, + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + challengeAttempts(params.toBuilder().cardPaymentId(cardPaymentId).build(), requestOptions) + + /** @see challengeAttempts */ + fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams + ): CompletableFuture = challengeAttempts(params, RequestOptions.none()) + + /** @see challengeAttempts */ + fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** + * Simulates starting a Card Authentication Challenge for an existing Card Authentication. This + * updates the `card_authentications` object under the [Card Payment](#card_payments). To + * attempt the challenge, use the + * `/simulations/card_authentications/:card_payment_id/challenge_attempts` endpoint or navigate + * to https://dashboard.increase.com/card_authentication_simulation/:card_payment_id. + */ + fun challenges(cardPaymentId: String): CompletableFuture = + challenges(cardPaymentId, CardAuthenticationChallengesParams.none()) + + /** @see challenges */ + fun challenges( + cardPaymentId: String, + params: CardAuthenticationChallengesParams = CardAuthenticationChallengesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture = + challenges(params.toBuilder().cardPaymentId(cardPaymentId).build(), requestOptions) + + /** @see challenges */ + fun challenges( + cardPaymentId: String, + params: CardAuthenticationChallengesParams = CardAuthenticationChallengesParams.none(), + ): CompletableFuture = challenges(cardPaymentId, params, RequestOptions.none()) + + /** @see challenges */ + fun challenges( + params: CardAuthenticationChallengesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + + /** @see challenges */ + fun challenges(params: CardAuthenticationChallengesParams): CompletableFuture = + challenges(params, RequestOptions.none()) + + /** @see challenges */ + fun challenges( + cardPaymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture = + challenges(cardPaymentId, CardAuthenticationChallengesParams.none(), requestOptions) + + /** + * A view of [CardAuthenticationServiceAsync] that provides access to raw HTTP responses for + * each method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardAuthenticationServiceAsync.WithRawResponse + + /** + * Returns a raw HTTP response for `post /simulations/card_authentications`, but is + * otherwise the same as [CardAuthenticationServiceAsync.create]. + */ + fun create( + params: CardAuthenticationCreateParams + ): CompletableFuture> = create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardAuthenticationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /simulations/card_authentications/{card_payment_id}/challenge_attempts`, but is otherwise + * the same as [CardAuthenticationServiceAsync.challengeAttempts]. + */ + fun challengeAttempts( + cardPaymentId: String, + params: CardAuthenticationChallengeAttemptsParams, + ): CompletableFuture> = + challengeAttempts(cardPaymentId, params, RequestOptions.none()) + + /** @see challengeAttempts */ + fun challengeAttempts( + cardPaymentId: String, + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + challengeAttempts( + params.toBuilder().cardPaymentId(cardPaymentId).build(), + requestOptions, + ) + + /** @see challengeAttempts */ + fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams + ): CompletableFuture> = + challengeAttempts(params, RequestOptions.none()) + + /** @see challengeAttempts */ + fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** + * Returns a raw HTTP response for `post + * /simulations/card_authentications/{card_payment_id}/challenges`, but is otherwise the + * same as [CardAuthenticationServiceAsync.challenges]. + */ + fun challenges(cardPaymentId: String): CompletableFuture> = + challenges(cardPaymentId, CardAuthenticationChallengesParams.none()) + + /** @see challenges */ + fun challenges( + cardPaymentId: String, + params: CardAuthenticationChallengesParams = CardAuthenticationChallengesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> = + challenges(params.toBuilder().cardPaymentId(cardPaymentId).build(), requestOptions) + + /** @see challenges */ + fun challenges( + cardPaymentId: String, + params: CardAuthenticationChallengesParams = CardAuthenticationChallengesParams.none(), + ): CompletableFuture> = + challenges(cardPaymentId, params, RequestOptions.none()) + + /** @see challenges */ + fun challenges( + params: CardAuthenticationChallengesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + + /** @see challenges */ + fun challenges( + params: CardAuthenticationChallengesParams + ): CompletableFuture> = + challenges(params, RequestOptions.none()) + + /** @see challenges */ + fun challenges( + cardPaymentId: String, + requestOptions: RequestOptions, + ): CompletableFuture> = + challenges(cardPaymentId, CardAuthenticationChallengesParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsyncImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsyncImpl.kt new file mode 100644 index 000000000..b5cdcbc95 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsyncImpl.kt @@ -0,0 +1,186 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepareAsync +import com.increase.api.models.cardpayments.CardPayment +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengeAttemptsParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengesParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationCreateParams +import java.util.concurrent.CompletableFuture +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardAuthenticationServiceAsyncImpl +internal constructor(private val clientOptions: ClientOptions) : CardAuthenticationServiceAsync { + + private val withRawResponse: CardAuthenticationServiceAsync.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardAuthenticationServiceAsync.WithRawResponse = withRawResponse + + override fun withOptions( + modifier: Consumer + ): CardAuthenticationServiceAsync = + CardAuthenticationServiceAsyncImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + override fun create( + params: CardAuthenticationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /simulations/card_authentications + withRawResponse().create(params, requestOptions).thenApply { it.parse() } + + override fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /simulations/card_authentications/{card_payment_id}/challenge_attempts + withRawResponse().challengeAttempts(params, requestOptions).thenApply { it.parse() } + + override fun challenges( + params: CardAuthenticationChallengesParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /simulations/card_authentications/{card_payment_id}/challenges + withRawResponse().challenges(params, requestOptions).thenApply { it.parse() } + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardAuthenticationServiceAsync.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardAuthenticationServiceAsync.WithRawResponse = + CardAuthenticationServiceAsyncImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardAuthenticationCreateParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("simulations", "card_authentications") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val challengeAttemptsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPaymentId", params.cardPaymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "simulations", + "card_authentications", + params._pathParam(0), + "challenge_attempts", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { challengeAttemptsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + + private val challengesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun challenges( + params: CardAuthenticationChallengesParams, + requestOptions: RequestOptions, + ): CompletableFuture> { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPaymentId", params.cardPaymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "simulations", + "card_authentications", + params._pathParam(0), + "challenges", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepareAsync(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + return request + .thenComposeAsync { clientOptions.httpClient.executeAsync(it, requestOptions) } + .thenApply { response -> + errorHandler.handle(response).parseable { + response + .use { challengesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt index 718263730..a74c3135b 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationService.kt @@ -6,6 +6,7 @@ import com.increase.api.core.ClientOptions import com.increase.api.services.blocking.simulations.AccountStatementService import com.increase.api.services.blocking.simulations.AccountTransferService import com.increase.api.services.blocking.simulations.AchTransferService +import com.increase.api.services.blocking.simulations.CardAuthenticationService import com.increase.api.services.blocking.simulations.CardAuthorizationExpirationService import com.increase.api.services.blocking.simulations.CardAuthorizationService import com.increase.api.services.blocking.simulations.CardBalanceInquiryService @@ -70,6 +71,8 @@ interface SimulationService { fun cardRefunds(): CardRefundService + fun cardAuthentications(): CardAuthenticationService + fun cardDisputes(): CardDisputeService fun physicalCards(): PhysicalCardService @@ -144,6 +147,8 @@ interface SimulationService { fun cardRefunds(): CardRefundService.WithRawResponse + fun cardAuthentications(): CardAuthenticationService.WithRawResponse + fun cardDisputes(): CardDisputeService.WithRawResponse fun physicalCards(): PhysicalCardService.WithRawResponse diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt index 027f9e4fe..1b51b6fed 100644 --- a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/SimulationServiceImpl.kt @@ -9,6 +9,8 @@ import com.increase.api.services.blocking.simulations.AccountTransferService import com.increase.api.services.blocking.simulations.AccountTransferServiceImpl import com.increase.api.services.blocking.simulations.AchTransferService import com.increase.api.services.blocking.simulations.AchTransferServiceImpl +import com.increase.api.services.blocking.simulations.CardAuthenticationService +import com.increase.api.services.blocking.simulations.CardAuthenticationServiceImpl import com.increase.api.services.blocking.simulations.CardAuthorizationExpirationService import com.increase.api.services.blocking.simulations.CardAuthorizationExpirationServiceImpl import com.increase.api.services.blocking.simulations.CardAuthorizationService @@ -112,6 +114,10 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie private val cardRefunds: CardRefundService by lazy { CardRefundServiceImpl(clientOptions) } + private val cardAuthentications: CardAuthenticationService by lazy { + CardAuthenticationServiceImpl(clientOptions) + } + private val cardDisputes: CardDisputeService by lazy { CardDisputeServiceImpl(clientOptions) } private val physicalCards: PhysicalCardService by lazy { @@ -212,6 +218,8 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie override fun cardRefunds(): CardRefundService = cardRefunds + override fun cardAuthentications(): CardAuthenticationService = cardAuthentications + override fun cardDisputes(): CardDisputeService = cardDisputes override fun physicalCards(): PhysicalCardService = physicalCards @@ -302,6 +310,10 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie CardRefundServiceImpl.WithRawResponseImpl(clientOptions) } + private val cardAuthentications: CardAuthenticationService.WithRawResponse by lazy { + CardAuthenticationServiceImpl.WithRawResponseImpl(clientOptions) + } + private val cardDisputes: CardDisputeService.WithRawResponse by lazy { CardDisputeServiceImpl.WithRawResponseImpl(clientOptions) } @@ -421,6 +433,9 @@ class SimulationServiceImpl internal constructor(private val clientOptions: Clie override fun cardRefunds(): CardRefundService.WithRawResponse = cardRefunds + override fun cardAuthentications(): CardAuthenticationService.WithRawResponse = + cardAuthentications + override fun cardDisputes(): CardDisputeService.WithRawResponse = cardDisputes override fun physicalCards(): PhysicalCardService.WithRawResponse = physicalCards diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationService.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationService.kt new file mode 100644 index 000000000..3a7cb5408 --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationService.kt @@ -0,0 +1,222 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.google.errorprone.annotations.MustBeClosed +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.models.cardpayments.CardPayment +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengeAttemptsParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengesParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationCreateParams +import java.util.function.Consumer + +interface CardAuthenticationService { + + /** + * Returns a view of this service that provides access to raw HTTP responses for each method. + */ + fun withRawResponse(): WithRawResponse + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions(modifier: Consumer): CardAuthenticationService + + /** + * Simulates a Card Authentication attempt on a [Card](#cards). The attempt always results in a + * [Card Payment](#card_payments) being created, either with a status that allows further action + * or a terminal failed status. + */ + fun create(params: CardAuthenticationCreateParams): CardPayment = + create(params, RequestOptions.none()) + + /** @see create */ + fun create( + params: CardAuthenticationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPayment + + /** + * Simulates an attempt at a Card Authentication Challenge. This updates the + * `card_authentications` object under the [Card Payment](#card_payments). You can also attempt + * the challenge by navigating to + * https://dashboard.increase.com/card_authentication_simulation/:card_payment_id. + */ + fun challengeAttempts( + cardPaymentId: String, + params: CardAuthenticationChallengeAttemptsParams, + ): CardPayment = challengeAttempts(cardPaymentId, params, RequestOptions.none()) + + /** @see challengeAttempts */ + fun challengeAttempts( + cardPaymentId: String, + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPayment = + challengeAttempts(params.toBuilder().cardPaymentId(cardPaymentId).build(), requestOptions) + + /** @see challengeAttempts */ + fun challengeAttempts(params: CardAuthenticationChallengeAttemptsParams): CardPayment = + challengeAttempts(params, RequestOptions.none()) + + /** @see challengeAttempts */ + fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPayment + + /** + * Simulates starting a Card Authentication Challenge for an existing Card Authentication. This + * updates the `card_authentications` object under the [Card Payment](#card_payments). To + * attempt the challenge, use the + * `/simulations/card_authentications/:card_payment_id/challenge_attempts` endpoint or navigate + * to https://dashboard.increase.com/card_authentication_simulation/:card_payment_id. + */ + fun challenges(cardPaymentId: String): CardPayment = + challenges(cardPaymentId, CardAuthenticationChallengesParams.none()) + + /** @see challenges */ + fun challenges( + cardPaymentId: String, + params: CardAuthenticationChallengesParams = CardAuthenticationChallengesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPayment = + challenges(params.toBuilder().cardPaymentId(cardPaymentId).build(), requestOptions) + + /** @see challenges */ + fun challenges( + cardPaymentId: String, + params: CardAuthenticationChallengesParams = CardAuthenticationChallengesParams.none(), + ): CardPayment = challenges(cardPaymentId, params, RequestOptions.none()) + + /** @see challenges */ + fun challenges( + params: CardAuthenticationChallengesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CardPayment + + /** @see challenges */ + fun challenges(params: CardAuthenticationChallengesParams): CardPayment = + challenges(params, RequestOptions.none()) + + /** @see challenges */ + fun challenges(cardPaymentId: String, requestOptions: RequestOptions): CardPayment = + challenges(cardPaymentId, CardAuthenticationChallengesParams.none(), requestOptions) + + /** + * A view of [CardAuthenticationService] that provides access to raw HTTP responses for each + * method. + */ + interface WithRawResponse { + + /** + * Returns a view of this service with the given option modifications applied. + * + * The original service is not modified. + */ + fun withOptions( + modifier: Consumer + ): CardAuthenticationService.WithRawResponse + + /** + * Returns a raw HTTP response for `post /simulations/card_authentications`, but is + * otherwise the same as [CardAuthenticationService.create]. + */ + @MustBeClosed + fun create(params: CardAuthenticationCreateParams): HttpResponseFor = + create(params, RequestOptions.none()) + + /** @see create */ + @MustBeClosed + fun create( + params: CardAuthenticationCreateParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /simulations/card_authentications/{card_payment_id}/challenge_attempts`, but is otherwise + * the same as [CardAuthenticationService.challengeAttempts]. + */ + @MustBeClosed + fun challengeAttempts( + cardPaymentId: String, + params: CardAuthenticationChallengeAttemptsParams, + ): HttpResponseFor = + challengeAttempts(cardPaymentId, params, RequestOptions.none()) + + /** @see challengeAttempts */ + @MustBeClosed + fun challengeAttempts( + cardPaymentId: String, + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + challengeAttempts( + params.toBuilder().cardPaymentId(cardPaymentId).build(), + requestOptions, + ) + + /** @see challengeAttempts */ + @MustBeClosed + fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams + ): HttpResponseFor = challengeAttempts(params, RequestOptions.none()) + + /** @see challengeAttempts */ + @MustBeClosed + fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** + * Returns a raw HTTP response for `post + * /simulations/card_authentications/{card_payment_id}/challenges`, but is otherwise the + * same as [CardAuthenticationService.challenges]. + */ + @MustBeClosed + fun challenges(cardPaymentId: String): HttpResponseFor = + challenges(cardPaymentId, CardAuthenticationChallengesParams.none()) + + /** @see challenges */ + @MustBeClosed + fun challenges( + cardPaymentId: String, + params: CardAuthenticationChallengesParams = CardAuthenticationChallengesParams.none(), + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor = + challenges(params.toBuilder().cardPaymentId(cardPaymentId).build(), requestOptions) + + /** @see challenges */ + @MustBeClosed + fun challenges( + cardPaymentId: String, + params: CardAuthenticationChallengesParams = CardAuthenticationChallengesParams.none(), + ): HttpResponseFor = challenges(cardPaymentId, params, RequestOptions.none()) + + /** @see challenges */ + @MustBeClosed + fun challenges( + params: CardAuthenticationChallengesParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + + /** @see challenges */ + @MustBeClosed + fun challenges(params: CardAuthenticationChallengesParams): HttpResponseFor = + challenges(params, RequestOptions.none()) + + /** @see challenges */ + @MustBeClosed + fun challenges( + cardPaymentId: String, + requestOptions: RequestOptions, + ): HttpResponseFor = + challenges(cardPaymentId, CardAuthenticationChallengesParams.none(), requestOptions) + } +} diff --git a/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationServiceImpl.kt b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationServiceImpl.kt new file mode 100644 index 000000000..fdc60351c --- /dev/null +++ b/increase-java-core/src/main/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationServiceImpl.kt @@ -0,0 +1,172 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.increase.api.core.ClientOptions +import com.increase.api.core.RequestOptions +import com.increase.api.core.checkRequired +import com.increase.api.core.handlers.errorBodyHandler +import com.increase.api.core.handlers.errorHandler +import com.increase.api.core.handlers.jsonHandler +import com.increase.api.core.http.HttpMethod +import com.increase.api.core.http.HttpRequest +import com.increase.api.core.http.HttpResponse +import com.increase.api.core.http.HttpResponse.Handler +import com.increase.api.core.http.HttpResponseFor +import com.increase.api.core.http.json +import com.increase.api.core.http.parseable +import com.increase.api.core.prepare +import com.increase.api.models.cardpayments.CardPayment +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengeAttemptsParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengesParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationCreateParams +import java.util.function.Consumer +import kotlin.jvm.optionals.getOrNull + +class CardAuthenticationServiceImpl internal constructor(private val clientOptions: ClientOptions) : + CardAuthenticationService { + + private val withRawResponse: CardAuthenticationService.WithRawResponse by lazy { + WithRawResponseImpl(clientOptions) + } + + override fun withRawResponse(): CardAuthenticationService.WithRawResponse = withRawResponse + + override fun withOptions(modifier: Consumer): CardAuthenticationService = + CardAuthenticationServiceImpl(clientOptions.toBuilder().apply(modifier::accept).build()) + + override fun create( + params: CardAuthenticationCreateParams, + requestOptions: RequestOptions, + ): CardPayment = + // post /simulations/card_authentications + withRawResponse().create(params, requestOptions).parse() + + override fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions, + ): CardPayment = + // post /simulations/card_authentications/{card_payment_id}/challenge_attempts + withRawResponse().challengeAttempts(params, requestOptions).parse() + + override fun challenges( + params: CardAuthenticationChallengesParams, + requestOptions: RequestOptions, + ): CardPayment = + // post /simulations/card_authentications/{card_payment_id}/challenges + withRawResponse().challenges(params, requestOptions).parse() + + class WithRawResponseImpl internal constructor(private val clientOptions: ClientOptions) : + CardAuthenticationService.WithRawResponse { + + private val errorHandler: Handler = + errorHandler(errorBodyHandler(clientOptions.jsonMapper)) + + override fun withOptions( + modifier: Consumer + ): CardAuthenticationService.WithRawResponse = + CardAuthenticationServiceImpl.WithRawResponseImpl( + clientOptions.toBuilder().apply(modifier::accept).build() + ) + + private val createHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun create( + params: CardAuthenticationCreateParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("simulations", "card_authentications") + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { createHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val challengeAttemptsHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun challengeAttempts( + params: CardAuthenticationChallengeAttemptsParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPaymentId", params.cardPaymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "simulations", + "card_authentications", + params._pathParam(0), + "challenge_attempts", + ) + .body(json(clientOptions.jsonMapper, params._body())) + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { challengeAttemptsHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + + private val challengesHandler: Handler = + jsonHandler(clientOptions.jsonMapper) + + override fun challenges( + params: CardAuthenticationChallengesParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + // We check here instead of in the params builder because this can be specified + // positionally or in the params class. + checkRequired("cardPaymentId", params.cardPaymentId().getOrNull()) + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments( + "simulations", + "card_authentications", + params._pathParam(0), + "challenges", + ) + .apply { params._body().ifPresent { body(json(clientOptions.jsonMapper, it)) } } + .build() + .prepare(clientOptions, params) + val requestOptions = requestOptions.applyDefaults(RequestOptions.from(clientOptions)) + val response = clientOptions.httpClient.execute(request, requestOptions) + return errorHandler.handle(response).parseable { + response + .use { challengesHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengeAttemptsParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengeAttemptsParamsTest.kt new file mode 100644 index 000000000..2f561b5b4 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengeAttemptsParamsTest.kt @@ -0,0 +1,43 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.cardauthentications + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardAuthenticationChallengeAttemptsParamsTest { + + @Test + fun create() { + CardAuthenticationChallengeAttemptsParams.builder() + .cardPaymentId("card_payment_nd3k2kacrqjli8482ave") + .oneTimeCode("123456") + .build() + } + + @Test + fun pathParams() { + val params = + CardAuthenticationChallengeAttemptsParams.builder() + .cardPaymentId("card_payment_nd3k2kacrqjli8482ave") + .oneTimeCode("123456") + .build() + + assertThat(params._pathParam(0)).isEqualTo("card_payment_nd3k2kacrqjli8482ave") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } + + @Test + fun body() { + val params = + CardAuthenticationChallengeAttemptsParams.builder() + .cardPaymentId("card_payment_nd3k2kacrqjli8482ave") + .oneTimeCode("123456") + .build() + + val body = params._body() + + assertThat(body.oneTimeCode()).isEqualTo("123456") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengesParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengesParamsTest.kt new file mode 100644 index 000000000..d1907ac8e --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationChallengesParamsTest.kt @@ -0,0 +1,28 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.cardauthentications + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardAuthenticationChallengesParamsTest { + + @Test + fun create() { + CardAuthenticationChallengesParams.builder() + .cardPaymentId("card_payment_nd3k2kacrqjli8482ave") + .build() + } + + @Test + fun pathParams() { + val params = + CardAuthenticationChallengesParams.builder() + .cardPaymentId("card_payment_nd3k2kacrqjli8482ave") + .build() + + assertThat(params._pathParam(0)).isEqualTo("card_payment_nd3k2kacrqjli8482ave") + // out-of-bound path param + assertThat(params._pathParam(1)).isEqualTo("") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationCreateParamsTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationCreateParamsTest.kt new file mode 100644 index 000000000..005235449 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/models/simulations/cardauthentications/CardAuthenticationCreateParamsTest.kt @@ -0,0 +1,60 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.models.simulations.cardauthentications + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class CardAuthenticationCreateParamsTest { + + @Test + fun create() { + CardAuthenticationCreateParams.builder() + .cardId("card_oubs0hwk5rn6knuecxg2") + .category(CardAuthenticationCreateParams.Category.PAYMENT_AUTHENTICATION) + .deviceChannel(CardAuthenticationCreateParams.DeviceChannel.APP) + .merchantAcceptorId("5665270011000168") + .merchantCategoryCode("5734") + .merchantCountry("US") + .merchantName("x") + .purchaseAmount(1000L) + .build() + } + + @Test + fun body() { + val params = + CardAuthenticationCreateParams.builder() + .cardId("card_oubs0hwk5rn6knuecxg2") + .category(CardAuthenticationCreateParams.Category.PAYMENT_AUTHENTICATION) + .deviceChannel(CardAuthenticationCreateParams.DeviceChannel.APP) + .merchantAcceptorId("5665270011000168") + .merchantCategoryCode("5734") + .merchantCountry("US") + .merchantName("x") + .purchaseAmount(1000L) + .build() + + val body = params._body() + + assertThat(body.cardId()).isEqualTo("card_oubs0hwk5rn6knuecxg2") + assertThat(body.category()) + .contains(CardAuthenticationCreateParams.Category.PAYMENT_AUTHENTICATION) + assertThat(body.deviceChannel()).contains(CardAuthenticationCreateParams.DeviceChannel.APP) + assertThat(body.merchantAcceptorId()).contains("5665270011000168") + assertThat(body.merchantCategoryCode()).contains("5734") + assertThat(body.merchantCountry()).contains("US") + assertThat(body.merchantName()).contains("x") + assertThat(body.purchaseAmount()).contains(1000L) + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + CardAuthenticationCreateParams.builder().cardId("card_oubs0hwk5rn6knuecxg2").build() + + val body = params._body() + + assertThat(body.cardId()).isEqualTo("card_oubs0hwk5rn6knuecxg2") + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsyncTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsyncTest.kt new file mode 100644 index 000000000..a15f85c72 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/async/simulations/CardAuthenticationServiceAsyncTest.kt @@ -0,0 +1,78 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.async.simulations + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClientAsync +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengeAttemptsParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardAuthenticationServiceAsyncTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardAuthenticationServiceAsync = client.simulations().cardAuthentications() + + val cardPaymentFuture = + cardAuthenticationServiceAsync.create( + CardAuthenticationCreateParams.builder() + .cardId("card_oubs0hwk5rn6knuecxg2") + .category(CardAuthenticationCreateParams.Category.PAYMENT_AUTHENTICATION) + .deviceChannel(CardAuthenticationCreateParams.DeviceChannel.APP) + .merchantAcceptorId("5665270011000168") + .merchantCategoryCode("5734") + .merchantCountry("US") + .merchantName("x") + .purchaseAmount(1000L) + .build() + ) + + val cardPayment = cardPaymentFuture.get() + cardPayment.validate() + } + + @Test + fun challengeAttempts() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardAuthenticationServiceAsync = client.simulations().cardAuthentications() + + val cardPaymentFuture = + cardAuthenticationServiceAsync.challengeAttempts( + CardAuthenticationChallengeAttemptsParams.builder() + .cardPaymentId("card_payment_nd3k2kacrqjli8482ave") + .oneTimeCode("123456") + .build() + ) + + val cardPayment = cardPaymentFuture.get() + cardPayment.validate() + } + + @Test + fun challenges() { + val client = + IncreaseOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardAuthenticationServiceAsync = client.simulations().cardAuthentications() + + val cardPaymentFuture = + cardAuthenticationServiceAsync.challenges("card_payment_nd3k2kacrqjli8482ave") + + val cardPayment = cardPaymentFuture.get() + cardPayment.validate() + } +} diff --git a/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationServiceTest.kt b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationServiceTest.kt new file mode 100644 index 000000000..1eaeef8c0 --- /dev/null +++ b/increase-java-core/src/test/kotlin/com/increase/api/services/blocking/simulations/CardAuthenticationServiceTest.kt @@ -0,0 +1,74 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.increase.api.services.blocking.simulations + +import com.increase.api.TestServerExtension +import com.increase.api.client.okhttp.IncreaseOkHttpClient +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationChallengeAttemptsParams +import com.increase.api.models.simulations.cardauthentications.CardAuthenticationCreateParams +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.extension.ExtendWith + +@ExtendWith(TestServerExtension::class) +internal class CardAuthenticationServiceTest { + + @Test + fun create() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardAuthenticationService = client.simulations().cardAuthentications() + + val cardPayment = + cardAuthenticationService.create( + CardAuthenticationCreateParams.builder() + .cardId("card_oubs0hwk5rn6knuecxg2") + .category(CardAuthenticationCreateParams.Category.PAYMENT_AUTHENTICATION) + .deviceChannel(CardAuthenticationCreateParams.DeviceChannel.APP) + .merchantAcceptorId("5665270011000168") + .merchantCategoryCode("5734") + .merchantCountry("US") + .merchantName("x") + .purchaseAmount(1000L) + .build() + ) + + cardPayment.validate() + } + + @Test + fun challengeAttempts() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardAuthenticationService = client.simulations().cardAuthentications() + + val cardPayment = + cardAuthenticationService.challengeAttempts( + CardAuthenticationChallengeAttemptsParams.builder() + .cardPaymentId("card_payment_nd3k2kacrqjli8482ave") + .oneTimeCode("123456") + .build() + ) + + cardPayment.validate() + } + + @Test + fun challenges() { + val client = + IncreaseOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My API Key") + .build() + val cardAuthenticationService = client.simulations().cardAuthentications() + + val cardPayment = cardAuthenticationService.challenges("card_payment_nd3k2kacrqjli8482ave") + + cardPayment.validate() + } +} From 61dc0bf1bb316db4f534c287f5c993226f13e419 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Mon, 2 Mar 2026 22:30:38 +0000 Subject: [PATCH 2/2] release: 0.439.0 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 8 ++++++++ README.md | 10 +++++----- build.gradle.kts | 2 +- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 3c933c245..2e06584a9 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.438.0" + ".": "0.439.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index def42c7c5..7b68f39c5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.439.0 (2026-03-02) + +Full Changelog: [v0.438.0...v0.439.0](https://github.com/Increase/increase-java/compare/v0.438.0...v0.439.0) + +### Features + +* **api:** api update ([421c44a](https://github.com/Increase/increase-java/commit/421c44a12d3fbd141ae1f197cdd55eb95431582d)) + ## 0.438.0 (2026-03-02) Full Changelog: [v0.437.0...v0.438.0](https://github.com/Increase/increase-java/compare/v0.437.0...v0.438.0) diff --git a/README.md b/README.md index b2fcf73c5..6b0081830 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.438.0) -[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.438.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.438.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.increase.api/increase-java)](https://central.sonatype.com/artifact/com.increase.api/increase-java/0.439.0) +[![javadoc](https://javadoc.io/badge2/com.increase.api/increase-java/0.439.0/javadoc.svg)](https://javadoc.io/doc/com.increase.api/increase-java/0.439.0) @@ -13,7 +13,7 @@ The Increase Java SDK is similar to the Increase Kotlin SDK but with minor diffe -The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.438.0). +The REST API documentation can be found on [increase.com](https://increase.com/documentation). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.increase.api/increase-java/0.439.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [increase.com](https://increase.com/d ### Gradle ```kotlin -implementation("com.increase.api:increase-java:0.438.0") +implementation("com.increase.api:increase-java:0.439.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.increase.api:increase-java:0.438.0") com.increase.api increase-java - 0.438.0 + 0.439.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 1bb7b2a25..b40615c24 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.increase.api" - version = "0.438.0" // x-release-please-version + version = "0.439.0" // x-release-please-version } subprojects {