diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index dbeb1ee3c..2292ca706 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,3 +1,3 @@
{
- ".": "0.94.1"
+ ".": "0.95.0"
}
\ No newline at end of file
diff --git a/.stats.yml b/.stats.yml
index dc05581d2..b57de73da 100644
--- a/.stats.yml
+++ b/.stats.yml
@@ -1,4 +1,4 @@
configured_endpoints: 165
-openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-aa684ff2a2af585fe502a6e44520ddd883f5141a1113fc9dbe7830027842aa09.yml
-openapi_spec_hash: b58989fdc04768fc1eb758e180c5f128
-config_hash: 1a83dceb58f6f525b19a5775018db7e8
+openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic%2Flithic-41b87f6139d55188993492b9c042a6bc1bc0506c166334c387072b57b6c79869.yml
+openapi_spec_hash: 3327246caf3bcbd3504ce99c81062075
+config_hash: b7425db12ddcc27a89a38de7042c4fa2
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5f3bb4369..c5f786210 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,26 @@
# Changelog
+## 0.95.0 (2025-07-08)
+
+Full Changelog: [v0.94.1...v0.95.0](https://github.com/lithic-com/lithic-java/compare/v0.94.1...v0.95.0)
+
+### Features
+
+* **api:** add models for merchant_lock_parameters and conditional_3ds_action_parameters ([b59636c](https://github.com/lithic-com/lithic-java/commit/b59636c2cb89ade70cf550def6e9725bc1b12543))
+* **api:** api update ([e2c3beb](https://github.com/lithic-com/lithic-java/commit/e2c3beb77d4ad2fe19de8b912c2ed76cb18cfc4c))
+* **api:** api update ([18b0eaf](https://github.com/lithic-com/lithic-java/commit/18b0eafd592ef69be6a1908fad502beb11a85091))
+* **api:** api update ([999bba7](https://github.com/lithic-com/lithic-java/commit/999bba7db4343cf712dffde3201210a871772007))
+
+
+### Bug Fixes
+
+* **api:** name conflict between type and account type ([17cd5ef](https://github.com/lithic-com/lithic-java/commit/17cd5ef02e671bd45043c16dc447c6ce51af65e2))
+
+
+### Refactors
+
+* **internal:** minor `ClientOptionsTest` change ([017f196](https://github.com/lithic-com/lithic-java/commit/017f196c2c6801484b43f0ee54f2f5764ed22560))
+
## 0.94.1 (2025-06-29)
Full Changelog: [v0.94.0...v0.94.1](https://github.com/lithic-com/lithic-java/compare/v0.94.0...v0.94.1)
diff --git a/README.md b/README.md
index d98d067b5..f7901d551 100644
--- a/README.md
+++ b/README.md
@@ -2,8 +2,8 @@
-[](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.94.1)
-[](https://javadoc.io/doc/com.lithic.api/lithic-java/0.94.1)
+[](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.95.0)
+[](https://javadoc.io/doc/com.lithic.api/lithic-java/0.95.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.94.1).
+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.95.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.94.1")
+implementation("com.lithic.api:lithic-java:0.95.0")
```
### Maven
@@ -33,7 +33,7 @@ implementation("com.lithic.api:lithic-java:0.94.1")
com.lithic.api
lithic-java
- 0.94.1
+ 0.95.0
```
diff --git a/build.gradle.kts b/build.gradle.kts
index 2ec19e53c..66686cd44 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -8,7 +8,7 @@ repositories {
allprojects {
group = "com.lithic.api"
- version = "0.94.1" // x-release-please-version
+ version = "0.95.0" // x-release-please-version
}
subprojects {
diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt
index 33b3d1ed2..50e2c94f8 100644
--- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt
+++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2CreateParams.kt
@@ -685,14 +685,14 @@ private constructor(
/**
* Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`.
*/
- fun parameters(merchantLock: Parameters.MerchantLockParameters) =
+ fun parameters(merchantLock: MerchantLockParameters) =
parameters(Parameters.ofMerchantLock(merchantLock))
/**
* Alias for calling [parameters] with
* `Parameters.ofConditional3dsAction(conditional3dsAction)`.
*/
- fun parameters(conditional3dsAction: Parameters.Conditional3dsActionParameters) =
+ fun parameters(conditional3dsAction: Conditional3dsActionParameters) =
parameters(Parameters.ofConditional3dsAction(conditional3dsAction))
/**
@@ -1058,1755 +1058,796 @@ private constructor(
}
}
}
+ }
- class MerchantLockParameters
- private constructor(
- private val merchants: JsonField>,
- private val additionalProperties: MutableMap,
- ) {
+ /**
+ * The type of Auth Rule. Effectively determines the event stream during which it will
+ * be evaluated.
+ * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream.
+ * - `VELOCITY_LIMIT`: AUTHORIZATION event stream.
+ * - `MERCHANT_LOCK`: AUTHORIZATION event stream.
+ * - `CONDITIONAL_3DS_ACTION`: THREE_DS_AUTHENTICATION event stream.
+ */
+ class AuthRuleType
+ @JsonCreator
+ private constructor(private val value: JsonField) : Enum {
- @JsonCreator
- private constructor(
- @JsonProperty("merchants")
- @ExcludeMissing
- merchants: JsonField> = JsonMissing.of()
- ) : this(merchants, mutableMapOf())
+ /**
+ * 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
- /**
- * A list of merchant locks defining specific merchants or groups of merchants
- * (based on descriptors or IDs) that the lock applies to.
- *
- * @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 merchants(): List = merchants.getRequired("merchants")
+ companion object {
- /**
- * Returns the raw JSON value of [merchants].
- *
- * Unlike [merchants], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("merchants")
- @ExcludeMissing
- fun _merchants(): JsonField> = merchants
+ @JvmField val CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK")
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
+ @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT")
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of
- * [MerchantLockParameters].
- *
- * The following fields are required:
- * ```java
- * .merchants()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
+ @JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK")
- /** A builder for [MerchantLockParameters]. */
- class Builder internal constructor() {
+ @JvmField val CONDITIONAL_3DS_ACTION = of("CONDITIONAL_3DS_ACTION")
- private var merchants: JsonField>? = null
- private var additionalProperties: MutableMap =
- mutableMapOf()
+ @JvmStatic fun of(value: String) = AuthRuleType(JsonField.of(value))
+ }
- @JvmSynthetic
- internal fun from(merchantLockParameters: MerchantLockParameters) = apply {
- merchants = merchantLockParameters.merchants.map { it.toMutableList() }
- additionalProperties =
- merchantLockParameters.additionalProperties.toMutableMap()
- }
+ /** An enum containing [AuthRuleType]'s known values. */
+ enum class Known {
+ CONDITIONAL_BLOCK,
+ VELOCITY_LIMIT,
+ MERCHANT_LOCK,
+ CONDITIONAL_3DS_ACTION,
+ }
- /**
- * A list of merchant locks defining specific merchants or groups of
- * merchants (based on descriptors or IDs) that the lock applies to.
- */
- fun merchants(merchants: List) =
- merchants(JsonField.of(merchants))
-
- /**
- * Sets [Builder.merchants] to an arbitrary JSON value.
- *
- * You should usually call [Builder.merchants] with a well-typed
- * `List` value instead. This method is primarily for setting the
- * field to an undocumented or not yet supported value.
- */
- fun merchants(merchants: JsonField>) = apply {
- this.merchants = merchants.map { it.toMutableList() }
- }
+ /**
+ * An enum containing [AuthRuleType]'s known values, as well as an [_UNKNOWN]
+ * member.
+ *
+ * An instance of [AuthRuleType] 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 {
+ CONDITIONAL_BLOCK,
+ VELOCITY_LIMIT,
+ MERCHANT_LOCK,
+ CONDITIONAL_3DS_ACTION,
+ /**
+ * An enum member indicating that [AuthRuleType] was instantiated with an
+ * unknown value.
+ */
+ _UNKNOWN,
+ }
- /**
- * Adds a single [Merchant] to [merchants].
- *
- * @throws IllegalStateException if the field was previously set to a
- * non-list.
- */
- fun addMerchant(merchant: Merchant) = apply {
- merchants =
- (merchants ?: JsonField.of(mutableListOf())).also {
- checkKnown("merchants", it).add(merchant)
- }
- }
+ /**
+ * 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) {
+ CONDITIONAL_BLOCK -> Value.CONDITIONAL_BLOCK
+ VELOCITY_LIMIT -> Value.VELOCITY_LIMIT
+ MERCHANT_LOCK -> Value.MERCHANT_LOCK
+ CONDITIONAL_3DS_ACTION -> Value.CONDITIONAL_3DS_ACTION
+ else -> Value._UNKNOWN
+ }
- fun additionalProperties(additionalProperties: Map) =
- apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
+ /**
+ * 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 LithicInvalidDataException if this class instance's value is a not a
+ * known member.
+ */
+ fun known(): Known =
+ when (this) {
+ CONDITIONAL_BLOCK -> Known.CONDITIONAL_BLOCK
+ VELOCITY_LIMIT -> Known.VELOCITY_LIMIT
+ MERCHANT_LOCK -> Known.MERCHANT_LOCK
+ CONDITIONAL_3DS_ACTION -> Known.CONDITIONAL_3DS_ACTION
+ else -> throw LithicInvalidDataException("Unknown AuthRuleType: $value")
+ }
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, 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 LithicInvalidDataException if this class instance's value does not have
+ * the expected primitive type.
+ */
+ fun asString(): String =
+ _value().asString().orElseThrow {
+ LithicInvalidDataException("Value is not a String")
+ }
- fun putAllAdditionalProperties(
- additionalProperties: Map
- ) = apply { this.additionalProperties.putAll(additionalProperties) }
+ private var validated: Boolean = false
- fun removeAdditionalProperty(key: String) = apply {
- additionalProperties.remove(key)
- }
+ fun validate(): AuthRuleType = apply {
+ if (validated) {
+ return@apply
+ }
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
+ known()
+ validated = true
+ }
- /**
- * Returns an immutable instance of [MerchantLockParameters].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .merchants()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): MerchantLockParameters =
- MerchantLockParameters(
- checkRequired("merchants", merchants).map { it.toImmutable() },
- additionalProperties.toMutableMap(),
- )
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: LithicInvalidDataException) {
+ false
}
- private var validated: Boolean = false
-
- fun validate(): MerchantLockParameters = apply {
- if (validated) {
- return@apply
- }
+ /**
+ * 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
- merchants().forEach { it.validate() }
- validated = true
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
}
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: LithicInvalidDataException) {
- false
- }
+ return /* spotless:off */ other is AuthRuleType && value == other.value /* spotless:on */
+ }
- /**
- * 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 =
- (merchants.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
+ override fun hashCode() = value.hashCode()
- /**
- * Represents a specific merchant lock based on their ID or descriptor. Each
- * merchant object allows transaction rules to work at a granular level and
- * requires at least one of merchant_id or descriptor.
- */
- class Merchant
- private constructor(
- private val comment: JsonField,
- private val descriptor: JsonField,
- private val merchantId: JsonField,
- private val additionalProperties: MutableMap,
- ) {
+ override fun toString() = value.toString()
+ }
- @JsonCreator
- private constructor(
- @JsonProperty("comment")
- @ExcludeMissing
- comment: JsonField = JsonMissing.of(),
- @JsonProperty("descriptor")
- @ExcludeMissing
- descriptor: JsonField = JsonMissing.of(),
- @JsonProperty("merchant_id")
- @ExcludeMissing
- merchantId: JsonField = JsonMissing.of(),
- ) : this(comment, descriptor, merchantId, mutableMapOf())
-
- /**
- * A comment or explanation about the merchant, used internally for rule
- * management purposes.
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun comment(): Optional = comment.getOptional("comment")
-
- /**
- * Short description of the merchant, often used to provide more
- * human-readable context about the transaction merchant. This is typically
- * the name or label shown on transaction summaries.
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun descriptor(): Optional = descriptor.getOptional("descriptor")
-
- /**
- * Unique alphanumeric identifier for the payment card acceptor (merchant).
- * This attribute specifies the merchant entity that will be locked or
- * referenced for authorization rules.
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun merchantId(): Optional = merchantId.getOptional("merchant_id")
-
- /**
- * Returns the raw JSON value of [comment].
- *
- * Unlike [comment], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("comment")
- @ExcludeMissing
- fun _comment(): JsonField = comment
-
- /**
- * 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 [merchantId].
- *
- * Unlike [merchantId], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("merchant_id")
- @ExcludeMissing
- fun _merchantId(): JsonField = merchantId
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
+ return /* spotless:off */ other is CreateAuthRuleRequestAccountTokens && accountTokens == other.accountTokens && name == other.name && parameters == other.parameters && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */
+ }
- fun toBuilder() = Builder().from(this)
+ /* spotless:off */
+ private val hashCode: Int by lazy { Objects.hash(accountTokens, name, parameters, type, additionalProperties) }
+ /* spotless:on */
- companion object {
+ override fun hashCode(): Int = hashCode
- /**
- * Returns a mutable builder for constructing an instance of [Merchant].
- */
- @JvmStatic fun builder() = Builder()
- }
+ override fun toString() =
+ "CreateAuthRuleRequestAccountTokens{accountTokens=$accountTokens, name=$name, parameters=$parameters, type=$type, additionalProperties=$additionalProperties}"
+ }
- /** A builder for [Merchant]. */
- class Builder internal constructor() {
-
- private var comment: JsonField = JsonMissing.of()
- private var descriptor: JsonField = JsonMissing.of()
- private var merchantId: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap =
- mutableMapOf()
-
- @JvmSynthetic
- internal fun from(merchant: Merchant) = apply {
- comment = merchant.comment
- descriptor = merchant.descriptor
- merchantId = merchant.merchantId
- additionalProperties = merchant.additionalProperties.toMutableMap()
- }
+ class CreateAuthRuleRequestCardTokens
+ private constructor(
+ private val cardTokens: JsonField>,
+ private val name: JsonField,
+ private val parameters: JsonField,
+ private val type: JsonField,
+ private val additionalProperties: MutableMap,
+ ) {
- /**
- * A comment or explanation about the merchant, used internally for rule
- * management purposes.
- */
- fun comment(comment: String) = comment(JsonField.of(comment))
-
- /**
- * Sets [Builder.comment] to an arbitrary JSON value.
- *
- * You should usually call [Builder.comment] with a well-typed [String]
- * value instead. This method is primarily for setting the field to an
- * undocumented or not yet supported value.
- */
- fun comment(comment: JsonField) = apply {
- this.comment = comment
- }
+ @JsonCreator
+ private constructor(
+ @JsonProperty("card_tokens")
+ @ExcludeMissing
+ cardTokens: JsonField> = JsonMissing.of(),
+ @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
+ @JsonProperty("parameters")
+ @ExcludeMissing
+ parameters: JsonField = JsonMissing.of(),
+ @JsonProperty("type")
+ @ExcludeMissing
+ type: JsonField = JsonMissing.of(),
+ ) : this(cardTokens, name, parameters, type, mutableMapOf())
- /**
- * Short description of the merchant, often used to provide more
- * human-readable context about the transaction merchant. This is
- * typically the name or label shown on transaction summaries.
- */
- 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
- }
+ /**
+ * Card tokens to which the Auth Rule applies.
+ *
+ * @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 cardTokens(): List = cardTokens.getRequired("card_tokens")
- /**
- * Unique alphanumeric identifier for the payment card acceptor
- * (merchant). This attribute specifies the merchant entity that will be
- * locked or referenced for authorization rules.
- */
- fun merchantId(merchantId: String) =
- merchantId(JsonField.of(merchantId))
-
- /**
- * Sets [Builder.merchantId] to an arbitrary JSON value.
- *
- * You should usually call [Builder.merchantId] with a well-typed
- * [String] value instead. This method is primarily for setting the
- * field to an undocumented or not yet supported value.
- */
- fun merchantId(merchantId: JsonField) = apply {
- this.merchantId = merchantId
- }
+ /**
+ * Auth Rule Name
+ *
+ * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun name(): Optional = name.getOptional("name")
- fun additionalProperties(additionalProperties: Map) =
- apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
+ /**
+ * Parameters for the Auth Rule
+ *
+ * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun parameters(): Optional = parameters.getOptional("parameters")
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
+ /**
+ * The type of Auth Rule. Effectively determines the event stream during which it will
+ * be evaluated.
+ * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream.
+ * - `VELOCITY_LIMIT`: AUTHORIZATION event stream.
+ * - `MERCHANT_LOCK`: AUTHORIZATION event stream.
+ * - `CONDITIONAL_3DS_ACTION`: THREE_DS_AUTHENTICATION event stream.
+ *
+ * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun type(): Optional = type.getOptional("type")
- fun putAllAdditionalProperties(
- additionalProperties: Map
- ) = apply { this.additionalProperties.putAll(additionalProperties) }
+ /**
+ * Returns the raw JSON value of [cardTokens].
+ *
+ * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("card_tokens")
+ @ExcludeMissing
+ fun _cardTokens(): JsonField> = cardTokens
- fun removeAdditionalProperty(key: String) = apply {
- additionalProperties.remove(key)
- }
+ /**
+ * Returns the raw JSON value of [name].
+ *
+ * Unlike [name], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
+ /**
+ * Returns the raw JSON value of [parameters].
+ *
+ * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected
+ * type.
+ */
+ @JsonProperty("parameters")
+ @ExcludeMissing
+ fun _parameters(): JsonField = parameters
- /**
- * Returns an immutable instance of [Merchant].
- *
- * Further updates to this [Builder] will not mutate the returned
- * instance.
- */
- fun build(): Merchant =
- Merchant(
- comment,
- descriptor,
- merchantId,
- additionalProperties.toMutableMap(),
- )
- }
+ /**
+ * Returns the raw JSON value of [type].
+ *
+ * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ */
+ @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
- private var validated: Boolean = false
+ @JsonAnySetter
+ private fun putAdditionalProperty(key: String, value: JsonValue) {
+ additionalProperties.put(key, value)
+ }
- fun validate(): Merchant = apply {
- if (validated) {
- return@apply
- }
+ @JsonAnyGetter
+ @ExcludeMissing
+ fun _additionalProperties(): Map =
+ Collections.unmodifiableMap(additionalProperties)
- comment()
- descriptor()
- merchantId()
- validated = true
- }
+ fun toBuilder() = Builder().from(this)
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: LithicInvalidDataException) {
- false
- }
+ companion object {
- /**
- * 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 (comment.asKnown().isPresent) 1 else 0) +
- (if (descriptor.asKnown().isPresent) 1 else 0) +
- (if (merchantId.asKnown().isPresent) 1 else 0)
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
+ /**
+ * Returns a mutable builder for constructing an instance of
+ * [CreateAuthRuleRequestCardTokens].
+ *
+ * The following fields are required:
+ * ```java
+ * .cardTokens()
+ * ```
+ */
+ @JvmStatic fun builder() = Builder()
+ }
- return /* spotless:off */ other is Merchant && comment == other.comment && descriptor == other.descriptor && merchantId == other.merchantId && additionalProperties == other.additionalProperties /* spotless:on */
- }
+ /** A builder for [CreateAuthRuleRequestCardTokens]. */
+ class Builder internal constructor() {
+
+ private var cardTokens: JsonField>? = null
+ private var name: JsonField = JsonMissing.of()
+ private var parameters: JsonField = JsonMissing.of()
+ private var type: JsonField = JsonMissing.of()
+ private var additionalProperties: MutableMap = mutableMapOf()
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(comment, descriptor, merchantId, additionalProperties) }
- /* spotless:on */
+ @JvmSynthetic
+ internal fun from(
+ createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens
+ ) = apply {
+ cardTokens =
+ createAuthRuleRequestCardTokens.cardTokens.map { it.toMutableList() }
+ name = createAuthRuleRequestCardTokens.name
+ parameters = createAuthRuleRequestCardTokens.parameters
+ type = createAuthRuleRequestCardTokens.type
+ additionalProperties =
+ createAuthRuleRequestCardTokens.additionalProperties.toMutableMap()
+ }
- override fun hashCode(): Int = hashCode
+ /** Card tokens to which the Auth Rule applies. */
+ fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens))
- override fun toString() =
- "Merchant{comment=$comment, descriptor=$descriptor, merchantId=$merchantId, additionalProperties=$additionalProperties}"
- }
+ /**
+ * Sets [Builder.cardTokens] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.cardTokens] with a well-typed `List`
+ * value instead. This method is primarily for setting the field to an undocumented
+ * or not yet supported value.
+ */
+ fun cardTokens(cardTokens: JsonField>) = apply {
+ this.cardTokens = cardTokens.map { it.toMutableList() }
+ }
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
+ /**
+ * Adds a single [String] to [cardTokens].
+ *
+ * @throws IllegalStateException if the field was previously set to a non-list.
+ */
+ fun addCardToken(cardToken: String) = apply {
+ cardTokens =
+ (cardTokens ?: JsonField.of(mutableListOf())).also {
+ checkKnown("cardTokens", it).add(cardToken)
}
+ }
- return /* spotless:off */ other is MerchantLockParameters && merchants == other.merchants && additionalProperties == other.additionalProperties /* spotless:on */
- }
+ /** Auth Rule Name */
+ fun name(name: String?) = name(JsonField.ofNullable(name))
+
+ /** Alias for calling [Builder.name] with `name.orElse(null)`. */
+ fun name(name: Optional) = name(name.getOrNull())
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(merchants, additionalProperties) }
- /* spotless:on */
+ /**
+ * Sets [Builder.name] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.name] with a well-typed [String] value instead.
+ * This method is primarily for setting the field to an undocumented or not yet
+ * supported value.
+ */
+ fun name(name: JsonField) = apply { this.name = name }
- override fun hashCode(): Int = hashCode
+ /** Parameters for the Auth Rule */
+ fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters))
- override fun toString() =
- "MerchantLockParameters{merchants=$merchants, additionalProperties=$additionalProperties}"
+ /**
+ * Sets [Builder.parameters] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.parameters] with a well-typed [Parameters] value
+ * instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun parameters(parameters: JsonField) = apply {
+ this.parameters = parameters
}
- class Conditional3dsActionParameters
- private constructor(
- private val action: JsonField,
- private val conditions: JsonField>,
- private val additionalProperties: MutableMap,
- ) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("action")
- @ExcludeMissing
- action: JsonField = JsonMissing.of(),
- @JsonProperty("conditions")
- @ExcludeMissing
- conditions: JsonField> = JsonMissing.of(),
- ) : this(action, conditions, mutableMapOf())
+ /**
+ * Alias for calling [parameters] with
+ * `Parameters.ofConditionalBlock(conditionalBlock)`.
+ */
+ fun parameters(conditionalBlock: ConditionalBlockParameters) =
+ parameters(Parameters.ofConditionalBlock(conditionalBlock))
- /**
- * The action to take if the conditions are met.
- *
- * @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 action(): Action = action.getRequired("action")
+ /**
+ * Alias for calling [parameters] with
+ * `Parameters.ofVelocityLimitParams(velocityLimitParams)`.
+ */
+ fun parameters(velocityLimitParams: VelocityLimitParams) =
+ parameters(Parameters.ofVelocityLimitParams(velocityLimitParams))
- /**
- * @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 conditions(): List = conditions.getRequired("conditions")
+ /**
+ * Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`.
+ */
+ fun parameters(merchantLock: MerchantLockParameters) =
+ parameters(Parameters.ofMerchantLock(merchantLock))
- /**
- * Returns the raw JSON value of [action].
- *
- * Unlike [action], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("action")
- @ExcludeMissing
- fun _action(): JsonField = action
+ /**
+ * Alias for calling [parameters] with
+ * `Parameters.ofConditional3dsAction(conditional3dsAction)`.
+ */
+ fun parameters(conditional3dsAction: Conditional3dsActionParameters) =
+ parameters(Parameters.ofConditional3dsAction(conditional3dsAction))
- /**
- * Returns the raw JSON value of [conditions].
- *
- * Unlike [conditions], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("conditions")
- @ExcludeMissing
- fun _conditions(): JsonField> = conditions
+ /**
+ * The type of Auth Rule. Effectively determines the event stream during which it
+ * will be evaluated.
+ * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream.
+ * - `VELOCITY_LIMIT`: AUTHORIZATION event stream.
+ * - `MERCHANT_LOCK`: AUTHORIZATION event stream.
+ * - `CONDITIONAL_3DS_ACTION`: THREE_DS_AUTHENTICATION event stream.
+ */
+ fun type(type: AuthRuleType) = type(JsonField.of(type))
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
+ /**
+ * Sets [Builder.type] to an arbitrary JSON value.
+ *
+ * You should usually call [Builder.type] with a well-typed [AuthRuleType] value
+ * instead. This method is primarily for setting the field to an undocumented or not
+ * yet supported value.
+ */
+ fun type(type: JsonField) = apply { this.type = type }
- @JsonAnyGetter
- @ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of
- * [Conditional3dsActionParameters].
- *
- * The following fields are required:
- * ```java
- * .action()
- * .conditions()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
+ fun additionalProperties(additionalProperties: Map) = apply {
+ this.additionalProperties.clear()
+ putAllAdditionalProperties(additionalProperties)
+ }
- /** A builder for [Conditional3dsActionParameters]. */
- class Builder internal constructor() {
-
- private var action: JsonField? = null
- private var conditions: JsonField>? = null
- private var additionalProperties: MutableMap =
- mutableMapOf()
-
- @JvmSynthetic
- internal fun from(
- conditional3dsActionParameters: Conditional3dsActionParameters
- ) = apply {
- action = conditional3dsActionParameters.action
- conditions =
- conditional3dsActionParameters.conditions.map { it.toMutableList() }
- additionalProperties =
- conditional3dsActionParameters.additionalProperties.toMutableMap()
- }
+ fun putAdditionalProperty(key: String, value: JsonValue) = apply {
+ additionalProperties.put(key, value)
+ }
- /** The action to take if the conditions are met. */
- fun action(action: Action) = action(JsonField.of(action))
-
- /**
- * Sets [Builder.action] to an arbitrary JSON value.
- *
- * You should usually call [Builder.action] with a well-typed [Action] value
- * instead. This method is primarily for setting the field to an
- * undocumented or not yet supported value.
- */
- fun action(action: JsonField) = apply { this.action = action }
-
- fun conditions(conditions: List) =
- conditions(JsonField.of(conditions))
-
- /**
- * Sets [Builder.conditions] to an arbitrary JSON value.
- *
- * You should usually call [Builder.conditions] with a well-typed
- * `List` value instead. This method is primarily for setting the
- * field to an undocumented or not yet supported value.
- */
- fun conditions(conditions: JsonField>) = apply {
- this.conditions = conditions.map { it.toMutableList() }
- }
+ fun putAllAdditionalProperties(additionalProperties: Map) =
+ apply {
+ this.additionalProperties.putAll(additionalProperties)
+ }
- /**
- * Adds a single [Condition] to [conditions].
- *
- * @throws IllegalStateException if the field was previously set to a
- * non-list.
- */
- fun addCondition(condition: Condition) = apply {
- conditions =
- (conditions ?: JsonField.of(mutableListOf())).also {
- checkKnown("conditions", it).add(condition)
- }
- }
+ fun removeAdditionalProperty(key: String) = apply {
+ additionalProperties.remove(key)
+ }
- fun additionalProperties(additionalProperties: Map) =
- apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
+ fun removeAllAdditionalProperties(keys: Set) = apply {
+ keys.forEach(::removeAdditionalProperty)
+ }
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
- }
+ /**
+ * Returns an immutable instance of [CreateAuthRuleRequestCardTokens].
+ *
+ * Further updates to this [Builder] will not mutate the returned instance.
+ *
+ * The following fields are required:
+ * ```java
+ * .cardTokens()
+ * ```
+ *
+ * @throws IllegalStateException if any required field is unset.
+ */
+ fun build(): CreateAuthRuleRequestCardTokens =
+ CreateAuthRuleRequestCardTokens(
+ checkRequired("cardTokens", cardTokens).map { it.toImmutable() },
+ name,
+ parameters,
+ type,
+ additionalProperties.toMutableMap(),
+ )
+ }
- fun putAllAdditionalProperties(
- additionalProperties: Map
- ) = apply { this.additionalProperties.putAll(additionalProperties) }
+ private var validated: Boolean = false
- fun removeAdditionalProperty(key: String) = apply {
- additionalProperties.remove(key)
- }
+ fun validate(): CreateAuthRuleRequestCardTokens = apply {
+ if (validated) {
+ return@apply
+ }
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
- }
+ cardTokens()
+ name()
+ parameters().ifPresent { it.validate() }
+ type().ifPresent { it.validate() }
+ validated = true
+ }
- /**
- * Returns an immutable instance of [Conditional3dsActionParameters].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .action()
- * .conditions()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): Conditional3dsActionParameters =
- Conditional3dsActionParameters(
- checkRequired("action", action),
- checkRequired("conditions", conditions).map { it.toImmutable() },
- additionalProperties.toMutableMap(),
- )
- }
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: LithicInvalidDataException) {
+ false
+ }
- private var validated: Boolean = 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 =
+ (cardTokens.asKnown().getOrNull()?.size ?: 0) +
+ (if (name.asKnown().isPresent) 1 else 0) +
+ (parameters.asKnown().getOrNull()?.validity() ?: 0) +
+ (type.asKnown().getOrNull()?.validity() ?: 0)
- fun validate(): Conditional3dsActionParameters = apply {
- if (validated) {
- return@apply
- }
+ /** Parameters for the Auth Rule */
+ @JsonDeserialize(using = Parameters.Deserializer::class)
+ @JsonSerialize(using = Parameters.Serializer::class)
+ class Parameters
+ private constructor(
+ private val conditionalBlock: ConditionalBlockParameters? = null,
+ private val velocityLimitParams: VelocityLimitParams? = null,
+ private val merchantLock: MerchantLockParameters? = null,
+ private val conditional3dsAction: Conditional3dsActionParameters? = null,
+ private val _json: JsonValue? = null,
+ ) {
- action().validate()
- conditions().forEach { it.validate() }
- validated = true
- }
+ fun conditionalBlock(): Optional =
+ Optional.ofNullable(conditionalBlock)
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: LithicInvalidDataException) {
- false
- }
+ fun velocityLimitParams(): Optional =
+ Optional.ofNullable(velocityLimitParams)
- /**
- * 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 =
- (action.asKnown().getOrNull()?.validity() ?: 0) +
- (conditions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
-
- /** The action to take if the conditions are met. */
- class Action
- @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 {
-
- @JvmField val DECLINE = of("DECLINE")
-
- @JvmField val CHALLENGE = of("CHALLENGE")
-
- @JvmStatic fun of(value: String) = Action(JsonField.of(value))
- }
+ fun merchantLock(): Optional =
+ Optional.ofNullable(merchantLock)
- /** An enum containing [Action]'s known values. */
- enum class Known {
- DECLINE,
- CHALLENGE,
- }
+ fun conditional3dsAction(): Optional =
+ Optional.ofNullable(conditional3dsAction)
- /**
- * An enum containing [Action]'s known values, as well as an [_UNKNOWN]
- * member.
- *
- * An instance of [Action] 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 {
- DECLINE,
- CHALLENGE,
- /**
- * An enum member indicating that [Action] 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) {
- DECLINE -> Value.DECLINE
- CHALLENGE -> Value.CHALLENGE
- 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 LithicInvalidDataException if this class instance's value is a
- * not a known member.
- */
- fun known(): Known =
- when (this) {
- DECLINE -> Known.DECLINE
- CHALLENGE -> Known.CHALLENGE
- else -> throw LithicInvalidDataException("Unknown Action: $value")
- }
+ fun isConditionalBlock(): Boolean = conditionalBlock != null
- /**
- * 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 LithicInvalidDataException if this class instance's value does
- * not have the expected primitive type.
- */
- fun asString(): String =
- _value().asString().orElseThrow {
- LithicInvalidDataException("Value is not a String")
- }
+ fun isVelocityLimitParams(): Boolean = velocityLimitParams != null
- private var validated: Boolean = false
+ fun isMerchantLock(): Boolean = merchantLock != null
- fun validate(): Action = apply {
- if (validated) {
- return@apply
- }
+ fun isConditional3dsAction(): Boolean = conditional3dsAction != null
- known()
- validated = true
- }
+ fun asConditionalBlock(): ConditionalBlockParameters =
+ conditionalBlock.getOrThrow("conditionalBlock")
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: LithicInvalidDataException) {
- false
- }
+ fun asVelocityLimitParams(): VelocityLimitParams =
+ velocityLimitParams.getOrThrow("velocityLimitParams")
- /**
- * 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
- }
+ fun asMerchantLock(): MerchantLockParameters =
+ merchantLock.getOrThrow("merchantLock")
- return /* spotless:off */ other is Action && value == other.value /* spotless:on */
- }
+ fun asConditional3dsAction(): Conditional3dsActionParameters =
+ conditional3dsAction.getOrThrow("conditional3dsAction")
- override fun hashCode() = value.hashCode()
+ fun _json(): Optional = Optional.ofNullable(_json)
- override fun toString() = value.toString()
+ fun accept(visitor: Visitor): T =
+ when {
+ conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock)
+ velocityLimitParams != null ->
+ visitor.visitVelocityLimitParams(velocityLimitParams)
+ merchantLock != null -> visitor.visitMerchantLock(merchantLock)
+ conditional3dsAction != null ->
+ visitor.visitConditional3dsAction(conditional3dsAction)
+ else -> visitor.unknown(_json)
}
- class Condition
- private constructor(
- private val attribute: JsonField,
- private val operation: JsonField,
- private val value: JsonField,
- private val additionalProperties: MutableMap,
- ) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("attribute")
- @ExcludeMissing
- attribute: JsonField = JsonMissing.of(),
- @JsonProperty("operation")
- @ExcludeMissing
- operation: JsonField = JsonMissing.of(),
- @JsonProperty("value")
- @ExcludeMissing
- value: JsonField = JsonMissing.of(),
- ) : this(attribute, operation, value, mutableMapOf())
-
- /**
- * The attribute to target.
- *
- * The following attributes may be targeted:
- * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to
- * classify a business by the types of goods or services it provides.
- * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1)
- * all ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT
- * for Netherlands Antilles.
- * - `CURRENCY`: 3-character alphabetic ISO 4217 code for the merchant
- * currency of the transaction.
- * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card
- * acceptor (merchant).
- * - `DESCRIPTOR`: Short description of card acceptor.
- * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the
- * acquirer fee field in the settlement/cardholder billing currency. This
- * is the amount the issuer should authorize against unless the issuer is
- * paying the acquirer fee on behalf of the cardholder.
- * - `RISK_SCORE`: Network-provided score assessing risk level associated
- * with a given authentication. Scores are on a range of 0-999, with 0
- * representing the lowest risk and 999 representing the highest risk. For
- * Visa transactions, where the raw score has a range of 0-99, Lithic will
- * normalize the score by multiplying the raw score by 10x.
- * - `MESSAGE_CATEGORY`: The category of the authentication being processed.
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun attribute(): Optional = attribute.getOptional("attribute")
-
- /**
- * The operation to apply to the attribute
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun operation(): Optional = operation.getOptional("operation")
-
- /**
- * A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH`
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun value(): Optional = value.getOptional("value")
-
- /**
- * Returns the raw JSON value of [attribute].
- *
- * Unlike [attribute], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("attribute")
- @ExcludeMissing
- fun _attribute(): JsonField = attribute
-
- /**
- * Returns the raw JSON value of [operation].
- *
- * Unlike [operation], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("operation")
- @ExcludeMissing
- fun _operation(): JsonField = operation
-
- /**
- * Returns the raw JSON value of [value].
- *
- * Unlike [value], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("value")
- @ExcludeMissing
- fun _value(): JsonField = value
-
- @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
- * [Condition].
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [Condition]. */
- class Builder internal constructor() {
-
- private var attribute: JsonField = JsonMissing.of()
- private var operation: JsonField = JsonMissing.of()
- private var value: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap =
- mutableMapOf()
-
- @JvmSynthetic
- internal fun from(condition: Condition) = apply {
- attribute = condition.attribute
- operation = condition.operation
- value = condition.value
- additionalProperties = condition.additionalProperties.toMutableMap()
- }
+ private var validated: Boolean = false
- /**
- * The attribute to target.
- *
- * The following attributes may be targeted:
- * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to
- * classify a business by the types of goods or services it provides.
- * - `COUNTRY`: Country of entity of card acceptor. Possible values are:
- * (1) all ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and
- * (3) ANT for Netherlands Antilles.
- * - `CURRENCY`: 3-character alphabetic ISO 4217 code for the merchant
- * currency of the transaction.
- * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card
- * acceptor (merchant).
- * - `DESCRIPTOR`: Short description of card acceptor.
- * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus
- * the acquirer fee field in the settlement/cardholder billing
- * currency. This is the amount the issuer should authorize against
- * unless the issuer is paying the acquirer fee on behalf of the
- * cardholder.
- * - `RISK_SCORE`: Network-provided score assessing risk level
- * associated with a given authentication. Scores are on a range of
- * 0-999, with 0 representing the lowest risk and 999 representing the
- * highest risk. For Visa transactions, where the raw score has a
- * range of 0-99, Lithic will normalize the score by multiplying the
- * raw score by 10x.
- * - `MESSAGE_CATEGORY`: The category of the authentication being
- * processed.
- */
- fun attribute(attribute: Attribute) = attribute(JsonField.of(attribute))
-
- /**
- * Sets [Builder.attribute] to an arbitrary JSON value.
- *
- * You should usually call [Builder.attribute] with a well-typed
- * [Attribute] value instead. This method is primarily for setting the
- * field to an undocumented or not yet supported value.
- */
- fun attribute(attribute: JsonField) = apply {
- this.attribute = attribute
- }
+ fun validate(): Parameters = apply {
+ if (validated) {
+ return@apply
+ }
- /** The operation to apply to the attribute */
- fun operation(operation: Operation) = operation(JsonField.of(operation))
-
- /**
- * Sets [Builder.operation] to an arbitrary JSON value.
- *
- * You should usually call [Builder.operation] with a well-typed
- * [Operation] value instead. This method is primarily for setting the
- * field to an undocumented or not yet supported value.
- */
- fun operation(operation: JsonField) = apply {
- this.operation = operation
+ accept(
+ object : Visitor {
+ override fun visitConditionalBlock(
+ conditionalBlock: ConditionalBlockParameters
+ ) {
+ conditionalBlock.validate()
}
- /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */
- fun value(value: Value) = value(JsonField.of(value))
-
- /**
- * Sets [Builder.value] to an arbitrary JSON value.
- *
- * You should usually call [Builder.value] with a well-typed [Value]
- * value instead. This method is primarily for setting the field to an
- * undocumented or not yet supported value.
- */
- fun value(value: JsonField) = apply { this.value = value }
-
- /** Alias for calling [value] with `Value.ofRegex(regex)`. */
- fun value(regex: String) = value(Value.ofRegex(regex))
-
- /** Alias for calling [value] with `Value.ofNumber(number)`. */
- fun value(number: Long) = value(Value.ofNumber(number))
-
- /**
- * Alias for calling [value] with
- * `Value.ofListOfStrings(listOfStrings)`.
- */
- fun valueOfListOfStrings(listOfStrings: List) =
- value(Value.ofListOfStrings(listOfStrings))
-
- fun additionalProperties(additionalProperties: Map) =
- apply {
- this.additionalProperties.clear()
- putAllAdditionalProperties(additionalProperties)
- }
-
- fun putAdditionalProperty(key: String, value: JsonValue) = apply {
- additionalProperties.put(key, value)
+ override fun visitVelocityLimitParams(
+ velocityLimitParams: VelocityLimitParams
+ ) {
+ velocityLimitParams.validate()
}
- fun putAllAdditionalProperties(
- additionalProperties: Map
- ) = apply { this.additionalProperties.putAll(additionalProperties) }
-
- fun removeAdditionalProperty(key: String) = apply {
- additionalProperties.remove(key)
+ override fun visitMerchantLock(merchantLock: MerchantLockParameters) {
+ merchantLock.validate()
}
- fun removeAllAdditionalProperties(keys: Set) = apply {
- keys.forEach(::removeAdditionalProperty)
+ override fun visitConditional3dsAction(
+ conditional3dsAction: Conditional3dsActionParameters
+ ) {
+ conditional3dsAction.validate()
}
-
- /**
- * Returns an immutable instance of [Condition].
- *
- * Further updates to this [Builder] will not mutate the returned
- * instance.
- */
- fun build(): Condition =
- Condition(
- attribute,
- operation,
- value,
- additionalProperties.toMutableMap(),
- )
}
+ )
+ validated = true
+ }
- private var validated: Boolean = false
+ fun isValid(): Boolean =
+ try {
+ validate()
+ true
+ } catch (e: LithicInvalidDataException) {
+ false
+ }
- fun validate(): Condition = apply {
- if (validated) {
- return@apply
- }
+ /**
+ * 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 =
+ accept(
+ object : Visitor {
+ override fun visitConditionalBlock(
+ conditionalBlock: ConditionalBlockParameters
+ ) = conditionalBlock.validity()
- attribute().ifPresent { it.validate() }
- operation().ifPresent { it.validate() }
- value().ifPresent { it.validate() }
- validated = true
- }
+ override fun visitVelocityLimitParams(
+ velocityLimitParams: VelocityLimitParams
+ ) = velocityLimitParams.validity()
- fun isValid(): Boolean =
- try {
- validate()
- true
- } catch (e: LithicInvalidDataException) {
- false
- }
+ override fun visitMerchantLock(merchantLock: MerchantLockParameters) =
+ merchantLock.validity()
- /**
- * 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 =
- (attribute.asKnown().getOrNull()?.validity() ?: 0) +
- (operation.asKnown().getOrNull()?.validity() ?: 0) +
- (value.asKnown().getOrNull()?.validity() ?: 0)
-
- /**
- * The attribute to target.
- *
- * The following attributes may be targeted:
- * - `MCC`: A four-digit number listed in ISO 18245. An MCC is used to
- * classify a business by the types of goods or services it provides.
- * - `COUNTRY`: Country of entity of card acceptor. Possible values are: (1)
- * all ISO 3166-1 alpha-3 country codes, (2) QZZ for Kosovo, and (3) ANT
- * for Netherlands Antilles.
- * - `CURRENCY`: 3-character alphabetic ISO 4217 code for the merchant
- * currency of the transaction.
- * - `MERCHANT_ID`: Unique alphanumeric identifier for the payment card
- * acceptor (merchant).
- * - `DESCRIPTOR`: Short description of card acceptor.
- * - `TRANSACTION_AMOUNT`: The base transaction amount (in cents) plus the
- * acquirer fee field in the settlement/cardholder billing currency. This
- * is the amount the issuer should authorize against unless the issuer is
- * paying the acquirer fee on behalf of the cardholder.
- * - `RISK_SCORE`: Network-provided score assessing risk level associated
- * with a given authentication. Scores are on a range of 0-999, with 0
- * representing the lowest risk and 999 representing the highest risk. For
- * Visa transactions, where the raw score has a range of 0-99, Lithic will
- * normalize the score by multiplying the raw score by 10x.
- * - `MESSAGE_CATEGORY`: The category of the authentication being processed.
- */
- class Attribute
- @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 {
-
- @JvmField val MCC = of("MCC")
-
- @JvmField val COUNTRY = of("COUNTRY")
-
- @JvmField val CURRENCY = of("CURRENCY")
-
- @JvmField val MERCHANT_ID = of("MERCHANT_ID")
-
- @JvmField val DESCRIPTOR = of("DESCRIPTOR")
-
- @JvmField val TRANSACTION_AMOUNT = of("TRANSACTION_AMOUNT")
-
- @JvmField val RISK_SCORE = of("RISK_SCORE")
-
- @JvmField val MESSAGE_CATEGORY = of("MESSAGE_CATEGORY")
-
- @JvmStatic fun of(value: String) = Attribute(JsonField.of(value))
- }
+ override fun visitConditional3dsAction(
+ conditional3dsAction: Conditional3dsActionParameters
+ ) = conditional3dsAction.validity()
- /** An enum containing [Attribute]'s known values. */
- enum class Known {
- MCC,
- COUNTRY,
- CURRENCY,
- MERCHANT_ID,
- DESCRIPTOR,
- TRANSACTION_AMOUNT,
- RISK_SCORE,
- MESSAGE_CATEGORY,
- }
+ override fun unknown(json: JsonValue?) = 0
+ }
+ )
- /**
- * An enum containing [Attribute]'s known values, as well as an
- * [_UNKNOWN] member.
- *
- * An instance of [Attribute] 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 {
- MCC,
- COUNTRY,
- CURRENCY,
- MERCHANT_ID,
- DESCRIPTOR,
- TRANSACTION_AMOUNT,
- RISK_SCORE,
- MESSAGE_CATEGORY,
- /**
- * An enum member indicating that [Attribute] was instantiated with
- * an unknown value.
- */
- _UNKNOWN,
- }
+ override fun equals(other: Any?): Boolean {
+ if (this === other) {
+ return true
+ }
- /**
- * 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) {
- MCC -> Value.MCC
- COUNTRY -> Value.COUNTRY
- CURRENCY -> Value.CURRENCY
- MERCHANT_ID -> Value.MERCHANT_ID
- DESCRIPTOR -> Value.DESCRIPTOR
- TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT
- RISK_SCORE -> Value.RISK_SCORE
- MESSAGE_CATEGORY -> Value.MESSAGE_CATEGORY
- 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 LithicInvalidDataException if this class instance's value is
- * a not a known member.
- */
- fun known(): Known =
- when (this) {
- MCC -> Known.MCC
- COUNTRY -> Known.COUNTRY
- CURRENCY -> Known.CURRENCY
- MERCHANT_ID -> Known.MERCHANT_ID
- DESCRIPTOR -> Known.DESCRIPTOR
- TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT
- RISK_SCORE -> Known.RISK_SCORE
- MESSAGE_CATEGORY -> Known.MESSAGE_CATEGORY
- else ->
- throw LithicInvalidDataException(
- "Unknown Attribute: $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 LithicInvalidDataException if this class instance's value
- * does not have the expected primitive type.
- */
- fun asString(): String =
- _value().asString().orElseThrow {
- LithicInvalidDataException("Value is not a String")
- }
-
- private var validated: Boolean = false
-
- fun validate(): Attribute = apply {
- if (validated) {
- return@apply
- }
-
- known()
- validated = true
- }
+ return /* spotless:off */ other is Parameters && conditionalBlock == other.conditionalBlock && velocityLimitParams == other.velocityLimitParams && merchantLock == other.merchantLock && conditional3dsAction == other.conditional3dsAction /* spotless:on */
+ }
- 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 (value() == Value._UNKNOWN) 0 else 1
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Attribute && value == other.value /* spotless:on */
- }
+ override fun hashCode(): Int = /* spotless:off */ Objects.hash(conditionalBlock, velocityLimitParams, merchantLock, conditional3dsAction) /* spotless:on */
- override fun hashCode() = value.hashCode()
+ override fun toString(): String =
+ when {
+ conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}"
+ velocityLimitParams != null ->
+ "Parameters{velocityLimitParams=$velocityLimitParams}"
+ merchantLock != null -> "Parameters{merchantLock=$merchantLock}"
+ conditional3dsAction != null ->
+ "Parameters{conditional3dsAction=$conditional3dsAction}"
+ _json != null -> "Parameters{_unknown=$_json}"
+ else -> throw IllegalStateException("Invalid Parameters")
+ }
- override fun toString() = value.toString()
- }
+ companion object {
- /** The operation to apply to the attribute */
- class Operation
- @JsonCreator
- private constructor(private val value: JsonField) : Enum {
+ @JvmStatic
+ fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) =
+ Parameters(conditionalBlock = conditionalBlock)
- /**
- * 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
+ @JvmStatic
+ fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) =
+ Parameters(velocityLimitParams = velocityLimitParams)
- companion object {
+ @JvmStatic
+ fun ofMerchantLock(merchantLock: MerchantLockParameters) =
+ Parameters(merchantLock = merchantLock)
- @JvmField val IS_ONE_OF = of("IS_ONE_OF")
+ @JvmStatic
+ fun ofConditional3dsAction(
+ conditional3dsAction: Conditional3dsActionParameters
+ ) = Parameters(conditional3dsAction = conditional3dsAction)
+ }
- @JvmField val IS_NOT_ONE_OF = of("IS_NOT_ONE_OF")
+ /**
+ * An interface that defines how to map each variant of [Parameters] to a value of
+ * type [T].
+ */
+ interface Visitor {
- @JvmField val MATCHES = of("MATCHES")
+ fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T
- @JvmField val DOES_NOT_MATCH = of("DOES_NOT_MATCH")
+ fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T
- @JvmField val IS_GREATER_THAN = of("IS_GREATER_THAN")
+ fun visitMerchantLock(merchantLock: MerchantLockParameters): T
- @JvmField val IS_LESS_THAN = of("IS_LESS_THAN")
+ fun visitConditional3dsAction(
+ conditional3dsAction: Conditional3dsActionParameters
+ ): T
- @JvmStatic fun of(value: String) = Operation(JsonField.of(value))
- }
+ /**
+ * Maps an unknown variant of [Parameters] to a value of type [T].
+ *
+ * An instance of [Parameters] can contain an unknown variant if it was
+ * deserialized from data that doesn't match any known variant. For example, if
+ * the SDK is on an older version than the API, then the API may respond with
+ * new variants that the SDK is unaware of.
+ *
+ * @throws LithicInvalidDataException in the default implementation.
+ */
+ fun unknown(json: JsonValue?): T {
+ throw LithicInvalidDataException("Unknown Parameters: $json")
+ }
+ }
- /** An enum containing [Operation]'s known values. */
- enum class Known {
- IS_ONE_OF,
- IS_NOT_ONE_OF,
- MATCHES,
- DOES_NOT_MATCH,
- IS_GREATER_THAN,
- IS_LESS_THAN,
- }
+ internal class Deserializer : BaseDeserializer(Parameters::class) {
- /**
- * An enum containing [Operation]'s known values, as well as an
- * [_UNKNOWN] member.
- *
- * An instance of [Operation] 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 {
- IS_ONE_OF,
- IS_NOT_ONE_OF,
- MATCHES,
- DOES_NOT_MATCH,
- IS_GREATER_THAN,
- IS_LESS_THAN,
- /**
- * An enum member indicating that [Operation] was instantiated with
- * an unknown value.
- */
- _UNKNOWN,
- }
+ override fun ObjectCodec.deserialize(node: JsonNode): Parameters {
+ val json = JsonValue.fromJsonNode(node)
- /**
- * 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) {
- IS_ONE_OF -> Value.IS_ONE_OF
- IS_NOT_ONE_OF -> Value.IS_NOT_ONE_OF
- MATCHES -> Value.MATCHES
- DOES_NOT_MATCH -> Value.DOES_NOT_MATCH
- IS_GREATER_THAN -> Value.IS_GREATER_THAN
- IS_LESS_THAN -> Value.IS_LESS_THAN
- 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 LithicInvalidDataException if this class instance's value is
- * a not a known member.
- */
- fun known(): Known =
- when (this) {
- IS_ONE_OF -> Known.IS_ONE_OF
- IS_NOT_ONE_OF -> Known.IS_NOT_ONE_OF
- MATCHES -> Known.MATCHES
- DOES_NOT_MATCH -> Known.DOES_NOT_MATCH
- IS_GREATER_THAN -> Known.IS_GREATER_THAN
- IS_LESS_THAN -> Known.IS_LESS_THAN
- else ->
- throw LithicInvalidDataException(
- "Unknown Operation: $value"
+ val bestMatches =
+ sequenceOf(
+ tryDeserialize(
+ node,
+ jacksonTypeRef(),
)
- }
-
- /**
- * 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 LithicInvalidDataException if this class instance's value
- * does not have the expected primitive type.
- */
- fun asString(): String =
- _value().asString().orElseThrow {
- LithicInvalidDataException("Value is not a String")
- }
-
- private var validated: Boolean = false
-
- fun validate(): Operation = apply {
- if (validated) {
- return@apply
- }
-
- known()
- 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 (value() == Value._UNKNOWN) 0 else 1
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Operation && value == other.value /* spotless:on */
- }
+ ?.let { Parameters(conditionalBlock = it, _json = json) },
+ tryDeserialize(node, jacksonTypeRef())
+ ?.let {
+ Parameters(velocityLimitParams = it, _json = json)
+ },
+ tryDeserialize(node, jacksonTypeRef())
+ ?.let { Parameters(merchantLock = it, _json = json) },
+ tryDeserialize(
+ node,
+ jacksonTypeRef(),
+ )
+ ?.let {
+ Parameters(conditional3dsAction = it, _json = json)
+ },
+ )
+ .filterNotNull()
+ .allMaxBy { it.validity() }
+ .toList()
+ return when (bestMatches.size) {
+ // This can happen if what we're deserializing is completely
+ // incompatible with all the possible variants (e.g. deserializing from
+ // boolean).
+ 0 -> Parameters(_json = json)
+ 1 -> bestMatches.single()
+ // If there's more than one match with the highest validity, then use
+ // the first completely valid match, or simply the first match if none
+ // are completely valid.
+ else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first()
+ }
+ }
+ }
- override fun hashCode() = value.hashCode()
+ internal class Serializer : BaseSerializer(Parameters::class) {
- override fun toString() = value.toString()
+ override fun serialize(
+ value: Parameters,
+ generator: JsonGenerator,
+ provider: SerializerProvider,
+ ) {
+ when {
+ value.conditionalBlock != null ->
+ generator.writeObject(value.conditionalBlock)
+ value.velocityLimitParams != null ->
+ generator.writeObject(value.velocityLimitParams)
+ value.merchantLock != null -> generator.writeObject(value.merchantLock)
+ value.conditional3dsAction != null ->
+ generator.writeObject(value.conditional3dsAction)
+ value._json != null -> generator.writeObject(value._json)
+ else -> throw IllegalStateException("Invalid Parameters")
}
+ }
+ }
+ }
- /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */
- @JsonDeserialize(using = Value.Deserializer::class)
- @JsonSerialize(using = Value.Serializer::class)
- class Value
- private constructor(
- private val regex: String? = null,
- private val number: Long? = null,
- private val listOfStrings: List? = null,
- private val _json: JsonValue? = null,
- ) {
+ /**
+ * The type of Auth Rule. Effectively determines the event stream during which it will
+ * be evaluated.
+ * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream.
+ * - `VELOCITY_LIMIT`: AUTHORIZATION event stream.
+ * - `MERCHANT_LOCK`: AUTHORIZATION event stream.
+ * - `CONDITIONAL_3DS_ACTION`: THREE_DS_AUTHENTICATION event stream.
+ */
+ class AuthRuleType
+ @JsonCreator
+ private constructor(private val value: JsonField) : Enum {
- /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */
- fun regex(): Optional = Optional.ofNullable(regex)
+ /**
+ * 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
- /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */
- fun number(): Optional = Optional.ofNullable(number)
+ companion object {
- /**
- * An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF`
- */
- fun listOfStrings(): Optional> =
- Optional.ofNullable(listOfStrings)
+ @JvmField val CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK")
- fun isRegex(): Boolean = regex != null
-
- fun isNumber(): Boolean = number != null
-
- fun isListOfStrings(): Boolean = listOfStrings != null
-
- /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */
- fun asRegex(): String = regex.getOrThrow("regex")
-
- /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */
- fun asNumber(): Long = number.getOrThrow("number")
-
- /**
- * An array of strings, to be used with `IS_ONE_OF` or `IS_NOT_ONE_OF`
- */
- fun asListOfStrings(): List =
- listOfStrings.getOrThrow("listOfStrings")
-
- fun _json(): Optional = Optional.ofNullable(_json)
-
- fun accept(visitor: Visitor): T =
- when {
- regex != null -> visitor.visitRegex(regex)
- number != null -> visitor.visitNumber(number)
- listOfStrings != null ->
- visitor.visitListOfStrings(listOfStrings)
- else -> visitor.unknown(_json)
- }
-
- private var validated: Boolean = false
-
- fun validate(): Value = apply {
- if (validated) {
- return@apply
- }
-
- accept(
- object : Visitor {
- override fun visitRegex(regex: String) {}
-
- override fun visitNumber(number: Long) {}
-
- override fun visitListOfStrings(
- listOfStrings: List
- ) {}
- }
- )
- 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 =
- accept(
- object : Visitor {
- override fun visitRegex(regex: String) = 1
-
- override fun visitNumber(number: Long) = 1
-
- override fun visitListOfStrings(
- listOfStrings: List
- ) = listOfStrings.size
-
- override fun unknown(json: JsonValue?) = 0
- }
- )
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Value && regex == other.regex && number == other.number && listOfStrings == other.listOfStrings /* spotless:on */
- }
-
- override fun hashCode(): Int = /* spotless:off */ Objects.hash(regex, number, listOfStrings) /* spotless:on */
-
- override fun toString(): String =
- when {
- regex != null -> "Value{regex=$regex}"
- number != null -> "Value{number=$number}"
- listOfStrings != null -> "Value{listOfStrings=$listOfStrings}"
- _json != null -> "Value{_unknown=$_json}"
- else -> throw IllegalStateException("Invalid Value")
- }
-
- companion object {
-
- /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */
- @JvmStatic fun ofRegex(regex: String) = Value(regex = regex)
-
- /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */
- @JvmStatic fun ofNumber(number: Long) = Value(number = number)
-
- /**
- * An array of strings, to be used with `IS_ONE_OF` or
- * `IS_NOT_ONE_OF`
- */
- @JvmStatic
- fun ofListOfStrings(listOfStrings: List) =
- Value(listOfStrings = listOfStrings)
- }
-
- /**
- * An interface that defines how to map each variant of [Value] to a
- * value of type [T].
- */
- interface Visitor {
-
- /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */
- fun visitRegex(regex: String): T
-
- /** A number, to be used with `IS_GREATER_THAN` or `IS_LESS_THAN` */
- fun visitNumber(number: Long): T
-
- /**
- * An array of strings, to be used with `IS_ONE_OF` or
- * `IS_NOT_ONE_OF`
- */
- fun visitListOfStrings(listOfStrings: List): T
-
- /**
- * Maps an unknown variant of [Value] to a value of type [T].
- *
- * An instance of [Value] can contain an unknown variant if it was
- * deserialized from data that doesn't match any known variant. For
- * example, if the SDK is on an older version than the API, then the
- * API may respond with new variants that the SDK is unaware of.
- *
- * @throws LithicInvalidDataException in the default implementation.
- */
- fun unknown(json: JsonValue?): T {
- throw LithicInvalidDataException("Unknown Value: $json")
- }
- }
-
- internal class Deserializer : BaseDeserializer(Value::class) {
-
- override fun ObjectCodec.deserialize(node: JsonNode): Value {
- val json = JsonValue.fromJsonNode(node)
-
- val bestMatches =
- sequenceOf(
- tryDeserialize(node, jacksonTypeRef())
- ?.let { Value(regex = it, _json = json) },
- tryDeserialize(node, jacksonTypeRef())?.let {
- Value(number = it, _json = json)
- },
- tryDeserialize(node, jacksonTypeRef>())
- ?.let {
- Value(listOfStrings = it, _json = json)
- },
- )
- .filterNotNull()
- .allMaxBy { it.validity() }
- .toList()
- return when (bestMatches.size) {
- // This can happen if what we're deserializing is completely
- // incompatible with all the possible variants (e.g.
- // deserializing from object).
- 0 -> Value(_json = json)
- 1 -> bestMatches.single()
- // If there's more than one match with the highest validity,
- // then use the first completely valid match, or simply the
- // first match if none are completely valid.
- else ->
- bestMatches.firstOrNull { it.isValid() }
- ?: bestMatches.first()
- }
- }
- }
-
- internal class Serializer : BaseSerializer(Value::class) {
-
- override fun serialize(
- value: Value,
- generator: JsonGenerator,
- provider: SerializerProvider,
- ) {
- when {
- value.regex != null -> generator.writeObject(value.regex)
- value.number != null -> generator.writeObject(value.number)
- value.listOfStrings != null ->
- generator.writeObject(value.listOfStrings)
- value._json != null -> generator.writeObject(value._json)
- else -> throw IllegalStateException("Invalid Value")
- }
- }
- }
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Condition && attribute == other.attribute && operation == other.operation && value == other.value && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(attribute, operation, value, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Condition{attribute=$attribute, operation=$operation, value=$value, additionalProperties=$additionalProperties}"
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Conditional3dsActionParameters && action == other.action && conditions == other.conditions && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(action, conditions, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Conditional3dsActionParameters{action=$action, conditions=$conditions, additionalProperties=$additionalProperties}"
- }
- }
-
- /**
- * The type of Auth Rule. Effectively determines the event stream during which it will
- * be evaluated.
- * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream.
- * - `VELOCITY_LIMIT`: AUTHORIZATION event stream.
- * - `MERCHANT_LOCK`: AUTHORIZATION event stream.
- * - `CONDITIONAL_3DS_ACTION`: THREE_DS_AUTHENTICATION event stream.
- */
- class AuthRuleType
- @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 {
-
- @JvmField val CONDITIONAL_BLOCK = of("CONDITIONAL_BLOCK")
-
- @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT")
+ @JvmField val VELOCITY_LIMIT = of("VELOCITY_LIMIT")
@JvmField val MERCHANT_LOCK = of("MERCHANT_LOCK")
@@ -2938,22 +1979,23 @@ private constructor(
return true
}
- return /* spotless:off */ other is CreateAuthRuleRequestAccountTokens && accountTokens == other.accountTokens && name == other.name && parameters == other.parameters && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */
+ return /* spotless:off */ other is CreateAuthRuleRequestCardTokens && cardTokens == other.cardTokens && name == other.name && parameters == other.parameters && type == other.type && additionalProperties == other.additionalProperties /* spotless:on */
}
/* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(accountTokens, name, parameters, type, additionalProperties) }
+ private val hashCode: Int by lazy { Objects.hash(cardTokens, name, parameters, type, additionalProperties) }
/* spotless:on */
override fun hashCode(): Int = hashCode
override fun toString() =
- "CreateAuthRuleRequestAccountTokens{accountTokens=$accountTokens, name=$name, parameters=$parameters, type=$type, additionalProperties=$additionalProperties}"
+ "CreateAuthRuleRequestCardTokens{cardTokens=$cardTokens, name=$name, parameters=$parameters, type=$type, additionalProperties=$additionalProperties}"
}
- class CreateAuthRuleRequestCardTokens
+ class CreateAuthRuleRequestProgramLevel
private constructor(
- private val cardTokens: JsonField>,
+ private val programLevel: JsonField,
+ private val excludedCardTokens: JsonField>,
private val name: JsonField,
private val parameters: JsonField,
private val type: JsonField,
@@ -2962,9 +2004,12 @@ private constructor(
@JsonCreator
private constructor(
- @JsonProperty("card_tokens")
+ @JsonProperty("program_level")
@ExcludeMissing
- cardTokens: JsonField> = JsonMissing.of(),
+ programLevel: JsonField = JsonMissing.of(),
+ @JsonProperty("excluded_card_tokens")
+ @ExcludeMissing
+ excludedCardTokens: JsonField> = JsonMissing.of(),
@JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(),
@JsonProperty("parameters")
@ExcludeMissing
@@ -2972,16 +2017,25 @@ private constructor(
@JsonProperty("type")
@ExcludeMissing
type: JsonField = JsonMissing.of(),
- ) : this(cardTokens, name, parameters, type, mutableMapOf())
+ ) : this(programLevel, excludedCardTokens, name, parameters, type, mutableMapOf())
/**
- * Card tokens to which the Auth Rule applies.
+ * Whether the Auth Rule applies to all authorizations on the card program.
*
* @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 cardTokens(): List = cardTokens.getRequired("card_tokens")
+ fun programLevel(): Boolean = programLevel.getRequired("program_level")
+
+ /**
+ * Card tokens to which the Auth Rule does not apply.
+ *
+ * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if
+ * the server responded with an unexpected value).
+ */
+ fun excludedCardTokens(): Optional> =
+ excludedCardTokens.getOptional("excluded_card_tokens")
/**
* Auth Rule Name
@@ -3013,4777 +2067,563 @@ private constructor(
fun type(): Optional = type.getOptional("type")
/**
- * Returns the raw JSON value of [cardTokens].
- *
- * Unlike [cardTokens], this method doesn't throw if the JSON field has an unexpected
- * type.
- */
- @JsonProperty("card_tokens")
- @ExcludeMissing
- fun _cardTokens(): JsonField> = cardTokens
-
- /**
- * Returns the raw JSON value of [name].
- *
- * Unlike [name], this method doesn't throw if the JSON field has an unexpected type.
- */
- @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name
-
- /**
- * Returns the raw JSON value of [parameters].
+ * Returns the raw JSON value of [programLevel].
*
- * Unlike [parameters], this method doesn't throw if the JSON field has an unexpected
+ * Unlike [programLevel], this method doesn't throw if the JSON field has an unexpected
* type.
*/
- @JsonProperty("parameters")
+ @JsonProperty("program_level")
@ExcludeMissing
- fun _parameters(): JsonField = parameters
+ fun _programLevel(): JsonField = programLevel
/**
- * Returns the raw JSON value of [type].
+ * Returns the raw JSON value of [excludedCardTokens].
*
- * Unlike [type], this method doesn't throw if the JSON field has an unexpected type.
+ * Unlike [excludedCardTokens], this method doesn't throw if the JSON field has an
+ * unexpected type.
*/
- @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type
-
- @JsonAnySetter
- private fun putAdditionalProperty(key: String, value: JsonValue) {
- additionalProperties.put(key, value)
- }
-
- @JsonAnyGetter
+ @JsonProperty("excluded_card_tokens")
@ExcludeMissing
- fun _additionalProperties(): Map =
- Collections.unmodifiableMap(additionalProperties)
-
- fun toBuilder() = Builder().from(this)
-
- companion object {
-
- /**
- * Returns a mutable builder for constructing an instance of
- * [CreateAuthRuleRequestCardTokens].
- *
- * The following fields are required:
- * ```java
- * .cardTokens()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [CreateAuthRuleRequestCardTokens]. */
- class Builder internal constructor() {
-
- private var cardTokens: JsonField>? = null
- private var name: JsonField = JsonMissing.of()
- private var parameters: JsonField = JsonMissing.of()
- private var type: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap = mutableMapOf()
-
- @JvmSynthetic
- internal fun from(
- createAuthRuleRequestCardTokens: CreateAuthRuleRequestCardTokens
- ) = apply {
- cardTokens =
- createAuthRuleRequestCardTokens.cardTokens.map { it.toMutableList() }
- name = createAuthRuleRequestCardTokens.name
- parameters = createAuthRuleRequestCardTokens.parameters
- type = createAuthRuleRequestCardTokens.type
- additionalProperties =
- createAuthRuleRequestCardTokens.additionalProperties.toMutableMap()
- }
-
- /** Card tokens to which the Auth Rule applies. */
- fun cardTokens(cardTokens: List) = cardTokens(JsonField.of(cardTokens))
-
- /**
- * Sets [Builder.cardTokens] to an arbitrary JSON value.
- *
- * You should usually call [Builder.cardTokens] with a well-typed `List`
- * value instead. This method is primarily for setting the field to an undocumented
- * or not yet supported value.
- */
- fun cardTokens(cardTokens: JsonField>) = apply {
- this.cardTokens = cardTokens.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [String] to [cardTokens].
- *
- * @throws IllegalStateException if the field was previously set to a non-list.
- */
- fun addCardToken(cardToken: String) = apply {
- cardTokens =
- (cardTokens ?: JsonField.of(mutableListOf())).also {
- checkKnown("cardTokens", it).add(cardToken)
- }
- }
-
- /** Auth Rule Name */
- fun name(name: String?) = name(JsonField.ofNullable(name))
-
- /** Alias for calling [Builder.name] with `name.orElse(null)`. */
- fun name(name: Optional) = name(name.getOrNull())
-
- /**
- * Sets [Builder.name] to an arbitrary JSON value.
- *
- * You should usually call [Builder.name] with a well-typed [String] value instead.
- * This method is primarily for setting the field to an undocumented or not yet
- * supported value.
- */
- fun name(name: JsonField) = apply { this.name = name }
-
- /** Parameters for the Auth Rule */
- fun parameters(parameters: Parameters) = parameters(JsonField.of(parameters))
-
- /**
- * Sets [Builder.parameters] to an arbitrary JSON value.
- *
- * You should usually call [Builder.parameters] with a well-typed [Parameters] value
- * instead. This method is primarily for setting the field to an undocumented or not
- * yet supported value.
- */
- fun parameters(parameters: JsonField) = apply {
- this.parameters = parameters
- }
-
- /**
- * Alias for calling [parameters] with
- * `Parameters.ofConditionalBlock(conditionalBlock)`.
- */
- fun parameters(conditionalBlock: ConditionalBlockParameters) =
- parameters(Parameters.ofConditionalBlock(conditionalBlock))
-
- /**
- * Alias for calling [parameters] with
- * `Parameters.ofVelocityLimitParams(velocityLimitParams)`.
- */
- fun parameters(velocityLimitParams: VelocityLimitParams) =
- parameters(Parameters.ofVelocityLimitParams(velocityLimitParams))
-
- /**
- * Alias for calling [parameters] with `Parameters.ofMerchantLock(merchantLock)`.
- */
- fun parameters(merchantLock: Parameters.MerchantLockParameters) =
- parameters(Parameters.ofMerchantLock(merchantLock))
-
- /**
- * Alias for calling [parameters] with
- * `Parameters.ofConditional3dsAction(conditional3dsAction)`.
- */
- fun parameters(conditional3dsAction: Parameters.Conditional3dsActionParameters) =
- parameters(Parameters.ofConditional3dsAction(conditional3dsAction))
-
- /**
- * The type of Auth Rule. Effectively determines the event stream during which it
- * will be evaluated.
- * - `CONDITIONAL_BLOCK`: AUTHORIZATION event stream.
- * - `VELOCITY_LIMIT`: AUTHORIZATION event stream.
- * - `MERCHANT_LOCK`: AUTHORIZATION event stream.
- * - `CONDITIONAL_3DS_ACTION`: THREE_DS_AUTHENTICATION event stream.
- */
- fun type(type: AuthRuleType) = type(JsonField.of(type))
-
- /**
- * Sets [Builder.type] to an arbitrary JSON value.
- *
- * You should usually call [Builder.type] with a well-typed [AuthRuleType] value
- * instead. This method is primarily for setting the field to an undocumented or not
- * yet supported value.
- */
- fun type(type: JsonField) = apply { this.type = type }
-
- 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 [CreateAuthRuleRequestCardTokens].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .cardTokens()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): CreateAuthRuleRequestCardTokens =
- CreateAuthRuleRequestCardTokens(
- checkRequired("cardTokens", cardTokens).map { it.toImmutable() },
- name,
- parameters,
- type,
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): CreateAuthRuleRequestCardTokens = apply {
- if (validated) {
- return@apply
- }
-
- cardTokens()
- name()
- parameters().ifPresent { it.validate() }
- type().ifPresent { it.validate() }
- 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 =
- (cardTokens.asKnown().getOrNull()?.size ?: 0) +
- (if (name.asKnown().isPresent) 1 else 0) +
- (parameters.asKnown().getOrNull()?.validity() ?: 0) +
- (type.asKnown().getOrNull()?.validity() ?: 0)
-
- /** Parameters for the Auth Rule */
- @JsonDeserialize(using = Parameters.Deserializer::class)
- @JsonSerialize(using = Parameters.Serializer::class)
- class Parameters
- private constructor(
- private val conditionalBlock: ConditionalBlockParameters? = null,
- private val velocityLimitParams: VelocityLimitParams? = null,
- private val merchantLock: MerchantLockParameters? = null,
- private val conditional3dsAction: Conditional3dsActionParameters? = null,
- private val _json: JsonValue? = null,
- ) {
-
- fun conditionalBlock(): Optional =
- Optional.ofNullable(conditionalBlock)
-
- fun velocityLimitParams(): Optional =
- Optional.ofNullable(velocityLimitParams)
-
- fun merchantLock(): Optional =
- Optional.ofNullable(merchantLock)
-
- fun conditional3dsAction(): Optional =
- Optional.ofNullable(conditional3dsAction)
-
- fun isConditionalBlock(): Boolean = conditionalBlock != null
-
- fun isVelocityLimitParams(): Boolean = velocityLimitParams != null
-
- fun isMerchantLock(): Boolean = merchantLock != null
-
- fun isConditional3dsAction(): Boolean = conditional3dsAction != null
-
- fun asConditionalBlock(): ConditionalBlockParameters =
- conditionalBlock.getOrThrow("conditionalBlock")
-
- fun asVelocityLimitParams(): VelocityLimitParams =
- velocityLimitParams.getOrThrow("velocityLimitParams")
-
- fun asMerchantLock(): MerchantLockParameters =
- merchantLock.getOrThrow("merchantLock")
-
- fun asConditional3dsAction(): Conditional3dsActionParameters =
- conditional3dsAction.getOrThrow("conditional3dsAction")
-
- fun _json(): Optional = Optional.ofNullable(_json)
-
- fun accept(visitor: Visitor): T =
- when {
- conditionalBlock != null -> visitor.visitConditionalBlock(conditionalBlock)
- velocityLimitParams != null ->
- visitor.visitVelocityLimitParams(velocityLimitParams)
- merchantLock != null -> visitor.visitMerchantLock(merchantLock)
- conditional3dsAction != null ->
- visitor.visitConditional3dsAction(conditional3dsAction)
- else -> visitor.unknown(_json)
- }
-
- private var validated: Boolean = false
-
- fun validate(): Parameters = apply {
- if (validated) {
- return@apply
- }
-
- accept(
- object : Visitor {
- override fun visitConditionalBlock(
- conditionalBlock: ConditionalBlockParameters
- ) {
- conditionalBlock.validate()
- }
-
- override fun visitVelocityLimitParams(
- velocityLimitParams: VelocityLimitParams
- ) {
- velocityLimitParams.validate()
- }
-
- override fun visitMerchantLock(merchantLock: MerchantLockParameters) {
- merchantLock.validate()
- }
-
- override fun visitConditional3dsAction(
- conditional3dsAction: Conditional3dsActionParameters
- ) {
- conditional3dsAction.validate()
- }
- }
- )
- 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 =
- accept(
- object : Visitor {
- override fun visitConditionalBlock(
- conditionalBlock: ConditionalBlockParameters
- ) = conditionalBlock.validity()
-
- override fun visitVelocityLimitParams(
- velocityLimitParams: VelocityLimitParams
- ) = velocityLimitParams.validity()
-
- override fun visitMerchantLock(merchantLock: MerchantLockParameters) =
- merchantLock.validity()
-
- override fun visitConditional3dsAction(
- conditional3dsAction: Conditional3dsActionParameters
- ) = conditional3dsAction.validity()
-
- override fun unknown(json: JsonValue?) = 0
- }
- )
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Parameters && conditionalBlock == other.conditionalBlock && velocityLimitParams == other.velocityLimitParams && merchantLock == other.merchantLock && conditional3dsAction == other.conditional3dsAction /* spotless:on */
- }
-
- override fun hashCode(): Int = /* spotless:off */ Objects.hash(conditionalBlock, velocityLimitParams, merchantLock, conditional3dsAction) /* spotless:on */
-
- override fun toString(): String =
- when {
- conditionalBlock != null -> "Parameters{conditionalBlock=$conditionalBlock}"
- velocityLimitParams != null ->
- "Parameters{velocityLimitParams=$velocityLimitParams}"
- merchantLock != null -> "Parameters{merchantLock=$merchantLock}"
- conditional3dsAction != null ->
- "Parameters{conditional3dsAction=$conditional3dsAction}"
- _json != null -> "Parameters{_unknown=$_json}"
- else -> throw IllegalStateException("Invalid Parameters")
- }
-
- companion object {
-
- @JvmStatic
- fun ofConditionalBlock(conditionalBlock: ConditionalBlockParameters) =
- Parameters(conditionalBlock = conditionalBlock)
-
- @JvmStatic
- fun ofVelocityLimitParams(velocityLimitParams: VelocityLimitParams) =
- Parameters(velocityLimitParams = velocityLimitParams)
-
- @JvmStatic
- fun ofMerchantLock(merchantLock: MerchantLockParameters) =
- Parameters(merchantLock = merchantLock)
-
- @JvmStatic
- fun ofConditional3dsAction(
- conditional3dsAction: Conditional3dsActionParameters
- ) = Parameters(conditional3dsAction = conditional3dsAction)
- }
-
- /**
- * An interface that defines how to map each variant of [Parameters] to a value of
- * type [T].
- */
- interface Visitor {
-
- fun visitConditionalBlock(conditionalBlock: ConditionalBlockParameters): T
-
- fun visitVelocityLimitParams(velocityLimitParams: VelocityLimitParams): T
-
- fun visitMerchantLock(merchantLock: MerchantLockParameters): T
-
- fun visitConditional3dsAction(
- conditional3dsAction: Conditional3dsActionParameters
- ): T
-
- /**
- * Maps an unknown variant of [Parameters] to a value of type [T].
- *
- * An instance of [Parameters] can contain an unknown variant if it was
- * deserialized from data that doesn't match any known variant. For example, if
- * the SDK is on an older version than the API, then the API may respond with
- * new variants that the SDK is unaware of.
- *
- * @throws LithicInvalidDataException in the default implementation.
- */
- fun unknown(json: JsonValue?): T {
- throw LithicInvalidDataException("Unknown Parameters: $json")
- }
- }
-
- internal class Deserializer : BaseDeserializer(Parameters::class) {
-
- override fun ObjectCodec.deserialize(node: JsonNode): Parameters {
- val json = JsonValue.fromJsonNode(node)
-
- val bestMatches =
- sequenceOf(
- tryDeserialize(
- node,
- jacksonTypeRef(),
- )
- ?.let { Parameters(conditionalBlock = it, _json = json) },
- tryDeserialize(node, jacksonTypeRef())
- ?.let {
- Parameters(velocityLimitParams = it, _json = json)
- },
- tryDeserialize(node, jacksonTypeRef())
- ?.let { Parameters(merchantLock = it, _json = json) },
- tryDeserialize(
- node,
- jacksonTypeRef(),
- )
- ?.let {
- Parameters(conditional3dsAction = it, _json = json)
- },
- )
- .filterNotNull()
- .allMaxBy { it.validity() }
- .toList()
- return when (bestMatches.size) {
- // This can happen if what we're deserializing is completely
- // incompatible with all the possible variants (e.g. deserializing from
- // boolean).
- 0 -> Parameters(_json = json)
- 1 -> bestMatches.single()
- // If there's more than one match with the highest validity, then use
- // the first completely valid match, or simply the first match if none
- // are completely valid.
- else -> bestMatches.firstOrNull { it.isValid() } ?: bestMatches.first()
- }
- }
- }
-
- internal class Serializer : BaseSerializer(Parameters::class) {
-
- override fun serialize(
- value: Parameters,
- generator: JsonGenerator,
- provider: SerializerProvider,
- ) {
- when {
- value.conditionalBlock != null ->
- generator.writeObject(value.conditionalBlock)
- value.velocityLimitParams != null ->
- generator.writeObject(value.velocityLimitParams)
- value.merchantLock != null -> generator.writeObject(value.merchantLock)
- value.conditional3dsAction != null ->
- generator.writeObject(value.conditional3dsAction)
- value._json != null -> generator.writeObject(value._json)
- else -> throw IllegalStateException("Invalid Parameters")
- }
- }
- }
-
- class MerchantLockParameters
- private constructor(
- private val merchants: JsonField>,
- private val additionalProperties: MutableMap,
- ) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("merchants")
- @ExcludeMissing
- merchants: JsonField> = JsonMissing.of()
- ) : this(merchants, mutableMapOf())
-
- /**
- * A list of merchant locks defining specific merchants or groups of merchants
- * (based on descriptors or IDs) that the lock applies to.
- *
- * @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 merchants(): List = merchants.getRequired("merchants")
-
- /**
- * Returns the raw JSON value of [merchants].
- *
- * Unlike [merchants], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("merchants")
- @ExcludeMissing
- fun _merchants(): JsonField> = merchants
-
- @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
- * [MerchantLockParameters].
- *
- * The following fields are required:
- * ```java
- * .merchants()
- * ```
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [MerchantLockParameters]. */
- class Builder internal constructor() {
-
- private var merchants: JsonField>? = null
- private var additionalProperties: MutableMap =
- mutableMapOf()
-
- @JvmSynthetic
- internal fun from(merchantLockParameters: MerchantLockParameters) = apply {
- merchants = merchantLockParameters.merchants.map { it.toMutableList() }
- additionalProperties =
- merchantLockParameters.additionalProperties.toMutableMap()
- }
-
- /**
- * A list of merchant locks defining specific merchants or groups of
- * merchants (based on descriptors or IDs) that the lock applies to.
- */
- fun merchants(merchants: List) =
- merchants(JsonField.of(merchants))
-
- /**
- * Sets [Builder.merchants] to an arbitrary JSON value.
- *
- * You should usually call [Builder.merchants] with a well-typed
- * `List` value instead. This method is primarily for setting the
- * field to an undocumented or not yet supported value.
- */
- fun merchants(merchants: JsonField>) = apply {
- this.merchants = merchants.map { it.toMutableList() }
- }
-
- /**
- * Adds a single [Merchant] to [merchants].
- *
- * @throws IllegalStateException if the field was previously set to a
- * non-list.
- */
- fun addMerchant(merchant: Merchant) = apply {
- merchants =
- (merchants ?: JsonField.of(mutableListOf())).also {
- checkKnown("merchants", it).add(merchant)
- }
- }
-
- 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 [MerchantLockParameters].
- *
- * Further updates to this [Builder] will not mutate the returned instance.
- *
- * The following fields are required:
- * ```java
- * .merchants()
- * ```
- *
- * @throws IllegalStateException if any required field is unset.
- */
- fun build(): MerchantLockParameters =
- MerchantLockParameters(
- checkRequired("merchants", merchants).map { it.toImmutable() },
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): MerchantLockParameters = apply {
- if (validated) {
- return@apply
- }
-
- merchants().forEach { it.validate() }
- 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 =
- (merchants.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0)
-
- /**
- * Represents a specific merchant lock based on their ID or descriptor. Each
- * merchant object allows transaction rules to work at a granular level and
- * requires at least one of merchant_id or descriptor.
- */
- class Merchant
- private constructor(
- private val comment: JsonField,
- private val descriptor: JsonField,
- private val merchantId: JsonField,
- private val additionalProperties: MutableMap,
- ) {
-
- @JsonCreator
- private constructor(
- @JsonProperty("comment")
- @ExcludeMissing
- comment: JsonField = JsonMissing.of(),
- @JsonProperty("descriptor")
- @ExcludeMissing
- descriptor: JsonField = JsonMissing.of(),
- @JsonProperty("merchant_id")
- @ExcludeMissing
- merchantId: JsonField = JsonMissing.of(),
- ) : this(comment, descriptor, merchantId, mutableMapOf())
-
- /**
- * A comment or explanation about the merchant, used internally for rule
- * management purposes.
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun comment(): Optional = comment.getOptional("comment")
-
- /**
- * Short description of the merchant, often used to provide more
- * human-readable context about the transaction merchant. This is typically
- * the name or label shown on transaction summaries.
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun descriptor(): Optional = descriptor.getOptional("descriptor")
-
- /**
- * Unique alphanumeric identifier for the payment card acceptor (merchant).
- * This attribute specifies the merchant entity that will be locked or
- * referenced for authorization rules.
- *
- * @throws LithicInvalidDataException if the JSON field has an unexpected
- * type (e.g. if the server responded with an unexpected value).
- */
- fun merchantId(): Optional = merchantId.getOptional("merchant_id")
-
- /**
- * Returns the raw JSON value of [comment].
- *
- * Unlike [comment], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("comment")
- @ExcludeMissing
- fun _comment(): JsonField = comment
-
- /**
- * 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 [merchantId].
- *
- * Unlike [merchantId], this method doesn't throw if the JSON field has an
- * unexpected type.
- */
- @JsonProperty("merchant_id")
- @ExcludeMissing
- fun _merchantId(): JsonField = merchantId
-
- @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 [Merchant].
- */
- @JvmStatic fun builder() = Builder()
- }
-
- /** A builder for [Merchant]. */
- class Builder internal constructor() {
-
- private var comment: JsonField = JsonMissing.of()
- private var descriptor: JsonField = JsonMissing.of()
- private var merchantId: JsonField = JsonMissing.of()
- private var additionalProperties: MutableMap =
- mutableMapOf()
-
- @JvmSynthetic
- internal fun from(merchant: Merchant) = apply {
- comment = merchant.comment
- descriptor = merchant.descriptor
- merchantId = merchant.merchantId
- additionalProperties = merchant.additionalProperties.toMutableMap()
- }
-
- /**
- * A comment or explanation about the merchant, used internally for rule
- * management purposes.
- */
- fun comment(comment: String) = comment(JsonField.of(comment))
-
- /**
- * Sets [Builder.comment] to an arbitrary JSON value.
- *
- * You should usually call [Builder.comment] with a well-typed [String]
- * value instead. This method is primarily for setting the field to an
- * undocumented or not yet supported value.
- */
- fun comment(comment: JsonField) = apply {
- this.comment = comment
- }
-
- /**
- * Short description of the merchant, often used to provide more
- * human-readable context about the transaction merchant. This is
- * typically the name or label shown on transaction summaries.
- */
- 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
- }
-
- /**
- * Unique alphanumeric identifier for the payment card acceptor
- * (merchant). This attribute specifies the merchant entity that will be
- * locked or referenced for authorization rules.
- */
- fun merchantId(merchantId: String) =
- merchantId(JsonField.of(merchantId))
-
- /**
- * Sets [Builder.merchantId] to an arbitrary JSON value.
- *
- * You should usually call [Builder.merchantId] with a well-typed
- * [String] value instead. This method is primarily for setting the
- * field to an undocumented or not yet supported value.
- */
- fun merchantId(merchantId: JsonField) = apply {
- this.merchantId = merchantId
- }
-
- 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 [Merchant].
- *
- * Further updates to this [Builder] will not mutate the returned
- * instance.
- */
- fun build(): Merchant =
- Merchant(
- comment,
- descriptor,
- merchantId,
- additionalProperties.toMutableMap(),
- )
- }
-
- private var validated: Boolean = false
-
- fun validate(): Merchant = apply {
- if (validated) {
- return@apply
- }
-
- comment()
- descriptor()
- merchantId()
- 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 (comment.asKnown().isPresent) 1 else 0) +
- (if (descriptor.asKnown().isPresent) 1 else 0) +
- (if (merchantId.asKnown().isPresent) 1 else 0)
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is Merchant && comment == other.comment && descriptor == other.descriptor && merchantId == other.merchantId && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(comment, descriptor, merchantId, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "Merchant{comment=$comment, descriptor=$descriptor, merchantId=$merchantId, additionalProperties=$additionalProperties}"
- }
-
- override fun equals(other: Any?): Boolean {
- if (this === other) {
- return true
- }
-
- return /* spotless:off */ other is MerchantLockParameters && merchants == other.merchants && additionalProperties == other.additionalProperties /* spotless:on */
- }
-
- /* spotless:off */
- private val hashCode: Int by lazy { Objects.hash(merchants, additionalProperties) }
- /* spotless:on */
-
- override fun hashCode(): Int = hashCode
-
- override fun toString() =
- "MerchantLockParameters{merchants=$merchants, additionalProperties=$additionalProperties}"
- }
-
- class Conditional3dsActionParameters
- private constructor(
- private val action: JsonField,
- private val conditions: JsonField>,
- private val additionalProperties: MutableMap