From c0827300cc7751f0fff23d46c8e600a431916471 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 10 Sep 2025 23:47:14 +0000 Subject: [PATCH 1/2] feat(api): rename endpoint deprecate simulate_credit_authorization in favor of simulate_credit_authorization_advice --- .stats.yml | 2 +- ...SimulateCreditAuthorizationAdviceParams.kt | 732 ++++++++++++++++++ ...mulateCreditAuthorizationAdviceResponse.kt | 215 +++++ ...actionSimulateCreditAuthorizationParams.kt | 1 + .../services/async/TransactionServiceAsync.kt | 37 + .../async/TransactionServiceAsyncImpl.kt | 49 ++ .../services/blocking/TransactionService.kt | 38 + .../blocking/TransactionServiceImpl.kt | 42 + ...lateCreditAuthorizationAdviceParamsTest.kt | 56 ++ ...teCreditAuthorizationAdviceResponseTest.kt | 44 ++ .../async/TransactionServiceAsyncTest.kt | 25 + .../blocking/TransactionServiceTest.kt | 24 + 12 files changed, 1264 insertions(+), 1 deletion(-) create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceParams.kt create mode 100644 lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceResponse.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceParamsTest.kt create mode 100644 lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceResponseTest.kt diff --git a/.stats.yml b/.stats.yml index 829e46b33..fa389875f 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 169 openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-1d44bb7fad99487af1161eb24dfd5369440eda7e80ed237cbc1acc6802a7d212.yml openapi_spec_hash: 1b6b6215b60094b76b91c56b925a251a -config_hash: ac676e77c8ca051c7aad978c26e96345 +config_hash: e68a052fd109c0885732114753abc739 diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceParams.kt new file mode 100644 index 000000000..28f9c234c --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceParams.kt @@ -0,0 +1,732 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.Params +import com.lithic.api.core.checkRequired +import com.lithic.api.core.http.Headers +import com.lithic.api.core.http.QueryParams +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +/** + * Simulates a credit authorization advice from the card network. This message indicates that the + * network approved a credit authorization on your behalf. + */ +class TransactionSimulateCreditAuthorizationAdviceParams +private constructor( + private val body: Body, + private val additionalHeaders: Headers, + private val additionalQueryParams: QueryParams, +) : Params { + + /** + * Amount (in cents). Any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will appear as a -100 amount + * in the transaction. + * + * @throws LithicInvalidDataException 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 amount(): Long = body.amount() + + /** + * Merchant descriptor. + * + * @throws LithicInvalidDataException 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 descriptor(): String = body.descriptor() + + /** + * Sixteen digit card number. + * + * @throws LithicInvalidDataException 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 pan(): String = body.pan() + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcc(): Optional = body.mcc() + + /** + * Unique identifier to identify the payment card acceptor. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun merchantAcceptorId(): Optional = body.merchantAcceptorId() + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _amount(): JsonField = body._amount() + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _descriptor(): JsonField = body._descriptor() + + /** + * Returns the raw JSON value of [pan]. + * + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _pan(): JsonField = body._pan() + + /** + * Returns the raw JSON value of [mcc]. + * + * Unlike [mcc], this method doesn't throw if the JSON field has an unexpected type. + */ + fun _mcc(): JsonField = body._mcc() + + /** + * 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() + + 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 + * [TransactionSimulateCreditAuthorizationAdviceParams]. + * + * The following fields are required: + * ```java + * .amount() + * .descriptor() + * .pan() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TransactionSimulateCreditAuthorizationAdviceParams]. */ + 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( + transactionSimulateCreditAuthorizationAdviceParams: + TransactionSimulateCreditAuthorizationAdviceParams + ) = apply { + body = transactionSimulateCreditAuthorizationAdviceParams.body.toBuilder() + additionalHeaders = + transactionSimulateCreditAuthorizationAdviceParams.additionalHeaders.toBuilder() + additionalQueryParams = + transactionSimulateCreditAuthorizationAdviceParams.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: + * - [amount] + * - [descriptor] + * - [pan] + * - [mcc] + * - [merchantAcceptorId] + * - etc. + */ + fun body(body: Body) = apply { this.body = body.toBuilder() } + + /** + * Amount (in cents). Any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will appear as a -100 + * amount in the transaction. + */ + fun amount(amount: Long) = apply { body.amount(amount) } + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + + /** Merchant descriptor. */ + fun descriptor(descriptor: String) = apply { body.descriptor(descriptor) } + + /** + * Sets [Builder.descriptor] to an arbitrary JSON value. + * + * You should usually call [Builder.descriptor] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun descriptor(descriptor: JsonField) = apply { body.descriptor(descriptor) } + + /** Sixteen digit card number. */ + fun pan(pan: String) = apply { body.pan(pan) } + + /** + * Sets [Builder.pan] to an arbitrary JSON value. + * + * You should usually call [Builder.pan] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun pan(pan: JsonField) = apply { body.pan(pan) } + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun mcc(mcc: String) = apply { body.mcc(mcc) } + + /** + * Sets [Builder.mcc] to an arbitrary JSON value. + * + * You should usually call [Builder.mcc] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun mcc(mcc: JsonField) = apply { body.mcc(mcc) } + + /** Unique identifier to identify the payment card acceptor. */ + 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) + } + + 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 [TransactionSimulateCreditAuthorizationAdviceParams]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .amount() + * .descriptor() + * .pan() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TransactionSimulateCreditAuthorizationAdviceParams = + TransactionSimulateCreditAuthorizationAdviceParams( + body.build(), + additionalHeaders.build(), + additionalQueryParams.build(), + ) + } + + fun _body(): Body = body + + override fun _headers(): Headers = additionalHeaders + + override fun _queryParams(): QueryParams = additionalQueryParams + + class Body + private constructor( + private val amount: JsonField, + private val descriptor: JsonField, + private val pan: JsonField, + private val mcc: JsonField, + private val merchantAcceptorId: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("amount") @ExcludeMissing amount: JsonField = JsonMissing.of(), + @JsonProperty("descriptor") + @ExcludeMissing + descriptor: JsonField = JsonMissing.of(), + @JsonProperty("pan") @ExcludeMissing pan: JsonField = JsonMissing.of(), + @JsonProperty("mcc") @ExcludeMissing mcc: JsonField = JsonMissing.of(), + @JsonProperty("merchant_acceptor_id") + @ExcludeMissing + merchantAcceptorId: JsonField = JsonMissing.of(), + ) : this(amount, descriptor, pan, mcc, merchantAcceptorId, mutableMapOf()) + + /** + * Amount (in cents). Any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will appear as a -100 + * amount in the transaction. + * + * @throws LithicInvalidDataException 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 amount(): Long = amount.getRequired("amount") + + /** + * Merchant descriptor. + * + * @throws LithicInvalidDataException 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 descriptor(): String = descriptor.getRequired("descriptor") + + /** + * Sixteen digit card number. + * + * @throws LithicInvalidDataException 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 pan(): String = pan.getRequired("pan") + + /** + * Merchant category code for the transaction to be simulated. A four-digit number listed in + * ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun mcc(): Optional = mcc.getOptional("mcc") + + /** + * Unique identifier to identify the payment card acceptor. + * + * @throws LithicInvalidDataException 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") + + /** + * Returns the raw JSON value of [amount]. + * + * Unlike [amount], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** + * Returns the raw JSON value of [descriptor]. + * + * Unlike [descriptor], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("descriptor") + @ExcludeMissing + fun _descriptor(): JsonField = descriptor + + /** + * Returns the raw JSON value of [pan]. + * + * Unlike [pan], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("pan") @ExcludeMissing fun _pan(): JsonField = pan + + /** + * Returns the raw JSON value of [mcc]. + * + * Unlike [mcc], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mcc") @ExcludeMissing fun _mcc(): JsonField = mcc + + /** + * 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 + + @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 + * .amount() + * .descriptor() + * .pan() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Body]. */ + class Builder internal constructor() { + + private var amount: JsonField? = null + private var descriptor: JsonField? = null + private var pan: JsonField? = null + private var mcc: JsonField = JsonMissing.of() + private var merchantAcceptorId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(body: Body) = apply { + amount = body.amount + descriptor = body.descriptor + pan = body.pan + mcc = body.mcc + merchantAcceptorId = body.merchantAcceptorId + additionalProperties = body.additionalProperties.toMutableMap() + } + + /** + * Amount (in cents). Any value entered will be converted into a negative amount in the + * simulated transaction. For example, entering 100 in this field will appear as a -100 + * amount in the transaction. + */ + fun amount(amount: Long) = amount(JsonField.of(amount)) + + /** + * Sets [Builder.amount] to an arbitrary JSON value. + * + * You should usually call [Builder.amount] with a well-typed [Long] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** Merchant descriptor. */ + fun descriptor(descriptor: String) = descriptor(JsonField.of(descriptor)) + + /** + * Sets [Builder.descriptor] to an arbitrary JSON value. + * + * You should usually call [Builder.descriptor] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun descriptor(descriptor: JsonField) = apply { this.descriptor = descriptor } + + /** Sixteen digit card number. */ + fun pan(pan: String) = pan(JsonField.of(pan)) + + /** + * Sets [Builder.pan] to an arbitrary JSON value. + * + * You should usually call [Builder.pan] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun pan(pan: JsonField) = apply { this.pan = pan } + + /** + * Merchant category code for the transaction to be simulated. A four-digit number + * listed in ISO 18245. Supported merchant category codes can be found + * [here](https://docs.lithic.com/docs/transactions#merchant-category-codes-mccs). + */ + fun mcc(mcc: String) = mcc(JsonField.of(mcc)) + + /** + * Sets [Builder.mcc] to an arbitrary JSON value. + * + * You should usually call [Builder.mcc] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun mcc(mcc: JsonField) = apply { this.mcc = mcc } + + /** Unique identifier to identify the payment card acceptor. */ + 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 + } + + 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 + * .amount() + * .descriptor() + * .pan() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Body = + Body( + checkRequired("amount", amount), + checkRequired("descriptor", descriptor), + checkRequired("pan", pan), + mcc, + merchantAcceptorId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): Body = apply { + if (validated) { + return@apply + } + + amount() + descriptor() + pan() + mcc() + merchantAcceptorId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (amount.asKnown().isPresent) 1 else 0) + + (if (descriptor.asKnown().isPresent) 1 else 0) + + (if (pan.asKnown().isPresent) 1 else 0) + + (if (mcc.asKnown().isPresent) 1 else 0) + + (if (merchantAcceptorId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Body && + amount == other.amount && + descriptor == other.descriptor && + pan == other.pan && + mcc == other.mcc && + merchantAcceptorId == other.merchantAcceptorId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(amount, descriptor, pan, mcc, merchantAcceptorId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "Body{amount=$amount, descriptor=$descriptor, pan=$pan, mcc=$mcc, merchantAcceptorId=$merchantAcceptorId, additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionSimulateCreditAuthorizationAdviceParams && + body == other.body && + additionalHeaders == other.additionalHeaders && + additionalQueryParams == other.additionalQueryParams + } + + override fun hashCode(): Int = Objects.hash(body, additionalHeaders, additionalQueryParams) + + override fun toString() = + "TransactionSimulateCreditAuthorizationAdviceParams{body=$body, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceResponse.kt new file mode 100644 index 000000000..eccc96cec --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceResponse.kt @@ -0,0 +1,215 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional + +class TransactionSimulateCreditAuthorizationAdviceResponse +private constructor( + private val token: JsonField, + private val debuggingRequestId: JsonField, + private val additionalProperties: MutableMap, +) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("debugging_request_id") + @ExcludeMissing + debuggingRequestId: JsonField = JsonMissing.of(), + ) : this(token, debuggingRequestId, mutableMapOf()) + + /** + * A unique token to reference this transaction. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun token(): Optional = token.getOptional("token") + + /** + * Debugging request ID to share with Lithic Support team. + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun debuggingRequestId(): Optional = + debuggingRequestId.getOptional("debugging_request_id") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [debuggingRequestId]. + * + * Unlike [debuggingRequestId], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("debugging_request_id") + @ExcludeMissing + fun _debuggingRequestId(): JsonField = debuggingRequestId + + @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 + * [TransactionSimulateCreditAuthorizationAdviceResponse]. + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TransactionSimulateCreditAuthorizationAdviceResponse]. */ + class Builder internal constructor() { + + private var token: JsonField = JsonMissing.of() + private var debuggingRequestId: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + transactionSimulateCreditAuthorizationAdviceResponse: + TransactionSimulateCreditAuthorizationAdviceResponse + ) = apply { + token = transactionSimulateCreditAuthorizationAdviceResponse.token + debuggingRequestId = + transactionSimulateCreditAuthorizationAdviceResponse.debuggingRequestId + additionalProperties = + transactionSimulateCreditAuthorizationAdviceResponse.additionalProperties + .toMutableMap() + } + + /** A unique token to reference this transaction. */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Debugging request ID to share with Lithic Support team. */ + fun debuggingRequestId(debuggingRequestId: String) = + debuggingRequestId(JsonField.of(debuggingRequestId)) + + /** + * Sets [Builder.debuggingRequestId] to an arbitrary JSON value. + * + * You should usually call [Builder.debuggingRequestId] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun debuggingRequestId(debuggingRequestId: JsonField) = apply { + this.debuggingRequestId = debuggingRequestId + } + + 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 [TransactionSimulateCreditAuthorizationAdviceResponse]. + * + * Further updates to this [Builder] will not mutate the returned instance. + */ + fun build(): TransactionSimulateCreditAuthorizationAdviceResponse = + TransactionSimulateCreditAuthorizationAdviceResponse( + token, + debuggingRequestId, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + fun validate(): TransactionSimulateCreditAuthorizationAdviceResponse = apply { + if (validated) { + return@apply + } + + token() + debuggingRequestId() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + 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 (token.asKnown().isPresent) 1 else 0) + + (if (debuggingRequestId.asKnown().isPresent) 1 else 0) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TransactionSimulateCreditAuthorizationAdviceResponse && + token == other.token && + debuggingRequestId == other.debuggingRequestId && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(token, debuggingRequestId, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TransactionSimulateCreditAuthorizationAdviceResponse{token=$token, debuggingRequestId=$debuggingRequestId, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationParams.kt index a6eec12f5..d1fcdc0e1 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationParams.kt @@ -23,6 +23,7 @@ import java.util.Optional * Simulates a credit authorization advice from the card network. This message indicates that the * network approved a credit authorization on your behalf. */ +@Deprecated("use `simulateCreditAuthorizationAdvice` instead") class TransactionSimulateCreditAuthorizationParams private constructor( private val body: Body, diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsync.kt index 965f06018..a3ebd98d4 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsync.kt @@ -17,6 +17,8 @@ import com.lithic.api.models.TransactionSimulateAuthorizationParams import com.lithic.api.models.TransactionSimulateAuthorizationResponse import com.lithic.api.models.TransactionSimulateClearingParams import com.lithic.api.models.TransactionSimulateClearingResponse +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceParams +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceResponse import com.lithic.api.models.TransactionSimulateCreditAuthorizationParams import com.lithic.api.models.TransactionSimulateCreditAuthorizationResponse import com.lithic.api.models.TransactionSimulateReturnParams @@ -207,17 +209,34 @@ interface TransactionServiceAsync { * Simulates a credit authorization advice from the card network. This message indicates that * the network approved a credit authorization on your behalf. */ + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams ): CompletableFuture = simulateCreditAuthorization(params, RequestOptions.none()) /** @see simulateCreditAuthorization */ + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture + /** + * Simulates a credit authorization advice from the card network. This message indicates that + * the network approved a credit authorization on your behalf. + */ + fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams + ): CompletableFuture = + simulateCreditAuthorizationAdvice(params, RequestOptions.none()) + + /** @see simulateCreditAuthorizationAdvice */ + fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture + /** * Returns, or refunds, an amount back to a card. Returns simulated via this endpoint clear * immediately, without prior authorization, and result in a `SETTLED` transaction status. @@ -448,17 +467,35 @@ interface TransactionServiceAsync { * Returns a raw HTTP response for `post /v1/simulate/credit_authorization_advice`, but is * otherwise the same as [TransactionServiceAsync.simulateCreditAuthorization]. */ + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams ): CompletableFuture> = simulateCreditAuthorization(params, RequestOptions.none()) /** @see simulateCreditAuthorization */ + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, requestOptions: RequestOptions = RequestOptions.none(), ): CompletableFuture> + /** + * Returns a raw HTTP response for `post /v1/simulate/credit_authorization_advice`, but is + * otherwise the same as [TransactionServiceAsync.simulateCreditAuthorizationAdvice]. + */ + fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams + ): CompletableFuture< + HttpResponseFor + > = simulateCreditAuthorizationAdvice(params, RequestOptions.none()) + + /** @see simulateCreditAuthorizationAdvice */ + fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): CompletableFuture> + /** * Returns a raw HTTP response for `post /v1/simulate/return`, but is otherwise the same as * [TransactionServiceAsync.simulateReturn]. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsyncImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsyncImpl.kt index 75f5fc07e..18869d803 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsyncImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/async/TransactionServiceAsyncImpl.kt @@ -29,6 +29,8 @@ import com.lithic.api.models.TransactionSimulateAuthorizationParams import com.lithic.api.models.TransactionSimulateAuthorizationResponse import com.lithic.api.models.TransactionSimulateClearingParams import com.lithic.api.models.TransactionSimulateClearingResponse +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceParams +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceResponse import com.lithic.api.models.TransactionSimulateCreditAuthorizationParams import com.lithic.api.models.TransactionSimulateCreditAuthorizationResponse import com.lithic.api.models.TransactionSimulateReturnParams @@ -112,6 +114,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions // post /v1/simulate/clearing withRawResponse().simulateClearing(params, requestOptions).thenApply { it.parse() } + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") override fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, requestOptions: RequestOptions, @@ -121,6 +124,15 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions it.parse() } + override fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams, + requestOptions: RequestOptions, + ): CompletableFuture = + // post /v1/simulate/credit_authorization_advice + withRawResponse().simulateCreditAuthorizationAdvice(params, requestOptions).thenApply { + it.parse() + } + override fun simulateReturn( params: TransactionSimulateReturnParams, requestOptions: RequestOptions, @@ -371,6 +383,7 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions Handler = jsonHandler(clientOptions.jsonMapper) + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") override fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, requestOptions: RequestOptions, @@ -399,6 +412,42 @@ class TransactionServiceAsyncImpl internal constructor(private val clientOptions } } + private val simulateCreditAuthorizationAdviceHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper + ) + + override fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams, + requestOptions: RequestOptions, + ): CompletableFuture< + HttpResponseFor + > { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "simulate", "credit_authorization_advice") + .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 { simulateCreditAuthorizationAdviceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + } + private val simulateReturnHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionService.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionService.kt index 3638017a8..731d26485 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionService.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionService.kt @@ -18,6 +18,8 @@ import com.lithic.api.models.TransactionSimulateAuthorizationParams import com.lithic.api.models.TransactionSimulateAuthorizationResponse import com.lithic.api.models.TransactionSimulateClearingParams import com.lithic.api.models.TransactionSimulateClearingResponse +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceParams +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceResponse import com.lithic.api.models.TransactionSimulateCreditAuthorizationParams import com.lithic.api.models.TransactionSimulateCreditAuthorizationResponse import com.lithic.api.models.TransactionSimulateReturnParams @@ -197,17 +199,34 @@ interface TransactionService { * Simulates a credit authorization advice from the card network. This message indicates that * the network approved a credit authorization on your behalf. */ + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams ): TransactionSimulateCreditAuthorizationResponse = simulateCreditAuthorization(params, RequestOptions.none()) /** @see simulateCreditAuthorization */ + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, requestOptions: RequestOptions = RequestOptions.none(), ): TransactionSimulateCreditAuthorizationResponse + /** + * Simulates a credit authorization advice from the card network. This message indicates that + * the network approved a credit authorization on your behalf. + */ + fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams + ): TransactionSimulateCreditAuthorizationAdviceResponse = + simulateCreditAuthorizationAdvice(params, RequestOptions.none()) + + /** @see simulateCreditAuthorizationAdvice */ + fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): TransactionSimulateCreditAuthorizationAdviceResponse + /** * Returns, or refunds, an amount back to a card. Returns simulated via this endpoint clear * immediately, without prior authorization, and result in a `SETTLED` transaction status. @@ -447,6 +466,7 @@ interface TransactionService { * Returns a raw HTTP response for `post /v1/simulate/credit_authorization_advice`, but is * otherwise the same as [TransactionService.simulateCreditAuthorization]. */ + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") @MustBeClosed fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams @@ -454,12 +474,30 @@ interface TransactionService { simulateCreditAuthorization(params, RequestOptions.none()) /** @see simulateCreditAuthorization */ + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") @MustBeClosed fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, requestOptions: RequestOptions = RequestOptions.none(), ): HttpResponseFor + /** + * Returns a raw HTTP response for `post /v1/simulate/credit_authorization_advice`, but is + * otherwise the same as [TransactionService.simulateCreditAuthorizationAdvice]. + */ + @MustBeClosed + fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams + ): HttpResponseFor = + simulateCreditAuthorizationAdvice(params, RequestOptions.none()) + + /** @see simulateCreditAuthorizationAdvice */ + @MustBeClosed + fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams, + requestOptions: RequestOptions = RequestOptions.none(), + ): HttpResponseFor + /** * Returns a raw HTTP response for `post /v1/simulate/return`, but is otherwise the same as * [TransactionService.simulateReturn]. diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionServiceImpl.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionServiceImpl.kt index 76f3e2a6f..8475c77d5 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionServiceImpl.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/services/blocking/TransactionServiceImpl.kt @@ -29,6 +29,8 @@ import com.lithic.api.models.TransactionSimulateAuthorizationParams import com.lithic.api.models.TransactionSimulateAuthorizationResponse import com.lithic.api.models.TransactionSimulateClearingParams import com.lithic.api.models.TransactionSimulateClearingResponse +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceParams +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceResponse import com.lithic.api.models.TransactionSimulateCreditAuthorizationParams import com.lithic.api.models.TransactionSimulateCreditAuthorizationResponse import com.lithic.api.models.TransactionSimulateReturnParams @@ -109,6 +111,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli // post /v1/simulate/clearing withRawResponse().simulateClearing(params, requestOptions).parse() + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") override fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, requestOptions: RequestOptions, @@ -116,6 +119,13 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli // post /v1/simulate/credit_authorization_advice withRawResponse().simulateCreditAuthorization(params, requestOptions).parse() + override fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams, + requestOptions: RequestOptions, + ): TransactionSimulateCreditAuthorizationAdviceResponse = + // post /v1/simulate/credit_authorization_advice + withRawResponse().simulateCreditAuthorizationAdvice(params, requestOptions).parse() + override fun simulateReturn( params: TransactionSimulateReturnParams, requestOptions: RequestOptions, @@ -346,6 +356,7 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli Handler = jsonHandler(clientOptions.jsonMapper) + @Deprecated("use `simulateCreditAuthorizationAdvice` instead") override fun simulateCreditAuthorization( params: TransactionSimulateCreditAuthorizationParams, requestOptions: RequestOptions, @@ -371,6 +382,37 @@ class TransactionServiceImpl internal constructor(private val clientOptions: Cli } } + private val simulateCreditAuthorizationAdviceHandler: + Handler = + jsonHandler( + clientOptions.jsonMapper + ) + + override fun simulateCreditAuthorizationAdvice( + params: TransactionSimulateCreditAuthorizationAdviceParams, + requestOptions: RequestOptions, + ): HttpResponseFor { + val request = + HttpRequest.builder() + .method(HttpMethod.POST) + .baseUrl(clientOptions.baseUrl()) + .addPathSegments("v1", "simulate", "credit_authorization_advice") + .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 { simulateCreditAuthorizationAdviceHandler.handle(it) } + .also { + if (requestOptions.responseValidation!!) { + it.validate() + } + } + } + } + private val simulateReturnHandler: Handler = jsonHandler(clientOptions.jsonMapper) diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceParamsTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceParamsTest.kt new file mode 100644 index 000000000..5b6d8bfc8 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceParamsTest.kt @@ -0,0 +1,56 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TransactionSimulateCreditAuthorizationAdviceParamsTest { + + @Test + fun create() { + TransactionSimulateCreditAuthorizationAdviceParams.builder() + .amount(3831L) + .descriptor("COFFEE SHOP") + .pan("4111111289144142") + .mcc("5812") + .merchantAcceptorId("XRKGDPOWEWQRRWU") + .build() + } + + @Test + fun body() { + val params = + TransactionSimulateCreditAuthorizationAdviceParams.builder() + .amount(3831L) + .descriptor("COFFEE SHOP") + .pan("4111111289144142") + .mcc("5812") + .merchantAcceptorId("XRKGDPOWEWQRRWU") + .build() + + val body = params._body() + + assertThat(body.amount()).isEqualTo(3831L) + assertThat(body.descriptor()).isEqualTo("COFFEE SHOP") + assertThat(body.pan()).isEqualTo("4111111289144142") + assertThat(body.mcc()).contains("5812") + assertThat(body.merchantAcceptorId()).contains("XRKGDPOWEWQRRWU") + } + + @Test + fun bodyWithoutOptionalFields() { + val params = + TransactionSimulateCreditAuthorizationAdviceParams.builder() + .amount(3831L) + .descriptor("COFFEE SHOP") + .pan("4111111289144142") + .build() + + val body = params._body() + + assertThat(body.amount()).isEqualTo(3831L) + assertThat(body.descriptor()).isEqualTo("COFFEE SHOP") + assertThat(body.pan()).isEqualTo("4111111289144142") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceResponseTest.kt new file mode 100644 index 000000000..bb7386a28 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/TransactionSimulateCreditAuthorizationAdviceResponseTest.kt @@ -0,0 +1,44 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class TransactionSimulateCreditAuthorizationAdviceResponseTest { + + @Test + fun create() { + val transactionSimulateCreditAuthorizationAdviceResponse = + TransactionSimulateCreditAuthorizationAdviceResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .debuggingRequestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + assertThat(transactionSimulateCreditAuthorizationAdviceResponse.token()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + assertThat(transactionSimulateCreditAuthorizationAdviceResponse.debuggingRequestId()) + .contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val transactionSimulateCreditAuthorizationAdviceResponse = + TransactionSimulateCreditAuthorizationAdviceResponse.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .debuggingRequestId("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val roundtrippedTransactionSimulateCreditAuthorizationAdviceResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(transactionSimulateCreditAuthorizationAdviceResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedTransactionSimulateCreditAuthorizationAdviceResponse) + .isEqualTo(transactionSimulateCreditAuthorizationAdviceResponse) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/TransactionServiceAsyncTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/TransactionServiceAsyncTest.kt index 4451cd2a7..4387e2e78 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/TransactionServiceAsyncTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/async/TransactionServiceAsyncTest.kt @@ -7,6 +7,7 @@ import com.lithic.api.client.okhttp.LithicOkHttpClientAsync import com.lithic.api.models.TransactionSimulateAuthorizationAdviceParams import com.lithic.api.models.TransactionSimulateAuthorizationParams import com.lithic.api.models.TransactionSimulateClearingParams +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceParams import com.lithic.api.models.TransactionSimulateCreditAuthorizationParams import com.lithic.api.models.TransactionSimulateReturnParams import com.lithic.api.models.TransactionSimulateReturnReversalParams @@ -158,6 +159,30 @@ internal class TransactionServiceAsyncTest { response.validate() } + @Test + fun simulateCreditAuthorizationAdvice() { + val client = + LithicOkHttpClientAsync.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val transactionServiceAsync = client.transactions() + + val responseFuture = + transactionServiceAsync.simulateCreditAuthorizationAdvice( + TransactionSimulateCreditAuthorizationAdviceParams.builder() + .amount(3831L) + .descriptor("COFFEE SHOP") + .pan("4111111289144142") + .mcc("5812") + .merchantAcceptorId("XRKGDPOWEWQRRWU") + .build() + ) + + val response = responseFuture.get() + response.validate() + } + @Test fun simulateReturn() { val client = diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/TransactionServiceTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/TransactionServiceTest.kt index 5f8d5379e..bd30db2f7 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/TransactionServiceTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/services/blocking/TransactionServiceTest.kt @@ -7,6 +7,7 @@ import com.lithic.api.client.okhttp.LithicOkHttpClient import com.lithic.api.models.TransactionSimulateAuthorizationAdviceParams import com.lithic.api.models.TransactionSimulateAuthorizationParams import com.lithic.api.models.TransactionSimulateClearingParams +import com.lithic.api.models.TransactionSimulateCreditAuthorizationAdviceParams import com.lithic.api.models.TransactionSimulateCreditAuthorizationParams import com.lithic.api.models.TransactionSimulateReturnParams import com.lithic.api.models.TransactionSimulateReturnReversalParams @@ -148,6 +149,29 @@ internal class TransactionServiceTest { response.validate() } + @Test + fun simulateCreditAuthorizationAdvice() { + val client = + LithicOkHttpClient.builder() + .baseUrl(TestServerExtension.BASE_URL) + .apiKey("My Lithic API Key") + .build() + val transactionService = client.transactions() + + val response = + transactionService.simulateCreditAuthorizationAdvice( + TransactionSimulateCreditAuthorizationAdviceParams.builder() + .amount(3831L) + .descriptor("COFFEE SHOP") + .pan("4111111289144142") + .mcc("5812") + .merchantAcceptorId("XRKGDPOWEWQRRWU") + .build() + ) + + response.validate() + } + @Test fun simulateReturn() { val client = From f830673411f005c10269d08cbde979a5b24e37a9 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Wed, 10 Sep 2025 23:47:39 +0000 Subject: [PATCH 2/2] release: 0.105.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 19c0e9cca..6b28bdb22 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.104.0" + ".": "0.105.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b01a30fc..0c6e3d650 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.105.0 (2025-09-10) + +Full Changelog: [v0.104.0...v0.105.0](https://github.com/lithic-com/lithic-java/compare/v0.104.0...v0.105.0) + +### Features + +* **api:** rename endpoint ([c082730](https://github.com/lithic-com/lithic-java/commit/c0827300cc7751f0fff23d46c8e600a431916471)) + ## 0.104.0 (2025-09-09) Full Changelog: [v0.103.0...v0.104.0](https://github.com/lithic-com/lithic-java/compare/v0.103.0...v0.104.0) diff --git a/README.md b/README.md index 622f13707..003c9c7d4 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.104.0) -[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.104.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.104.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.105.0) +[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.105.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.105.0) @@ -13,7 +13,7 @@ The Lithic Java SDK is similar to the Lithic Kotlin SDK but with minor differenc -The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.104.0). +The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.105.0). @@ -24,7 +24,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic ### Gradle ```kotlin -implementation("com.lithic.api:lithic-java:0.104.0") +implementation("com.lithic.api:lithic-java:0.105.0") ``` ### Maven @@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.104.0") com.lithic.api lithic-java - 0.104.0 + 0.105.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index f72139c39..fe036afff 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.lithic.api" - version = "0.104.0" // x-release-please-version + version = "0.105.0" // x-release-please-version } subprojects {