com.lithic.api.models.TransactionSimulateVoidParams.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of lithic-java-core Show documentation
Show all versions of lithic-java-core Show documentation
The Lithic Developer API is designed to provide a predictable programmatic
interface for accessing your Lithic account through an API and transaction
webhooks. Note that your API key is a secret and should be treated as such.
Don't share it with anyone, including us. We will never ask you for it.
// 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.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.lithic.api.core.Enum
import com.lithic.api.core.ExcludeMissing
import com.lithic.api.core.JsonField
import com.lithic.api.core.JsonValue
import com.lithic.api.core.NoAutoDetect
import com.lithic.api.core.toUnmodifiable
import com.lithic.api.errors.LithicInvalidDataException
import com.lithic.api.models.*
import java.util.Objects
import java.util.Optional
class TransactionSimulateVoidParams
constructor(
private val token: String,
private val amount: Long?,
private val type: Type?,
private val additionalQueryParams: Map>,
private val additionalHeaders: Map>,
private val additionalBodyProperties: Map,
) {
fun token(): String = token
fun amount(): Optional = Optional.ofNullable(amount)
fun type(): Optional = Optional.ofNullable(type)
@JvmSynthetic
internal fun getBody(): TransactionSimulateVoidBody {
return TransactionSimulateVoidBody(
token,
amount,
type,
additionalBodyProperties,
)
}
@JvmSynthetic internal fun getQueryParams(): Map> = additionalQueryParams
@JvmSynthetic internal fun getHeaders(): Map> = additionalHeaders
@JsonDeserialize(builder = TransactionSimulateVoidBody.Builder::class)
@NoAutoDetect
class TransactionSimulateVoidBody
internal constructor(
private val token: String?,
private val amount: Long?,
private val type: Type?,
private val additionalProperties: Map,
) {
/** The transaction token returned from the /v1/simulate/authorize response. */
@JsonProperty("token") fun token(): String? = token
/**
* Amount (in cents) to void. Typically this will match the original authorization, but may
* be less.
*/
@JsonProperty("amount") fun amount(): Long? = amount
/**
* Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`.
* - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by Lithic.
* - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant.
*/
@JsonProperty("type") fun type(): Type? = type
@JsonAnyGetter
@ExcludeMissing
fun _additionalProperties(): Map = additionalProperties
fun toBuilder() = Builder().from(this)
companion object {
@JvmStatic fun builder() = Builder()
}
class Builder {
private var token: String? = null
private var amount: Long? = null
private var type: Type? = null
private var additionalProperties: MutableMap = mutableMapOf()
@JvmSynthetic
internal fun from(transactionSimulateVoidBody: TransactionSimulateVoidBody) = apply {
this.token = transactionSimulateVoidBody.token
this.amount = transactionSimulateVoidBody.amount
this.type = transactionSimulateVoidBody.type
additionalProperties(transactionSimulateVoidBody.additionalProperties)
}
/** The transaction token returned from the /v1/simulate/authorize response. */
@JsonProperty("token") fun token(token: String) = apply { this.token = token }
/**
* Amount (in cents) to void. Typically this will match the original authorization, but
* may be less.
*/
@JsonProperty("amount") fun amount(amount: Long) = apply { this.amount = amount }
/**
* Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`.
* - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by
* Lithic.
* - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant.
*/
@JsonProperty("type") fun type(type: Type) = apply { this.type = type }
fun additionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.clear()
this.additionalProperties.putAll(additionalProperties)
}
@JsonAnySetter
fun putAdditionalProperty(key: String, value: JsonValue) = apply {
this.additionalProperties.put(key, value)
}
fun putAllAdditionalProperties(additionalProperties: Map) = apply {
this.additionalProperties.putAll(additionalProperties)
}
fun build(): TransactionSimulateVoidBody =
TransactionSimulateVoidBody(
checkNotNull(token) { "`token` is required but was not set" },
amount,
type,
additionalProperties.toUnmodifiable(),
)
}
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return /* spotless:off */ other is TransactionSimulateVoidBody && this.token == other.token && this.amount == other.amount && this.type == other.type && this.additionalProperties == other.additionalProperties /* spotless:on */
}
private var hashCode: Int = 0
override fun hashCode(): Int {
if (hashCode == 0) {
hashCode = /* spotless:off */ Objects.hash(token, amount, type, additionalProperties) /* spotless:on */
}
return hashCode
}
override fun toString() =
"TransactionSimulateVoidBody{token=$token, amount=$amount, type=$type, additionalProperties=$additionalProperties}"
}
fun _additionalQueryParams(): Map> = additionalQueryParams
fun _additionalHeaders(): Map> = additionalHeaders
fun _additionalBodyProperties(): Map = additionalBodyProperties
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return /* spotless:off */ other is TransactionSimulateVoidParams && this.token == other.token && this.amount == other.amount && this.type == other.type && this.additionalQueryParams == other.additionalQueryParams && this.additionalHeaders == other.additionalHeaders && this.additionalBodyProperties == other.additionalBodyProperties /* spotless:on */
}
override fun hashCode(): Int {
return /* spotless:off */ Objects.hash(token, amount, type, additionalQueryParams, additionalHeaders, additionalBodyProperties) /* spotless:on */
}
override fun toString() =
"TransactionSimulateVoidParams{token=$token, amount=$amount, type=$type, additionalQueryParams=$additionalQueryParams, additionalHeaders=$additionalHeaders, additionalBodyProperties=$additionalBodyProperties}"
fun toBuilder() = Builder().from(this)
companion object {
@JvmStatic fun builder() = Builder()
}
@NoAutoDetect
class Builder {
private var token: String? = null
private var amount: Long? = null
private var type: Type? = null
private var additionalQueryParams: MutableMap> = mutableMapOf()
private var additionalHeaders: MutableMap> = mutableMapOf()
private var additionalBodyProperties: MutableMap = mutableMapOf()
@JvmSynthetic
internal fun from(transactionSimulateVoidParams: TransactionSimulateVoidParams) = apply {
this.token = transactionSimulateVoidParams.token
this.amount = transactionSimulateVoidParams.amount
this.type = transactionSimulateVoidParams.type
additionalQueryParams(transactionSimulateVoidParams.additionalQueryParams)
additionalHeaders(transactionSimulateVoidParams.additionalHeaders)
additionalBodyProperties(transactionSimulateVoidParams.additionalBodyProperties)
}
/** The transaction token returned from the /v1/simulate/authorize response. */
fun token(token: String) = apply { this.token = token }
/**
* Amount (in cents) to void. Typically this will match the original authorization, but may
* be less.
*/
fun amount(amount: Long) = apply { this.amount = amount }
/**
* Type of event to simulate. Defaults to `AUTHORIZATION_REVERSAL`.
* - `AUTHORIZATION_EXPIRY` indicates authorization has expired and been reversed by Lithic.
* - `AUTHORIZATION_REVERSAL` indicates authorization was reversed by the merchant.
*/
fun type(type: Type) = apply { this.type = type }
fun additionalQueryParams(additionalQueryParams: Map>) = apply {
this.additionalQueryParams.clear()
putAllQueryParams(additionalQueryParams)
}
fun putQueryParam(name: String, value: String) = apply {
this.additionalQueryParams.getOrPut(name) { mutableListOf() }.add(value)
}
fun putQueryParams(name: String, values: Iterable) = apply {
this.additionalQueryParams.getOrPut(name) { mutableListOf() }.addAll(values)
}
fun putAllQueryParams(additionalQueryParams: Map>) = apply {
additionalQueryParams.forEach(this::putQueryParams)
}
fun removeQueryParam(name: String) = apply {
this.additionalQueryParams.put(name, mutableListOf())
}
fun additionalHeaders(additionalHeaders: Map>) = apply {
this.additionalHeaders.clear()
putAllHeaders(additionalHeaders)
}
fun putHeader(name: String, value: String) = apply {
this.additionalHeaders.getOrPut(name) { mutableListOf() }.add(value)
}
fun putHeaders(name: String, values: Iterable) = apply {
this.additionalHeaders.getOrPut(name) { mutableListOf() }.addAll(values)
}
fun putAllHeaders(additionalHeaders: Map>) = apply {
additionalHeaders.forEach(this::putHeaders)
}
fun removeHeader(name: String) = apply { this.additionalHeaders.put(name, mutableListOf()) }
fun additionalBodyProperties(additionalBodyProperties: Map) = apply {
this.additionalBodyProperties.clear()
this.additionalBodyProperties.putAll(additionalBodyProperties)
}
fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply {
this.additionalBodyProperties.put(key, value)
}
fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) =
apply {
this.additionalBodyProperties.putAll(additionalBodyProperties)
}
fun build(): TransactionSimulateVoidParams =
TransactionSimulateVoidParams(
checkNotNull(token) { "`token` is required but was not set" },
amount,
type,
additionalQueryParams.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
additionalBodyProperties.toUnmodifiable(),
)
}
class Type
@JsonCreator
private constructor(
private val value: JsonField,
) : Enum {
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField = value
override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
return /* spotless:off */ other is Type && this.value == other.value /* spotless:on */
}
override fun hashCode() = value.hashCode()
override fun toString() = value.toString()
companion object {
@JvmField val AUTHORIZATION_EXPIRY = Type(JsonField.of("AUTHORIZATION_EXPIRY"))
@JvmField val AUTHORIZATION_REVERSAL = Type(JsonField.of("AUTHORIZATION_REVERSAL"))
@JvmStatic fun of(value: String) = Type(JsonField.of(value))
}
enum class Known {
AUTHORIZATION_EXPIRY,
AUTHORIZATION_REVERSAL,
}
enum class Value {
AUTHORIZATION_EXPIRY,
AUTHORIZATION_REVERSAL,
_UNKNOWN,
}
fun value(): Value =
when (this) {
AUTHORIZATION_EXPIRY -> Value.AUTHORIZATION_EXPIRY
AUTHORIZATION_REVERSAL -> Value.AUTHORIZATION_REVERSAL
else -> Value._UNKNOWN
}
fun known(): Known =
when (this) {
AUTHORIZATION_EXPIRY -> Known.AUTHORIZATION_EXPIRY
AUTHORIZATION_REVERSAL -> Known.AUTHORIZATION_REVERSAL
else -> throw LithicInvalidDataException("Unknown Type: $value")
}
fun asString(): String = _value().asStringOrThrow()
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy