diff --git a/.release-please-manifest.json b/.release-please-manifest.json index f118d043..65b6e7b4 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.128.0" + ".": "0.129.0" } \ No newline at end of file diff --git a/.stats.yml b/.stats.yml index e2068bef..7ecdcfae 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ configured_endpoints: 214 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-a4afc884f86f30a87445552888031ac1ca18aed0476d7120da555bf457627e65.yml -openapi_spec_hash: ce8d0830986c702f0c7a693b1c3cc5a2 -config_hash: 4b618a1df59e555cebe6aa13e8c0218f +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/lithic/lithic-8e691d2dedaea1906ebbe28b28c978855d5e4fe5fe595a8d23917df851123400.yml +openapi_spec_hash: c33e82abb4d7c979d05386ca230464d3 +config_hash: 5bb913c05ebeb301ec925b16e75bb251 diff --git a/CHANGELOG.md b/CHANGELOG.md index 6483fcc5..4fe18bc8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.129.0 (2026-06-19) + +Full Changelog: [v0.128.0...v0.129.0](https://github.com/lithic-com/lithic-java/compare/v0.128.0...v0.129.0) + +### Features + +* **api:** add ACH payment update actions, event stream, rule features, and result types ([d7c895d](https://github.com/lithic-com/lithic-java/commit/d7c895d86ee84ae68111bb6e995c21cccd10994a)) + ## 0.128.0 (2026-06-16) Full Changelog: [v0.127.0...v0.128.0](https://github.com/lithic-com/lithic-java/compare/v0.127.0...v0.128.0) diff --git a/README.md b/README.md index 9323dd11..0f9664a8 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.128.0) -[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.128.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.128.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.lithic.api/lithic-java)](https://central.sonatype.com/artifact/com.lithic.api/lithic-java/0.129.0) +[![javadoc](https://javadoc.io/badge2/com.lithic.api/lithic-java/0.129.0/javadoc.svg)](https://javadoc.io/doc/com.lithic.api/lithic-java/0.129.0) @@ -22,7 +22,7 @@ Use the Lithic MCP Server to enable AI assistants to interact with this API, all -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.128.0). +The REST API documentation can be found on [docs.lithic.com](https://docs.lithic.com). Javadocs are available on [javadoc.io](https://javadoc.io/doc/com.lithic.api/lithic-java/0.129.0). @@ -33,7 +33,7 @@ The REST API documentation can be found on [docs.lithic.com](https://docs.lithic ### Gradle ```kotlin -implementation("com.lithic.api:lithic-java:0.128.0") +implementation("com.lithic.api:lithic-java:0.129.0") ``` ### Maven @@ -42,7 +42,7 @@ implementation("com.lithic.api:lithic-java:0.128.0") com.lithic.api lithic-java - 0.128.0 + 0.129.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 1d421d9f..2f1ae6ee 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -8,7 +8,7 @@ repositories { allprojects { group = "com.lithic.api" - version = "0.128.0" // x-release-please-version + version = "0.129.0" // x-release-please-version } subprojects { diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AchPaymentUpdateAction.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AchPaymentUpdateAction.kt new file mode 100644 index 00000000..c4a6a5e6 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AchPaymentUpdateAction.kt @@ -0,0 +1,1135 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.fasterxml.jackson.core.JsonGenerator +import com.fasterxml.jackson.core.ObjectCodec +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.SerializerProvider +import com.fasterxml.jackson.databind.annotation.JsonDeserialize +import com.fasterxml.jackson.databind.annotation.JsonSerialize +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.BaseDeserializer +import com.lithic.api.core.BaseSerializer +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.allMaxBy +import com.lithic.api.core.checkRequired +import com.lithic.api.core.getOrThrow +import com.lithic.api.errors.LithicInvalidDataException +import java.util.Collections +import java.util.Objects +import java.util.Optional +import kotlin.jvm.optionals.getOrNull + +@JsonDeserialize(using = AchPaymentUpdateAction.Deserializer::class) +@JsonSerialize(using = AchPaymentUpdateAction.Serializer::class) +class AchPaymentUpdateAction +private constructor( + private val tag: TagAction? = null, + private val createCase: CreateCaseAction? = null, + private val _json: JsonValue? = null, +) { + + fun tag(): Optional = Optional.ofNullable(tag) + + fun createCase(): Optional = Optional.ofNullable(createCase) + + fun isTag(): Boolean = tag != null + + fun isCreateCase(): Boolean = createCase != null + + fun asTag(): TagAction = tag.getOrThrow("tag") + + fun asCreateCase(): CreateCaseAction = createCase.getOrThrow("createCase") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, unless + * [visitor] overrides [Visitor.unknown]. To handle variants not known to this version of the + * SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.lithic.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = achPaymentUpdateAction.accept(new AchPaymentUpdateAction.Visitor>() { + * @Override + * public Optional visitTag(TagAction tag) { + * return Optional.of(tag.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws LithicInvalidDataException if [Visitor.unknown] is not overridden in [visitor] and + * the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + tag != null -> visitor.visitTag(tag) + createCase != null -> visitor.visitCreateCase(createCase) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AchPaymentUpdateAction = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTag(tag: TagAction) { + tag.validate() + } + + override fun visitCreateCase(createCase: CreateCaseAction) { + createCase.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 visitTag(tag: TagAction) = tag.validity() + + override fun visitCreateCase(createCase: CreateCaseAction) = createCase.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AchPaymentUpdateAction && tag == other.tag && createCase == other.createCase + } + + override fun hashCode(): Int = Objects.hash(tag, createCase) + + override fun toString(): String = + when { + tag != null -> "AchPaymentUpdateAction{tag=$tag}" + createCase != null -> "AchPaymentUpdateAction{createCase=$createCase}" + _json != null -> "AchPaymentUpdateAction{_unknown=$_json}" + else -> throw IllegalStateException("Invalid AchPaymentUpdateAction") + } + + companion object { + + @JvmStatic fun ofTag(tag: TagAction) = AchPaymentUpdateAction(tag = tag) + + @JvmStatic + fun ofCreateCase(createCase: CreateCaseAction) = + AchPaymentUpdateAction(createCase = createCase) + } + + /** + * An interface that defines how to map each variant of [AchPaymentUpdateAction] to a value of + * type [T]. + */ + interface Visitor { + + fun visitTag(tag: TagAction): T + + fun visitCreateCase(createCase: CreateCaseAction): T + + /** + * Maps an unknown variant of [AchPaymentUpdateAction] to a value of type [T]. + * + * An instance of [AchPaymentUpdateAction] 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 AchPaymentUpdateAction: $json") + } + } + + internal class Deserializer : + BaseDeserializer(AchPaymentUpdateAction::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): AchPaymentUpdateAction { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + AchPaymentUpdateAction(tag = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + AchPaymentUpdateAction(createCase = 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 -> AchPaymentUpdateAction(_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(AchPaymentUpdateAction::class) { + + override fun serialize( + value: AchPaymentUpdateAction, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.tag != null -> generator.writeObject(value.tag) + value.createCase != null -> generator.writeObject(value.createCase) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid AchPaymentUpdateAction") + } + } + } + + class TagAction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val key: JsonField, + private val type: JsonField, + private val value: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("value") @ExcludeMissing value: JsonField = JsonMissing.of(), + ) : this(key, type, value, mutableMapOf()) + + /** + * The key of the tag to apply to the payment + * + * @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 key(): String = key.getRequired("key") + + /** + * Tag the payment with key-value metadata + * + * @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 type(): Type = type.getRequired("type") + + /** + * The value of the tag to apply to the payment + * + * @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 value(): String = value.getRequired("value") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * 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 + + /** + * 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 [TagAction]. + * + * The following fields are required: + * ```java + * .key() + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagAction]. */ + class Builder internal constructor() { + + private var key: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tagAction: TagAction) = apply { + key = tagAction.key + type = tagAction.type + value = tagAction.value + additionalProperties = tagAction.additionalProperties.toMutableMap() + } + + /** The key of the tag to apply to the payment */ + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun key(key: JsonField) = apply { this.key = key } + + /** Tag the payment with key-value metadata */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] 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 } + + /** The value of the tag to apply to the payment */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] 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 } + + 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 [TagAction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagAction = + TagAction( + checkRequired("key", key), + checkRequired("type", type), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): TagAction = apply { + if (validated) { + return@apply + } + + key() + type().validate() + value() + 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 (key.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + /** Tag the payment with key-value metadata */ + class Type @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 TAG = of("TAG") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TAG + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + TAG, + /** An enum member indicating that [Type] 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) { + TAG -> Value.TAG + 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) { + TAG -> Known.TAG + else -> throw LithicInvalidDataException("Unknown Type: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagAction && + key == other.key && + type == other.type && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(key, type, value, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TagAction{key=$key, type=$type, value=$value, additionalProperties=$additionalProperties}" + } + + class CreateCaseAction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val queueToken: JsonField, + private val scope: JsonField, + private val type: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("queue_token") + @ExcludeMissing + queueToken: JsonField = JsonMissing.of(), + @JsonProperty("scope") @ExcludeMissing scope: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + ) : this(queueToken, scope, type, mutableMapOf()) + + /** + * The token of the queue to create the case in + * + * @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 queueToken(): String = queueToken.getRequired("queue_token") + + /** + * The scope of the case to create + * + * @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 scope(): Scope = scope.getRequired("scope") + + /** + * Create a case for the payment + * + * @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 type(): Type = type.getRequired("type") + + /** + * Returns the raw JSON value of [queueToken]. + * + * Unlike [queueToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("queue_token") + @ExcludeMissing + fun _queueToken(): JsonField = queueToken + + /** + * Returns the raw JSON value of [scope]. + * + * Unlike [scope], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope + + /** + * 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 + + @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 [CreateCaseAction]. + * + * The following fields are required: + * ```java + * .queueToken() + * .scope() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateCaseAction]. */ + class Builder internal constructor() { + + private var queueToken: JsonField? = null + private var scope: JsonField? = null + private var type: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createCaseAction: CreateCaseAction) = apply { + queueToken = createCaseAction.queueToken + scope = createCaseAction.scope + type = createCaseAction.type + additionalProperties = createCaseAction.additionalProperties.toMutableMap() + } + + /** The token of the queue to create the case in */ + fun queueToken(queueToken: String) = queueToken(JsonField.of(queueToken)) + + /** + * Sets [Builder.queueToken] to an arbitrary JSON value. + * + * You should usually call [Builder.queueToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun queueToken(queueToken: JsonField) = apply { this.queueToken = queueToken } + + /** The scope of the case to create */ + fun scope(scope: Scope) = scope(JsonField.of(scope)) + + /** + * Sets [Builder.scope] to an arbitrary JSON value. + * + * You should usually call [Builder.scope] with a well-typed [Scope] value instead. This + * method is primarily for setting the field to an undocumented or not yet supported + * value. + */ + fun scope(scope: JsonField) = apply { this.scope = scope } + + /** Create a case for the payment */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] 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 [CreateCaseAction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueToken() + * .scope() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreateCaseAction = + CreateCaseAction( + checkRequired("queueToken", queueToken), + checkRequired("scope", scope), + checkRequired("type", type), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CreateCaseAction = apply { + if (validated) { + return@apply + } + + queueToken() + scope().validate() + type().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 = + (if (queueToken.asKnown().isPresent) 1 else 0) + + (scope.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + /** The scope of the case to create */ + class Scope @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 FINANCIAL_ACCOUNT = of("FINANCIAL_ACCOUNT") + + @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) + } + + /** An enum containing [Scope]'s known values. */ + enum class Known { + FINANCIAL_ACCOUNT + } + + /** + * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Scope] 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 { + FINANCIAL_ACCOUNT, + /** + * An enum member indicating that [Scope] 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) { + FINANCIAL_ACCOUNT -> Value.FINANCIAL_ACCOUNT + 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) { + FINANCIAL_ACCOUNT -> Known.FINANCIAL_ACCOUNT + else -> throw LithicInvalidDataException("Unknown Scope: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Scope = 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 other is Scope && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Create a case for the payment */ + class Type @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 CREATE_CASE = of("CREATE_CASE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CREATE_CASE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + CREATE_CASE, + /** An enum member indicating that [Type] 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) { + CREATE_CASE -> Value.CREATE_CASE + 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) { + CREATE_CASE -> Known.CREATE_CASE + else -> throw LithicInvalidDataException("Unknown Type: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateCaseAction && + queueToken == other.queueToken && + scope == other.scope && + type == other.type && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(queueToken, scope, type, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateCaseAction{queueToken=$queueToken, scope=$scope, type=$type, additionalProperties=$additionalProperties}" + } +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt index 1421d2e8..e3ae5912 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt @@ -205,9 +205,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or ACH_PAYMENT_UPDATE event + * stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or ACH_PAYMENT_UPDATE event + * stream. * * @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). @@ -655,9 +657,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or ACH_PAYMENT_UPDATE + * event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or ACH_PAYMENT_UPDATE + * event stream. */ fun type(type: AuthRuleType) = type(JsonField.of(type)) @@ -1052,6 +1056,19 @@ private constructor( ) ) + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction)`. + */ + fun parameters( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + parameters( + Parameters.ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) + ) + /** * Alias for calling [parameters] with `Parameters.ofTypescriptCode(typescriptCode)`. */ @@ -1182,6 +1199,9 @@ private constructor( private val conditionalCardTransactionUpdateAction: ConditionalCardTransactionUpdateActionParameters? = null, + private val conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters? = + null, private val typescriptCode: TypescriptCodeParameters? = null, private val conditionalAuthorizationAdjustment: ConditionalAuthorizationAdjustmentParameters? = @@ -1216,6 +1236,10 @@ private constructor( Optional = Optional.ofNullable(conditionalCardTransactionUpdateAction) + fun conditionalAchPaymentUpdateAction(): + Optional = + Optional.ofNullable(conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ fun typescriptCode(): Optional = Optional.ofNullable(typescriptCode) @@ -1241,6 +1265,9 @@ private constructor( fun isConditionalCardTransactionUpdateAction(): Boolean = conditionalCardTransactionUpdateAction != null + fun isConditionalAchPaymentUpdateAction(): Boolean = + conditionalAchPaymentUpdateAction != null + fun isTypescriptCode(): Boolean = typescriptCode != null fun isConditionalAuthorizationAdjustment(): Boolean = @@ -1274,6 +1301,9 @@ private constructor( "conditionalCardTransactionUpdateAction" ) + fun asConditionalAchPaymentUpdateAction(): ConditionalAchPaymentUpdateActionParameters = + conditionalAchPaymentUpdateAction.getOrThrow("conditionalAchPaymentUpdateAction") + /** Parameters for defining a TypeScript code rule */ fun asTypescriptCode(): TypescriptCodeParameters = typescriptCode.getOrThrow("typescriptCode") @@ -1332,6 +1362,10 @@ private constructor( visitor.visitConditionalCardTransactionUpdateAction( conditionalCardTransactionUpdateAction ) + conditionalAchPaymentUpdateAction != null -> + visitor.visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) typescriptCode != null -> visitor.visitTypescriptCode(typescriptCode) conditionalAuthorizationAdjustment != null -> visitor.visitConditionalAuthorizationAdjustment( @@ -1406,6 +1440,13 @@ private constructor( conditionalCardTransactionUpdateAction.validate() } + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) { + conditionalAchPaymentUpdateAction.validate() + } + override fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters) { typescriptCode.validate() } @@ -1471,6 +1512,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ) = conditionalCardTransactionUpdateAction.validity() + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = conditionalAchPaymentUpdateAction.validity() + override fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters) = typescriptCode.validity() @@ -1498,6 +1544,7 @@ private constructor( conditionalTokenizationAction == other.conditionalTokenizationAction && conditionalCardTransactionUpdateAction == other.conditionalCardTransactionUpdateAction && + conditionalAchPaymentUpdateAction == other.conditionalAchPaymentUpdateAction && typescriptCode == other.typescriptCode && conditionalAuthorizationAdjustment == other.conditionalAuthorizationAdjustment } @@ -1512,6 +1559,7 @@ private constructor( conditionalAchAction, conditionalTokenizationAction, conditionalCardTransactionUpdateAction, + conditionalAchPaymentUpdateAction, typescriptCode, conditionalAuthorizationAdjustment, ) @@ -1532,6 +1580,8 @@ private constructor( "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" conditionalCardTransactionUpdateAction != null -> "Parameters{conditionalCardTransactionUpdateAction=$conditionalCardTransactionUpdateAction}" + conditionalAchPaymentUpdateAction != null -> + "Parameters{conditionalAchPaymentUpdateAction=$conditionalAchPaymentUpdateAction}" typescriptCode != null -> "Parameters{typescriptCode=$typescriptCode}" conditionalAuthorizationAdjustment != null -> "Parameters{conditionalAuthorizationAdjustment=$conditionalAuthorizationAdjustment}" @@ -1583,6 +1633,14 @@ private constructor( conditionalCardTransactionUpdateAction ) + @JvmStatic + fun ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + Parameters( + conditionalAchPaymentUpdateAction = conditionalAchPaymentUpdateAction + ) + /** Parameters for defining a TypeScript code rule */ @JvmStatic fun ofTypescriptCode(typescriptCode: TypescriptCodeParameters) = @@ -1632,6 +1690,10 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ): T + fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ): T + /** Parameters for defining a TypeScript code rule */ fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters): T @@ -1707,6 +1769,18 @@ private constructor( _json = json, ) }, + tryDeserialize( + node, + jacksonTypeRef< + ConditionalAchPaymentUpdateActionParameters + >(), + ) + ?.let { + Parameters( + conditionalAchPaymentUpdateAction = it, + _json = json, + ) + }, tryDeserialize(node, jacksonTypeRef()) ?.let { Parameters(typescriptCode = it, _json = json) }, tryDeserialize( @@ -1761,6 +1835,8 @@ private constructor( generator.writeObject(value.conditionalTokenizationAction) value.conditionalCardTransactionUpdateAction != null -> generator.writeObject(value.conditionalCardTransactionUpdateAction) + value.conditionalAchPaymentUpdateAction != null -> + generator.writeObject(value.conditionalAchPaymentUpdateAction) value.typescriptCode != null -> generator.writeObject(value.typescriptCode) value.conditionalAuthorizationAdjustment != null -> generator.writeObject(value.conditionalAuthorizationAdjustment) @@ -2027,6 +2103,19 @@ private constructor( ) ) + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction)`. + */ + fun parameters( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + parameters( + Parameters.ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) + ) + /** * Alias for calling [parameters] with `Parameters.ofTypescriptCode(typescriptCode)`. */ @@ -2186,6 +2275,9 @@ private constructor( private val conditionalCardTransactionUpdateAction: ConditionalCardTransactionUpdateActionParameters? = null, + private val conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters? = + null, private val typescriptCode: TypescriptCodeParameters? = null, private val conditionalAuthorizationAdjustment: ConditionalAuthorizationAdjustmentParameters? = @@ -2220,6 +2312,10 @@ private constructor( Optional = Optional.ofNullable(conditionalCardTransactionUpdateAction) + fun conditionalAchPaymentUpdateAction(): + Optional = + Optional.ofNullable(conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ fun typescriptCode(): Optional = Optional.ofNullable(typescriptCode) @@ -2245,6 +2341,9 @@ private constructor( fun isConditionalCardTransactionUpdateAction(): Boolean = conditionalCardTransactionUpdateAction != null + fun isConditionalAchPaymentUpdateAction(): Boolean = + conditionalAchPaymentUpdateAction != null + fun isTypescriptCode(): Boolean = typescriptCode != null fun isConditionalAuthorizationAdjustment(): Boolean = @@ -2278,6 +2377,9 @@ private constructor( "conditionalCardTransactionUpdateAction" ) + fun asConditionalAchPaymentUpdateAction(): ConditionalAchPaymentUpdateActionParameters = + conditionalAchPaymentUpdateAction.getOrThrow("conditionalAchPaymentUpdateAction") + /** Parameters for defining a TypeScript code rule */ fun asTypescriptCode(): TypescriptCodeParameters = typescriptCode.getOrThrow("typescriptCode") @@ -2336,6 +2438,10 @@ private constructor( visitor.visitConditionalCardTransactionUpdateAction( conditionalCardTransactionUpdateAction ) + conditionalAchPaymentUpdateAction != null -> + visitor.visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) typescriptCode != null -> visitor.visitTypescriptCode(typescriptCode) conditionalAuthorizationAdjustment != null -> visitor.visitConditionalAuthorizationAdjustment( @@ -2410,6 +2516,13 @@ private constructor( conditionalCardTransactionUpdateAction.validate() } + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) { + conditionalAchPaymentUpdateAction.validate() + } + override fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters) { typescriptCode.validate() } @@ -2475,6 +2588,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ) = conditionalCardTransactionUpdateAction.validity() + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = conditionalAchPaymentUpdateAction.validity() + override fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters) = typescriptCode.validity() @@ -2502,6 +2620,7 @@ private constructor( conditionalTokenizationAction == other.conditionalTokenizationAction && conditionalCardTransactionUpdateAction == other.conditionalCardTransactionUpdateAction && + conditionalAchPaymentUpdateAction == other.conditionalAchPaymentUpdateAction && typescriptCode == other.typescriptCode && conditionalAuthorizationAdjustment == other.conditionalAuthorizationAdjustment } @@ -2516,6 +2635,7 @@ private constructor( conditionalAchAction, conditionalTokenizationAction, conditionalCardTransactionUpdateAction, + conditionalAchPaymentUpdateAction, typescriptCode, conditionalAuthorizationAdjustment, ) @@ -2536,6 +2656,8 @@ private constructor( "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" conditionalCardTransactionUpdateAction != null -> "Parameters{conditionalCardTransactionUpdateAction=$conditionalCardTransactionUpdateAction}" + conditionalAchPaymentUpdateAction != null -> + "Parameters{conditionalAchPaymentUpdateAction=$conditionalAchPaymentUpdateAction}" typescriptCode != null -> "Parameters{typescriptCode=$typescriptCode}" conditionalAuthorizationAdjustment != null -> "Parameters{conditionalAuthorizationAdjustment=$conditionalAuthorizationAdjustment}" @@ -2587,6 +2709,14 @@ private constructor( conditionalCardTransactionUpdateAction ) + @JvmStatic + fun ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + Parameters( + conditionalAchPaymentUpdateAction = conditionalAchPaymentUpdateAction + ) + /** Parameters for defining a TypeScript code rule */ @JvmStatic fun ofTypescriptCode(typescriptCode: TypescriptCodeParameters) = @@ -2636,6 +2766,10 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ): T + fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ): T + /** Parameters for defining a TypeScript code rule */ fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters): T @@ -2711,6 +2845,18 @@ private constructor( _json = json, ) }, + tryDeserialize( + node, + jacksonTypeRef< + ConditionalAchPaymentUpdateActionParameters + >(), + ) + ?.let { + Parameters( + conditionalAchPaymentUpdateAction = it, + _json = json, + ) + }, tryDeserialize(node, jacksonTypeRef()) ?.let { Parameters(typescriptCode = it, _json = json) }, tryDeserialize( @@ -2765,6 +2911,8 @@ private constructor( generator.writeObject(value.conditionalTokenizationAction) value.conditionalCardTransactionUpdateAction != null -> generator.writeObject(value.conditionalCardTransactionUpdateAction) + value.conditionalAchPaymentUpdateAction != null -> + generator.writeObject(value.conditionalAchPaymentUpdateAction) value.typescriptCode != null -> generator.writeObject(value.typescriptCode) value.conditionalAuthorizationAdjustment != null -> generator.writeObject(value.conditionalAuthorizationAdjustment) @@ -3101,9 +3249,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or ACH_PAYMENT_UPDATE event + * stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or ACH_PAYMENT_UPDATE event + * stream. */ class AuthRuleType @JsonCreator private constructor(private val value: JsonField) : Enum { 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 5c62843d..c0a400f3 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 @@ -516,9 +516,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * * @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 @@ -748,6 +750,19 @@ private constructor( ) ) + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction)`. + */ + fun parameters( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + parameters( + Parameters.ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) + ) + /** * Alias for calling [parameters] with * `Parameters.ofTypescriptCode(typescriptCode)`. @@ -778,9 +793,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. */ fun type(type: AuthRuleType) = type(JsonField.of(type)) @@ -991,6 +1008,9 @@ private constructor( private val conditionalCardTransactionUpdateAction: ConditionalCardTransactionUpdateActionParameters? = null, + private val conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters? = + null, private val typescriptCode: TypescriptCodeParameters? = null, private val conditionalAuthorizationAdjustment: ConditionalAuthorizationAdjustmentParameters? = @@ -1027,6 +1047,10 @@ private constructor( Optional = Optional.ofNullable(conditionalCardTransactionUpdateAction) + fun conditionalAchPaymentUpdateAction(): + Optional = + Optional.ofNullable(conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ fun typescriptCode(): Optional = Optional.ofNullable(typescriptCode) @@ -1055,6 +1079,9 @@ private constructor( fun isConditionalCardTransactionUpdateAction(): Boolean = conditionalCardTransactionUpdateAction != null + fun isConditionalAchPaymentUpdateAction(): Boolean = + conditionalAchPaymentUpdateAction != null + fun isTypescriptCode(): Boolean = typescriptCode != null fun isConditionalAuthorizationAdjustment(): Boolean = @@ -1089,6 +1116,12 @@ private constructor( "conditionalCardTransactionUpdateAction" ) + fun asConditionalAchPaymentUpdateAction(): + ConditionalAchPaymentUpdateActionParameters = + conditionalAchPaymentUpdateAction.getOrThrow( + "conditionalAchPaymentUpdateAction" + ) + /** Parameters for defining a TypeScript code rule */ fun asTypescriptCode(): TypescriptCodeParameters = typescriptCode.getOrThrow("typescriptCode") @@ -1153,6 +1186,10 @@ private constructor( visitor.visitConditionalCardTransactionUpdateAction( conditionalCardTransactionUpdateAction ) + conditionalAchPaymentUpdateAction != null -> + visitor.visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) typescriptCode != null -> visitor.visitTypescriptCode(typescriptCode) conditionalAuthorizationAdjustment != null -> visitor.visitConditionalAuthorizationAdjustment( @@ -1229,6 +1266,13 @@ private constructor( conditionalCardTransactionUpdateAction.validate() } + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) { + conditionalAchPaymentUpdateAction.validate() + } + override fun visitTypescriptCode( typescriptCode: TypescriptCodeParameters ) { @@ -1298,6 +1342,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ) = conditionalCardTransactionUpdateAction.validity() + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = conditionalAchPaymentUpdateAction.validity() + override fun visitTypescriptCode( typescriptCode: TypescriptCodeParameters ) = typescriptCode.validity() @@ -1326,6 +1375,8 @@ private constructor( conditionalTokenizationAction == other.conditionalTokenizationAction && conditionalCardTransactionUpdateAction == other.conditionalCardTransactionUpdateAction && + conditionalAchPaymentUpdateAction == + other.conditionalAchPaymentUpdateAction && typescriptCode == other.typescriptCode && conditionalAuthorizationAdjustment == other.conditionalAuthorizationAdjustment @@ -1341,6 +1392,7 @@ private constructor( conditionalAchAction, conditionalTokenizationAction, conditionalCardTransactionUpdateAction, + conditionalAchPaymentUpdateAction, typescriptCode, conditionalAuthorizationAdjustment, ) @@ -1361,6 +1413,8 @@ private constructor( "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" conditionalCardTransactionUpdateAction != null -> "Parameters{conditionalCardTransactionUpdateAction=$conditionalCardTransactionUpdateAction}" + conditionalAchPaymentUpdateAction != null -> + "Parameters{conditionalAchPaymentUpdateAction=$conditionalAchPaymentUpdateAction}" typescriptCode != null -> "Parameters{typescriptCode=$typescriptCode}" conditionalAuthorizationAdjustment != null -> "Parameters{conditionalAuthorizationAdjustment=$conditionalAuthorizationAdjustment}" @@ -1414,6 +1468,15 @@ private constructor( conditionalCardTransactionUpdateAction ) + @JvmStatic + fun ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = + Parameters( + conditionalAchPaymentUpdateAction = conditionalAchPaymentUpdateAction + ) + /** Parameters for defining a TypeScript code rule */ @JvmStatic fun ofTypescriptCode(typescriptCode: TypescriptCodeParameters) = @@ -1464,6 +1527,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ): T + fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ): T + /** Parameters for defining a TypeScript code rule */ fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters): T @@ -1555,6 +1623,18 @@ private constructor( _json = json, ) }, + tryDeserialize( + node, + jacksonTypeRef< + ConditionalAchPaymentUpdateActionParameters + >(), + ) + ?.let { + Parameters( + conditionalAchPaymentUpdateAction = it, + _json = json, + ) + }, tryDeserialize(node, jacksonTypeRef()) ?.let { Parameters(typescriptCode = it, _json = json) }, tryDeserialize( @@ -1610,6 +1690,8 @@ private constructor( generator.writeObject(value.conditionalTokenizationAction) value.conditionalCardTransactionUpdateAction != null -> generator.writeObject(value.conditionalCardTransactionUpdateAction) + value.conditionalAchPaymentUpdateAction != null -> + generator.writeObject(value.conditionalAchPaymentUpdateAction) value.typescriptCode != null -> generator.writeObject(value.typescriptCode) value.conditionalAuthorizationAdjustment != null -> @@ -1630,9 +1712,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. */ class AuthRuleType @JsonCreator @@ -1883,9 +1967,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * * @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 @@ -2111,6 +2197,19 @@ private constructor( ) ) + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction)`. + */ + fun parameters( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + parameters( + Parameters.ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) + ) + /** * Alias for calling [parameters] with * `Parameters.ofTypescriptCode(typescriptCode)`. @@ -2141,9 +2240,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. */ fun type(type: AuthRuleType) = type(JsonField.of(type)) @@ -2298,6 +2399,9 @@ private constructor( private val conditionalCardTransactionUpdateAction: ConditionalCardTransactionUpdateActionParameters? = null, + private val conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters? = + null, private val typescriptCode: TypescriptCodeParameters? = null, private val conditionalAuthorizationAdjustment: ConditionalAuthorizationAdjustmentParameters? = @@ -2334,6 +2438,10 @@ private constructor( Optional = Optional.ofNullable(conditionalCardTransactionUpdateAction) + fun conditionalAchPaymentUpdateAction(): + Optional = + Optional.ofNullable(conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ fun typescriptCode(): Optional = Optional.ofNullable(typescriptCode) @@ -2362,6 +2470,9 @@ private constructor( fun isConditionalCardTransactionUpdateAction(): Boolean = conditionalCardTransactionUpdateAction != null + fun isConditionalAchPaymentUpdateAction(): Boolean = + conditionalAchPaymentUpdateAction != null + fun isTypescriptCode(): Boolean = typescriptCode != null fun isConditionalAuthorizationAdjustment(): Boolean = @@ -2396,6 +2507,12 @@ private constructor( "conditionalCardTransactionUpdateAction" ) + fun asConditionalAchPaymentUpdateAction(): + ConditionalAchPaymentUpdateActionParameters = + conditionalAchPaymentUpdateAction.getOrThrow( + "conditionalAchPaymentUpdateAction" + ) + /** Parameters for defining a TypeScript code rule */ fun asTypescriptCode(): TypescriptCodeParameters = typescriptCode.getOrThrow("typescriptCode") @@ -2460,6 +2577,10 @@ private constructor( visitor.visitConditionalCardTransactionUpdateAction( conditionalCardTransactionUpdateAction ) + conditionalAchPaymentUpdateAction != null -> + visitor.visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) typescriptCode != null -> visitor.visitTypescriptCode(typescriptCode) conditionalAuthorizationAdjustment != null -> visitor.visitConditionalAuthorizationAdjustment( @@ -2536,6 +2657,13 @@ private constructor( conditionalCardTransactionUpdateAction.validate() } + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) { + conditionalAchPaymentUpdateAction.validate() + } + override fun visitTypescriptCode( typescriptCode: TypescriptCodeParameters ) { @@ -2605,6 +2733,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ) = conditionalCardTransactionUpdateAction.validity() + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = conditionalAchPaymentUpdateAction.validity() + override fun visitTypescriptCode( typescriptCode: TypescriptCodeParameters ) = typescriptCode.validity() @@ -2633,6 +2766,8 @@ private constructor( conditionalTokenizationAction == other.conditionalTokenizationAction && conditionalCardTransactionUpdateAction == other.conditionalCardTransactionUpdateAction && + conditionalAchPaymentUpdateAction == + other.conditionalAchPaymentUpdateAction && typescriptCode == other.typescriptCode && conditionalAuthorizationAdjustment == other.conditionalAuthorizationAdjustment @@ -2648,6 +2783,7 @@ private constructor( conditionalAchAction, conditionalTokenizationAction, conditionalCardTransactionUpdateAction, + conditionalAchPaymentUpdateAction, typescriptCode, conditionalAuthorizationAdjustment, ) @@ -2668,6 +2804,8 @@ private constructor( "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" conditionalCardTransactionUpdateAction != null -> "Parameters{conditionalCardTransactionUpdateAction=$conditionalCardTransactionUpdateAction}" + conditionalAchPaymentUpdateAction != null -> + "Parameters{conditionalAchPaymentUpdateAction=$conditionalAchPaymentUpdateAction}" typescriptCode != null -> "Parameters{typescriptCode=$typescriptCode}" conditionalAuthorizationAdjustment != null -> "Parameters{conditionalAuthorizationAdjustment=$conditionalAuthorizationAdjustment}" @@ -2721,6 +2859,15 @@ private constructor( conditionalCardTransactionUpdateAction ) + @JvmStatic + fun ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = + Parameters( + conditionalAchPaymentUpdateAction = conditionalAchPaymentUpdateAction + ) + /** Parameters for defining a TypeScript code rule */ @JvmStatic fun ofTypescriptCode(typescriptCode: TypescriptCodeParameters) = @@ -2771,6 +2918,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ): T + fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ): T + /** Parameters for defining a TypeScript code rule */ fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters): T @@ -2862,6 +3014,18 @@ private constructor( _json = json, ) }, + tryDeserialize( + node, + jacksonTypeRef< + ConditionalAchPaymentUpdateActionParameters + >(), + ) + ?.let { + Parameters( + conditionalAchPaymentUpdateAction = it, + _json = json, + ) + }, tryDeserialize(node, jacksonTypeRef()) ?.let { Parameters(typescriptCode = it, _json = json) }, tryDeserialize( @@ -2917,6 +3081,8 @@ private constructor( generator.writeObject(value.conditionalTokenizationAction) value.conditionalCardTransactionUpdateAction != null -> generator.writeObject(value.conditionalCardTransactionUpdateAction) + value.conditionalAchPaymentUpdateAction != null -> + generator.writeObject(value.conditionalAchPaymentUpdateAction) value.typescriptCode != null -> generator.writeObject(value.typescriptCode) value.conditionalAuthorizationAdjustment != null -> @@ -2937,9 +3103,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. */ class AuthRuleType @JsonCreator @@ -3203,9 +3371,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * * @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 @@ -3472,6 +3642,19 @@ private constructor( ) ) + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction)`. + */ + fun parameters( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + parameters( + Parameters.ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) + ) + /** * Alias for calling [parameters] with * `Parameters.ofTypescriptCode(typescriptCode)`. @@ -3516,9 +3699,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. */ fun type(type: AuthRuleType) = type(JsonField.of(type)) @@ -3769,6 +3954,9 @@ private constructor( private val conditionalCardTransactionUpdateAction: ConditionalCardTransactionUpdateActionParameters? = null, + private val conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters? = + null, private val typescriptCode: TypescriptCodeParameters? = null, private val conditionalAuthorizationAdjustment: ConditionalAuthorizationAdjustmentParameters? = @@ -3805,6 +3993,10 @@ private constructor( Optional = Optional.ofNullable(conditionalCardTransactionUpdateAction) + fun conditionalAchPaymentUpdateAction(): + Optional = + Optional.ofNullable(conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ fun typescriptCode(): Optional = Optional.ofNullable(typescriptCode) @@ -3833,6 +4025,9 @@ private constructor( fun isConditionalCardTransactionUpdateAction(): Boolean = conditionalCardTransactionUpdateAction != null + fun isConditionalAchPaymentUpdateAction(): Boolean = + conditionalAchPaymentUpdateAction != null + fun isTypescriptCode(): Boolean = typescriptCode != null fun isConditionalAuthorizationAdjustment(): Boolean = @@ -3867,6 +4062,12 @@ private constructor( "conditionalCardTransactionUpdateAction" ) + fun asConditionalAchPaymentUpdateAction(): + ConditionalAchPaymentUpdateActionParameters = + conditionalAchPaymentUpdateAction.getOrThrow( + "conditionalAchPaymentUpdateAction" + ) + /** Parameters for defining a TypeScript code rule */ fun asTypescriptCode(): TypescriptCodeParameters = typescriptCode.getOrThrow("typescriptCode") @@ -3931,6 +4132,10 @@ private constructor( visitor.visitConditionalCardTransactionUpdateAction( conditionalCardTransactionUpdateAction ) + conditionalAchPaymentUpdateAction != null -> + visitor.visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) typescriptCode != null -> visitor.visitTypescriptCode(typescriptCode) conditionalAuthorizationAdjustment != null -> visitor.visitConditionalAuthorizationAdjustment( @@ -4007,6 +4212,13 @@ private constructor( conditionalCardTransactionUpdateAction.validate() } + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) { + conditionalAchPaymentUpdateAction.validate() + } + override fun visitTypescriptCode( typescriptCode: TypescriptCodeParameters ) { @@ -4076,6 +4288,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ) = conditionalCardTransactionUpdateAction.validity() + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = conditionalAchPaymentUpdateAction.validity() + override fun visitTypescriptCode( typescriptCode: TypescriptCodeParameters ) = typescriptCode.validity() @@ -4104,6 +4321,8 @@ private constructor( conditionalTokenizationAction == other.conditionalTokenizationAction && conditionalCardTransactionUpdateAction == other.conditionalCardTransactionUpdateAction && + conditionalAchPaymentUpdateAction == + other.conditionalAchPaymentUpdateAction && typescriptCode == other.typescriptCode && conditionalAuthorizationAdjustment == other.conditionalAuthorizationAdjustment @@ -4119,6 +4338,7 @@ private constructor( conditionalAchAction, conditionalTokenizationAction, conditionalCardTransactionUpdateAction, + conditionalAchPaymentUpdateAction, typescriptCode, conditionalAuthorizationAdjustment, ) @@ -4139,6 +4359,8 @@ private constructor( "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" conditionalCardTransactionUpdateAction != null -> "Parameters{conditionalCardTransactionUpdateAction=$conditionalCardTransactionUpdateAction}" + conditionalAchPaymentUpdateAction != null -> + "Parameters{conditionalAchPaymentUpdateAction=$conditionalAchPaymentUpdateAction}" typescriptCode != null -> "Parameters{typescriptCode=$typescriptCode}" conditionalAuthorizationAdjustment != null -> "Parameters{conditionalAuthorizationAdjustment=$conditionalAuthorizationAdjustment}" @@ -4192,6 +4414,15 @@ private constructor( conditionalCardTransactionUpdateAction ) + @JvmStatic + fun ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = + Parameters( + conditionalAchPaymentUpdateAction = conditionalAchPaymentUpdateAction + ) + /** Parameters for defining a TypeScript code rule */ @JvmStatic fun ofTypescriptCode(typescriptCode: TypescriptCodeParameters) = @@ -4242,6 +4473,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ): T + fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ): T + /** Parameters for defining a TypeScript code rule */ fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters): T @@ -4333,6 +4569,18 @@ private constructor( _json = json, ) }, + tryDeserialize( + node, + jacksonTypeRef< + ConditionalAchPaymentUpdateActionParameters + >(), + ) + ?.let { + Parameters( + conditionalAchPaymentUpdateAction = it, + _json = json, + ) + }, tryDeserialize(node, jacksonTypeRef()) ?.let { Parameters(typescriptCode = it, _json = json) }, tryDeserialize( @@ -4388,6 +4636,8 @@ private constructor( generator.writeObject(value.conditionalTokenizationAction) value.conditionalCardTransactionUpdateAction != null -> generator.writeObject(value.conditionalCardTransactionUpdateAction) + value.conditionalAchPaymentUpdateAction != null -> + generator.writeObject(value.conditionalAchPaymentUpdateAction) value.typescriptCode != null -> generator.writeObject(value.typescriptCode) value.conditionalAuthorizationAdjustment != null -> @@ -4408,9 +4658,11 @@ private constructor( * - `VELOCITY_LIMIT`: AUTHORIZATION event stream. * - `MERCHANT_LOCK`: AUTHORIZATION event stream. * - `CONDITIONAL_ACTION`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. * - `TYPESCRIPT_CODE`: AUTHORIZATION, THREE_DS_AUTHENTICATION, TOKENIZATION, - * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, or CARD_TRANSACTION_UPDATE event stream. + * ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, or + * ACH_PAYMENT_UPDATE event stream. */ class AuthRuleType @JsonCreator diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt index 39ab125a..63c1afd7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2DraftParams.kt @@ -188,6 +188,14 @@ private constructor( conditionalCardTransactionUpdateAction: ConditionalCardTransactionUpdateActionParameters ) = apply { body.parameters(conditionalCardTransactionUpdateAction) } + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction)`. + */ + fun parameters( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = apply { body.parameters(conditionalAchPaymentUpdateAction) } + /** Alias for calling [parameters] with `Parameters.ofTypescriptCode(typescriptCode)`. */ fun parameters(typescriptCode: TypescriptCodeParameters) = apply { body.parameters(typescriptCode) @@ -489,6 +497,19 @@ private constructor( ) ) + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction)`. + */ + fun parameters( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + parameters( + Parameters.ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) + ) + /** * Alias for calling [parameters] with `Parameters.ofTypescriptCode(typescriptCode)`. */ @@ -606,6 +627,9 @@ private constructor( private val conditionalCardTransactionUpdateAction: ConditionalCardTransactionUpdateActionParameters? = null, + private val conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters? = + null, private val typescriptCode: TypescriptCodeParameters? = null, private val conditionalAuthorizationAdjustment: ConditionalAuthorizationAdjustmentParameters? = @@ -639,6 +663,10 @@ private constructor( Optional = Optional.ofNullable(conditionalCardTransactionUpdateAction) + fun conditionalAchPaymentUpdateAction(): + Optional = + Optional.ofNullable(conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ fun typescriptCode(): Optional = Optional.ofNullable(typescriptCode) @@ -664,6 +692,9 @@ private constructor( fun isConditionalCardTransactionUpdateAction(): Boolean = conditionalCardTransactionUpdateAction != null + fun isConditionalAchPaymentUpdateAction(): Boolean = + conditionalAchPaymentUpdateAction != null + fun isTypescriptCode(): Boolean = typescriptCode != null fun isConditionalAuthorizationAdjustment(): Boolean = @@ -697,6 +728,9 @@ private constructor( "conditionalCardTransactionUpdateAction" ) + fun asConditionalAchPaymentUpdateAction(): ConditionalAchPaymentUpdateActionParameters = + conditionalAchPaymentUpdateAction.getOrThrow("conditionalAchPaymentUpdateAction") + /** Parameters for defining a TypeScript code rule */ fun asTypescriptCode(): TypescriptCodeParameters = typescriptCode.getOrThrow("typescriptCode") @@ -752,6 +786,10 @@ private constructor( visitor.visitConditionalCardTransactionUpdateAction( conditionalCardTransactionUpdateAction ) + conditionalAchPaymentUpdateAction != null -> + visitor.visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) typescriptCode != null -> visitor.visitTypescriptCode(typescriptCode) conditionalAuthorizationAdjustment != null -> visitor.visitConditionalAuthorizationAdjustment( @@ -825,6 +863,13 @@ private constructor( conditionalCardTransactionUpdateAction.validate() } + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) { + conditionalAchPaymentUpdateAction.validate() + } + override fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters) { typescriptCode.validate() } @@ -890,6 +935,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ) = conditionalCardTransactionUpdateAction.validity() + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = conditionalAchPaymentUpdateAction.validity() + override fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters) = typescriptCode.validity() @@ -917,6 +967,7 @@ private constructor( conditionalTokenizationAction == other.conditionalTokenizationAction && conditionalCardTransactionUpdateAction == other.conditionalCardTransactionUpdateAction && + conditionalAchPaymentUpdateAction == other.conditionalAchPaymentUpdateAction && typescriptCode == other.typescriptCode && conditionalAuthorizationAdjustment == other.conditionalAuthorizationAdjustment } @@ -931,6 +982,7 @@ private constructor( conditionalAchAction, conditionalTokenizationAction, conditionalCardTransactionUpdateAction, + conditionalAchPaymentUpdateAction, typescriptCode, conditionalAuthorizationAdjustment, ) @@ -951,6 +1003,8 @@ private constructor( "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" conditionalCardTransactionUpdateAction != null -> "Parameters{conditionalCardTransactionUpdateAction=$conditionalCardTransactionUpdateAction}" + conditionalAchPaymentUpdateAction != null -> + "Parameters{conditionalAchPaymentUpdateAction=$conditionalAchPaymentUpdateAction}" typescriptCode != null -> "Parameters{typescriptCode=$typescriptCode}" conditionalAuthorizationAdjustment != null -> "Parameters{conditionalAuthorizationAdjustment=$conditionalAuthorizationAdjustment}" @@ -1001,6 +1055,11 @@ private constructor( conditionalCardTransactionUpdateAction = conditionalCardTransactionUpdateAction ) + @JvmStatic + fun ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = Parameters(conditionalAchPaymentUpdateAction = conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ @JvmStatic fun ofTypescriptCode(typescriptCode: TypescriptCodeParameters) = @@ -1042,6 +1101,10 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ): T + fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ): T + /** Parameters for defining a TypeScript code rule */ fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters): T @@ -1109,6 +1172,13 @@ private constructor( _json = json, ) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Parameters(conditionalAchPaymentUpdateAction = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Parameters(typescriptCode = it, _json = json) }, @@ -1161,6 +1231,8 @@ private constructor( generator.writeObject(value.conditionalTokenizationAction) value.conditionalCardTransactionUpdateAction != null -> generator.writeObject(value.conditionalCardTransactionUpdateAction) + value.conditionalAchPaymentUpdateAction != null -> + generator.writeObject(value.conditionalAchPaymentUpdateAction) value.typescriptCode != null -> generator.writeObject(value.typescriptCode) value.conditionalAuthorizationAdjustment != null -> generator.writeObject(value.conditionalAuthorizationAdjustment) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPage.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPage.kt index 80a97926..9a7639b7 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPage.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPage.kt @@ -65,6 +65,18 @@ private constructor( override fun visitAchResult( achResult: V2ListResultsResponse.AchResult ): Optional = achResult._token().getOptional("token") + + override fun visitCardTransactionUpdateResult( + cardTransactionUpdateResult: + V2ListResultsResponse.CardTransactionUpdateResult + ): Optional = + cardTransactionUpdateResult._token().getOptional("token") + + override fun visitAchPaymentUpdateResult( + achPaymentUpdateResult: + V2ListResultsResponse.AchPaymentUpdateResult + ): Optional = + achPaymentUpdateResult._token().getOptional("token") } ) ) @@ -96,6 +108,18 @@ private constructor( override fun visitAchResult( achResult: V2ListResultsResponse.AchResult ): Optional = achResult._token().getOptional("token") + + override fun visitCardTransactionUpdateResult( + cardTransactionUpdateResult: + V2ListResultsResponse.CardTransactionUpdateResult + ): Optional = + cardTransactionUpdateResult._token().getOptional("token") + + override fun visitAchPaymentUpdateResult( + achPaymentUpdateResult: + V2ListResultsResponse.AchPaymentUpdateResult + ): Optional = + achPaymentUpdateResult._token().getOptional("token") } ) ) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPageAsync.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPageAsync.kt index bf7822cf..fcc93c2a 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPageAsync.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPageAsync.kt @@ -68,6 +68,18 @@ private constructor( override fun visitAchResult( achResult: V2ListResultsResponse.AchResult ): Optional = achResult._token().getOptional("token") + + override fun visitCardTransactionUpdateResult( + cardTransactionUpdateResult: + V2ListResultsResponse.CardTransactionUpdateResult + ): Optional = + cardTransactionUpdateResult._token().getOptional("token") + + override fun visitAchPaymentUpdateResult( + achPaymentUpdateResult: + V2ListResultsResponse.AchPaymentUpdateResult + ): Optional = + achPaymentUpdateResult._token().getOptional("token") } ) ) @@ -99,6 +111,18 @@ private constructor( override fun visitAchResult( achResult: V2ListResultsResponse.AchResult ): Optional = achResult._token().getOptional("token") + + override fun visitCardTransactionUpdateResult( + cardTransactionUpdateResult: + V2ListResultsResponse.CardTransactionUpdateResult + ): Optional = + cardTransactionUpdateResult._token().getOptional("token") + + override fun visitAchPaymentUpdateResult( + achPaymentUpdateResult: + V2ListResultsResponse.AchPaymentUpdateResult + ): Optional = + achPaymentUpdateResult._token().getOptional("token") } ) ) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPageResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPageResponse.kt index 3a25d7ed..537d597e 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPageResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleV2ListResultsPageResponse.kt @@ -155,6 +155,24 @@ private constructor( fun addData(achResult: V2ListResultsResponse.AchResult) = addData(V2ListResultsResponse.ofAchResult(achResult)) + /** + * Alias for calling [addData] with + * `V2ListResultsResponse.ofCardTransactionUpdateResult(cardTransactionUpdateResult)`. + */ + fun addData( + cardTransactionUpdateResult: V2ListResultsResponse.CardTransactionUpdateResult + ) = + addData( + V2ListResultsResponse.ofCardTransactionUpdateResult(cardTransactionUpdateResult) + ) + + /** + * Alias for calling [addData] with + * `V2ListResultsResponse.ofAchPaymentUpdateResult(achPaymentUpdateResult)`. + */ + fun addData(achPaymentUpdateResult: V2ListResultsResponse.AchPaymentUpdateResult) = + addData(V2ListResultsResponse.ofAchPaymentUpdateResult(achPaymentUpdateResult)) + /** * Indicates whether there are more results to be retrieved by paging through the results. */ diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleVersion.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleVersion.kt index 85307dc6..5480e2d5 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleVersion.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRuleVersion.kt @@ -245,6 +245,17 @@ private constructor( ) ) + /** + * Alias for calling [parameters] with + * `Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction)`. + */ + fun parameters( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = + parameters( + Parameters.ofConditionalAchPaymentUpdateAction(conditionalAchPaymentUpdateAction) + ) + /** Alias for calling [parameters] with `Parameters.ofTypescriptCode(typescriptCode)`. */ fun parameters(typescriptCode: TypescriptCodeParameters) = parameters(Parameters.ofTypescriptCode(typescriptCode)) @@ -385,6 +396,9 @@ private constructor( private val conditionalCardTransactionUpdateAction: ConditionalCardTransactionUpdateActionParameters? = null, + private val conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters? = + null, private val typescriptCode: TypescriptCodeParameters? = null, private val conditionalAuthorizationAdjustment: ConditionalAuthorizationAdjustmentParameters? = @@ -418,6 +432,10 @@ private constructor( Optional = Optional.ofNullable(conditionalCardTransactionUpdateAction) + fun conditionalAchPaymentUpdateAction(): + Optional = + Optional.ofNullable(conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ fun typescriptCode(): Optional = Optional.ofNullable(typescriptCode) @@ -443,6 +461,9 @@ private constructor( fun isConditionalCardTransactionUpdateAction(): Boolean = conditionalCardTransactionUpdateAction != null + fun isConditionalAchPaymentUpdateAction(): Boolean = + conditionalAchPaymentUpdateAction != null + fun isTypescriptCode(): Boolean = typescriptCode != null fun isConditionalAuthorizationAdjustment(): Boolean = @@ -476,6 +497,9 @@ private constructor( "conditionalCardTransactionUpdateAction" ) + fun asConditionalAchPaymentUpdateAction(): ConditionalAchPaymentUpdateActionParameters = + conditionalAchPaymentUpdateAction.getOrThrow("conditionalAchPaymentUpdateAction") + /** Parameters for defining a TypeScript code rule */ fun asTypescriptCode(): TypescriptCodeParameters = typescriptCode.getOrThrow("typescriptCode") @@ -531,6 +555,10 @@ private constructor( visitor.visitConditionalCardTransactionUpdateAction( conditionalCardTransactionUpdateAction ) + conditionalAchPaymentUpdateAction != null -> + visitor.visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction + ) typescriptCode != null -> visitor.visitTypescriptCode(typescriptCode) conditionalAuthorizationAdjustment != null -> visitor.visitConditionalAuthorizationAdjustment( @@ -604,6 +632,13 @@ private constructor( conditionalCardTransactionUpdateAction.validate() } + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) { + conditionalAchPaymentUpdateAction.validate() + } + override fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters) { typescriptCode.validate() } @@ -669,6 +704,11 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ) = conditionalCardTransactionUpdateAction.validity() + override fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: + ConditionalAchPaymentUpdateActionParameters + ) = conditionalAchPaymentUpdateAction.validity() + override fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters) = typescriptCode.validity() @@ -696,6 +736,7 @@ private constructor( conditionalTokenizationAction == other.conditionalTokenizationAction && conditionalCardTransactionUpdateAction == other.conditionalCardTransactionUpdateAction && + conditionalAchPaymentUpdateAction == other.conditionalAchPaymentUpdateAction && typescriptCode == other.typescriptCode && conditionalAuthorizationAdjustment == other.conditionalAuthorizationAdjustment } @@ -710,6 +751,7 @@ private constructor( conditionalAchAction, conditionalTokenizationAction, conditionalCardTransactionUpdateAction, + conditionalAchPaymentUpdateAction, typescriptCode, conditionalAuthorizationAdjustment, ) @@ -730,6 +772,8 @@ private constructor( "Parameters{conditionalTokenizationAction=$conditionalTokenizationAction}" conditionalCardTransactionUpdateAction != null -> "Parameters{conditionalCardTransactionUpdateAction=$conditionalCardTransactionUpdateAction}" + conditionalAchPaymentUpdateAction != null -> + "Parameters{conditionalAchPaymentUpdateAction=$conditionalAchPaymentUpdateAction}" typescriptCode != null -> "Parameters{typescriptCode=$typescriptCode}" conditionalAuthorizationAdjustment != null -> "Parameters{conditionalAuthorizationAdjustment=$conditionalAuthorizationAdjustment}" @@ -780,6 +824,11 @@ private constructor( conditionalCardTransactionUpdateAction = conditionalCardTransactionUpdateAction ) + @JvmStatic + fun ofConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ) = Parameters(conditionalAchPaymentUpdateAction = conditionalAchPaymentUpdateAction) + /** Parameters for defining a TypeScript code rule */ @JvmStatic fun ofTypescriptCode(typescriptCode: TypescriptCodeParameters) = @@ -821,6 +870,10 @@ private constructor( ConditionalCardTransactionUpdateActionParameters ): T + fun visitConditionalAchPaymentUpdateAction( + conditionalAchPaymentUpdateAction: ConditionalAchPaymentUpdateActionParameters + ): T + /** Parameters for defining a TypeScript code rule */ fun visitTypescriptCode(typescriptCode: TypescriptCodeParameters): T @@ -888,6 +941,13 @@ private constructor( _json = json, ) }, + tryDeserialize( + node, + jacksonTypeRef(), + ) + ?.let { + Parameters(conditionalAchPaymentUpdateAction = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { Parameters(typescriptCode = it, _json = json) }, @@ -940,6 +1000,8 @@ private constructor( generator.writeObject(value.conditionalTokenizationAction) value.conditionalCardTransactionUpdateAction != null -> generator.writeObject(value.conditionalCardTransactionUpdateAction) + value.conditionalAchPaymentUpdateAction != null -> + generator.writeObject(value.conditionalAchPaymentUpdateAction) value.typescriptCode != null -> generator.writeObject(value.typescriptCode) value.conditionalAuthorizationAdjustment != null -> generator.writeObject(value.conditionalAuthorizationAdjustment) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAchPaymentUpdateActionParameters.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAchPaymentUpdateActionParameters.kt new file mode 100644 index 00000000..0a0a1941 --- /dev/null +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/ConditionalAchPaymentUpdateActionParameters.kt @@ -0,0 +1,792 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.annotation.JsonAnyGetter +import com.fasterxml.jackson.annotation.JsonAnySetter +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonProperty +import com.lithic.api.core.Enum +import com.lithic.api.core.ExcludeMissing +import com.lithic.api.core.JsonField +import com.lithic.api.core.JsonMissing +import com.lithic.api.core.JsonValue +import com.lithic.api.core.checkKnown +import com.lithic.api.core.checkRequired +import com.lithic.api.core.toImmutable +import com.lithic.api.errors.LithicInvalidDataException +import java.time.OffsetDateTime +import java.util.Collections +import java.util.Objects +import kotlin.jvm.optionals.getOrNull + +class ConditionalAchPaymentUpdateActionParameters +@JsonCreator(mode = JsonCreator.Mode.DISABLED) +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()) + + /** + * 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(): AchPaymentUpdateAction = action.getRequired("action") + + /** + * @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") + + /** + * 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 + + /** + * 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 + + @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 + * [ConditionalAchPaymentUpdateActionParameters]. + * + * The following fields are required: + * ```java + * .action() + * .conditions() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [ConditionalAchPaymentUpdateActionParameters]. */ + class Builder internal constructor() { + + private var action: JsonField? = null + private var conditions: JsonField>? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from( + conditionalAchPaymentUpdateActionParameters: ConditionalAchPaymentUpdateActionParameters + ) = apply { + action = conditionalAchPaymentUpdateActionParameters.action + conditions = + conditionalAchPaymentUpdateActionParameters.conditions.map { it.toMutableList() } + additionalProperties = + conditionalAchPaymentUpdateActionParameters.additionalProperties.toMutableMap() + } + + /** The action to take if the conditions are met. */ + fun action(action: AchPaymentUpdateAction) = action(JsonField.of(action)) + + /** + * Sets [Builder.action] to an arbitrary JSON value. + * + * You should usually call [Builder.action] with a well-typed [AchPaymentUpdateAction] 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 } + + /** Alias for calling [action] with `AchPaymentUpdateAction.ofTag(tag)`. */ + fun action(tag: AchPaymentUpdateAction.TagAction) = + action(AchPaymentUpdateAction.ofTag(tag)) + + /** Alias for calling [action] with `AchPaymentUpdateAction.ofCreateCase(createCase)`. */ + fun action(createCase: AchPaymentUpdateAction.CreateCaseAction) = + action(AchPaymentUpdateAction.ofCreateCase(createCase)) + + 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() } + } + + /** + * 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 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 [ConditionalAchPaymentUpdateActionParameters]. + * + * 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(): ConditionalAchPaymentUpdateActionParameters = + ConditionalAchPaymentUpdateActionParameters( + checkRequired("action", action), + checkRequired("conditions", conditions).map { it.toImmutable() }, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): ConditionalAchPaymentUpdateActionParameters = apply { + if (validated) { + return@apply + } + + action().validate() + conditions().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 = + (action.asKnown().getOrNull()?.validity() ?: 0) + + (conditions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + class Condition + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + 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: + * * `TRANSACTION_AMOUNT`: The total amount of the ACH payment in minor units (cents), + * calculated as the sum of the settled and pending amounts. Use an integer value. + * * `SEC_CODE`: Standard Entry Class code indicating the type of ACH transaction. Valid + * values include PPD (Prearranged Payment and Deposit Entry), CCD (Corporate Credit or + * Debit Entry), WEB (Internet-Initiated/Mobile Entry), TEL (Telephone-Initiated Entry), + * and others. + * * `RETURN_REASON_CODE`: NACHA return reason code associated with the payment (for + * example, `R01`). + * * `ACCOUNT_AGE`: The age of the account in seconds at the time of the payment. Use an + * integer value. For programs where Lithic does not manage or retain account holder data, + * this attribute does not evaluate. + * * `EXTERNAL_BANK_ACCOUNT_AGE`: The age of the external bank account in seconds at the + * time of the payment. Use an integer value. + * * `EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD`: The method used to verify the external + * bank account. Valid values are `MANUAL`, `MICRO_DEPOSIT`, `PRENOTE`, + * `EXTERNALLY_VERIFIED`, or `UNVERIFIED`. + * * `EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE`: The verification state of the external bank + * account. Valid values are `PENDING`, `ENABLED`, `FAILED_VERIFICATION`, or + * `INSUFFICIENT_FUNDS`. + * * `EXTERNAL_BANK_ACCOUNT_OWNER_TYPE`: The owner type of the external bank account. Valid + * values are `INDIVIDUAL` or `BUSINESS`. + * + * @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 attribute(): Attribute = attribute.getRequired("attribute") + + /** + * The operation to apply to the attribute + * + * @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 operation(): ConditionalOperation = operation.getRequired("operation") + + /** + * A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` + * + * @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 value(): ConditionalValue = value.getRequired("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]. + * + * The following fields are required: + * ```java + * .attribute() + * .operation() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [Condition]. */ + class Builder internal constructor() { + + private var attribute: JsonField? = null + private var operation: JsonField? = null + private var value: JsonField? = null + 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() + } + + /** + * The attribute to target. + * + * The following attributes may be targeted: + * * `TRANSACTION_AMOUNT`: The total amount of the ACH payment in minor units (cents), + * calculated as the sum of the settled and pending amounts. Use an integer value. + * * `SEC_CODE`: Standard Entry Class code indicating the type of ACH transaction. Valid + * values include PPD (Prearranged Payment and Deposit Entry), CCD (Corporate Credit + * or Debit Entry), WEB (Internet-Initiated/Mobile Entry), TEL (Telephone-Initiated + * Entry), and others. + * * `RETURN_REASON_CODE`: NACHA return reason code associated with the payment (for + * example, `R01`). + * * `ACCOUNT_AGE`: The age of the account in seconds at the time of the payment. Use an + * integer value. For programs where Lithic does not manage or retain account holder + * data, this attribute does not evaluate. + * * `EXTERNAL_BANK_ACCOUNT_AGE`: The age of the external bank account in seconds at the + * time of the payment. Use an integer value. + * * `EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD`: The method used to verify the external + * bank account. Valid values are `MANUAL`, `MICRO_DEPOSIT`, `PRENOTE`, + * `EXTERNALLY_VERIFIED`, or `UNVERIFIED`. + * * `EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE`: The verification state of the external + * bank account. Valid values are `PENDING`, `ENABLED`, `FAILED_VERIFICATION`, or + * `INSUFFICIENT_FUNDS`. + * * `EXTERNAL_BANK_ACCOUNT_OWNER_TYPE`: The owner type of the external bank account. + * Valid values are `INDIVIDUAL` or `BUSINESS`. + */ + 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 } + + /** The operation to apply to the attribute */ + fun operation(operation: ConditionalOperation) = operation(JsonField.of(operation)) + + /** + * Sets [Builder.operation] to an arbitrary JSON value. + * + * You should usually call [Builder.operation] with a well-typed [ConditionalOperation] + * 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 + } + + /** A regex string, to be used with `MATCHES` or `DOES_NOT_MATCH` */ + fun value(value: ConditionalValue) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [ConditionalValue] 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 `ConditionalValue.ofRegex(regex)`. */ + fun value(regex: String) = value(ConditionalValue.ofRegex(regex)) + + /** Alias for calling [value] with `ConditionalValue.ofInteger(integer)`. */ + fun value(integer: Long) = value(ConditionalValue.ofInteger(integer)) + + /** Alias for calling [value] with `ConditionalValue.ofNumber(number)`. */ + fun value(number: Double) = value(ConditionalValue.ofNumber(number)) + + /** Alias for calling [value] with `ConditionalValue.ofListOfStrings(listOfStrings)`. */ + fun valueOfListOfStrings(listOfStrings: List) = + value(ConditionalValue.ofListOfStrings(listOfStrings)) + + /** Alias for calling [value] with `ConditionalValue.ofTimestamp(timestamp)`. */ + fun value(timestamp: OffsetDateTime) = value(ConditionalValue.ofTimestamp(timestamp)) + + 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 [Condition]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .attribute() + * .operation() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): Condition = + Condition( + checkRequired("attribute", attribute), + checkRequired("operation", operation), + checkRequired("value", value), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Condition = apply { + if (validated) { + return@apply + } + + attribute().validate() + operation().validate() + value().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 = + (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: + * * `TRANSACTION_AMOUNT`: The total amount of the ACH payment in minor units (cents), + * calculated as the sum of the settled and pending amounts. Use an integer value. + * * `SEC_CODE`: Standard Entry Class code indicating the type of ACH transaction. Valid + * values include PPD (Prearranged Payment and Deposit Entry), CCD (Corporate Credit or + * Debit Entry), WEB (Internet-Initiated/Mobile Entry), TEL (Telephone-Initiated Entry), + * and others. + * * `RETURN_REASON_CODE`: NACHA return reason code associated with the payment (for + * example, `R01`). + * * `ACCOUNT_AGE`: The age of the account in seconds at the time of the payment. Use an + * integer value. For programs where Lithic does not manage or retain account holder data, + * this attribute does not evaluate. + * * `EXTERNAL_BANK_ACCOUNT_AGE`: The age of the external bank account in seconds at the + * time of the payment. Use an integer value. + * * `EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD`: The method used to verify the external + * bank account. Valid values are `MANUAL`, `MICRO_DEPOSIT`, `PRENOTE`, + * `EXTERNALLY_VERIFIED`, or `UNVERIFIED`. + * * `EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE`: The verification state of the external bank + * account. Valid values are `PENDING`, `ENABLED`, `FAILED_VERIFICATION`, or + * `INSUFFICIENT_FUNDS`. + * * `EXTERNAL_BANK_ACCOUNT_OWNER_TYPE`: The owner type of the external bank account. Valid + * values are `INDIVIDUAL` or `BUSINESS`. + */ + 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 TRANSACTION_AMOUNT = of("TRANSACTION_AMOUNT") + + @JvmField val SEC_CODE = of("SEC_CODE") + + @JvmField val RETURN_REASON_CODE = of("RETURN_REASON_CODE") + + @JvmField val ACCOUNT_AGE = of("ACCOUNT_AGE") + + @JvmField val EXTERNAL_BANK_ACCOUNT_AGE = of("EXTERNAL_BANK_ACCOUNT_AGE") + + @JvmField + val EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD = + of("EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD") + + @JvmField + val EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE = + of("EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE") + + @JvmField + val EXTERNAL_BANK_ACCOUNT_OWNER_TYPE = of("EXTERNAL_BANK_ACCOUNT_OWNER_TYPE") + + @JvmStatic fun of(value: String) = Attribute(JsonField.of(value)) + } + + /** An enum containing [Attribute]'s known values. */ + enum class Known { + TRANSACTION_AMOUNT, + SEC_CODE, + RETURN_REASON_CODE, + ACCOUNT_AGE, + EXTERNAL_BANK_ACCOUNT_AGE, + EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD, + EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE, + EXTERNAL_BANK_ACCOUNT_OWNER_TYPE, + } + + /** + * 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 { + TRANSACTION_AMOUNT, + SEC_CODE, + RETURN_REASON_CODE, + ACCOUNT_AGE, + EXTERNAL_BANK_ACCOUNT_AGE, + EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD, + EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE, + EXTERNAL_BANK_ACCOUNT_OWNER_TYPE, + /** + * An enum member indicating that [Attribute] 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) { + TRANSACTION_AMOUNT -> Value.TRANSACTION_AMOUNT + SEC_CODE -> Value.SEC_CODE + RETURN_REASON_CODE -> Value.RETURN_REASON_CODE + ACCOUNT_AGE -> Value.ACCOUNT_AGE + EXTERNAL_BANK_ACCOUNT_AGE -> Value.EXTERNAL_BANK_ACCOUNT_AGE + EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD -> + Value.EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD + EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE -> + Value.EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE + EXTERNAL_BANK_ACCOUNT_OWNER_TYPE -> Value.EXTERNAL_BANK_ACCOUNT_OWNER_TYPE + 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) { + TRANSACTION_AMOUNT -> Known.TRANSACTION_AMOUNT + SEC_CODE -> Known.SEC_CODE + RETURN_REASON_CODE -> Known.RETURN_REASON_CODE + ACCOUNT_AGE -> Known.ACCOUNT_AGE + EXTERNAL_BANK_ACCOUNT_AGE -> Known.EXTERNAL_BANK_ACCOUNT_AGE + EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD -> + Known.EXTERNAL_BANK_ACCOUNT_VERIFICATION_METHOD + EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE -> + Known.EXTERNAL_BANK_ACCOUNT_VERIFICATION_STATE + EXTERNAL_BANK_ACCOUNT_OWNER_TYPE -> Known.EXTERNAL_BANK_ACCOUNT_OWNER_TYPE + 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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Attribute = 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 other is Attribute && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Condition && + attribute == other.attribute && + operation == other.operation && + value == other.value && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(attribute, operation, value, additionalProperties) + } + + 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 other is ConditionalAchPaymentUpdateActionParameters && + action == other.action && + conditions == other.conditions && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(action, conditions, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "ConditionalAchPaymentUpdateActionParameters{action=$action, conditions=$conditions, additionalProperties=$additionalProperties}" +} diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventStream.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventStream.kt index 4bc8b893..48394fc4 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventStream.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/EventStream.kt @@ -33,6 +33,8 @@ class EventStream @JsonCreator private constructor(private val value: JsonField< @JvmField val CARD_TRANSACTION_UPDATE = of("CARD_TRANSACTION_UPDATE") + @JvmField val ACH_PAYMENT_UPDATE = of("ACH_PAYMENT_UPDATE") + @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) } @@ -44,6 +46,7 @@ class EventStream @JsonCreator private constructor(private val value: JsonField< ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, + ACH_PAYMENT_UPDATE, } /** @@ -62,6 +65,7 @@ class EventStream @JsonCreator private constructor(private val value: JsonField< ACH_CREDIT_RECEIPT, ACH_DEBIT_RECEIPT, CARD_TRANSACTION_UPDATE, + ACH_PAYMENT_UPDATE, /** An enum member indicating that [EventStream] was instantiated with an unknown value. */ _UNKNOWN, } @@ -81,6 +85,7 @@ class EventStream @JsonCreator private constructor(private val value: JsonField< ACH_CREDIT_RECEIPT -> Value.ACH_CREDIT_RECEIPT ACH_DEBIT_RECEIPT -> Value.ACH_DEBIT_RECEIPT CARD_TRANSACTION_UPDATE -> Value.CARD_TRANSACTION_UPDATE + ACH_PAYMENT_UPDATE -> Value.ACH_PAYMENT_UPDATE else -> Value._UNKNOWN } @@ -100,6 +105,7 @@ class EventStream @JsonCreator private constructor(private val value: JsonField< ACH_CREDIT_RECEIPT -> Known.ACH_CREDIT_RECEIPT ACH_DEBIT_RECEIPT -> Known.ACH_DEBIT_RECEIPT CARD_TRANSACTION_UPDATE -> Known.CARD_TRANSACTION_UPDATE + ACH_PAYMENT_UPDATE -> Known.ACH_PAYMENT_UPDATE else -> throw LithicInvalidDataException("Unknown EventStream: $value") } diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/RuleFeature.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/RuleFeature.kt index 50ab3e04..07671c01 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/RuleFeature.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/RuleFeature.kt @@ -43,10 +43,12 @@ import kotlin.jvm.optionals.getOrNull * ACH_DEBIT_RECEIPT event stream rules. * - `CARD_TRANSACTION`: The card transaction being evaluated. Only available for * CARD_TRANSACTION_UPDATE event stream rules. + * - `ACH_PAYMENT`: The ACH payment being evaluated. Only available for ACH_PAYMENT_UPDATE event + * stream rules. * - `CARD`: The card associated with the event. Available for AUTHORIZATION, * THREE_DS_AUTHENTICATION, and CARD_TRANSACTION_UPDATE event stream rules. - * - `ACCOUNT_HOLDER`: The account holder associated with the card. Available for AUTHORIZATION, - * THREE_DS_AUTHENTICATION, and CARD_TRANSACTION_UPDATE event stream rules. + * - `ACCOUNT_HOLDER`: The account holder associated with the event. Available for AUTHORIZATION, + * THREE_DS_AUTHENTICATION, CARD_TRANSACTION_UPDATE, and ACH_PAYMENT_UPDATE event stream rules. * - `IP_METADATA`: IP address metadata for the request. Available for THREE_DS_AUTHENTICATION event * stream rules. * - `SPEND_VELOCITY`: Spend velocity data for the card or account. Requires `scope`, `period`, and @@ -65,6 +67,7 @@ private constructor( private val tokenization: TokenizationFeature? = null, private val achReceipt: AchReceiptFeature? = null, private val cardTransaction: CardTransactionFeature? = null, + private val achPayment: AchPaymentFeature? = null, private val card: CardFeature? = null, private val accountHolder: AccountHolderFeature? = null, private val ipMetadata: IpMetadataFeature? = null, @@ -83,6 +86,8 @@ private constructor( fun cardTransaction(): Optional = Optional.ofNullable(cardTransaction) + fun achPayment(): Optional = Optional.ofNullable(achPayment) + fun card(): Optional = Optional.ofNullable(card) fun accountHolder(): Optional = Optional.ofNullable(accountHolder) @@ -104,6 +109,8 @@ private constructor( fun isCardTransaction(): Boolean = cardTransaction != null + fun isAchPayment(): Boolean = achPayment != null + fun isCard(): Boolean = card != null fun isAccountHolder(): Boolean = accountHolder != null @@ -124,6 +131,8 @@ private constructor( fun asCardTransaction(): CardTransactionFeature = cardTransaction.getOrThrow("cardTransaction") + fun asAchPayment(): AchPaymentFeature = achPayment.getOrThrow("achPayment") + fun asCard(): CardFeature = card.getOrThrow("card") fun asAccountHolder(): AccountHolderFeature = accountHolder.getOrThrow("accountHolder") @@ -173,6 +182,7 @@ private constructor( tokenization != null -> visitor.visitTokenization(tokenization) achReceipt != null -> visitor.visitAchReceipt(achReceipt) cardTransaction != null -> visitor.visitCardTransaction(cardTransaction) + achPayment != null -> visitor.visitAchPayment(achPayment) card != null -> visitor.visitCard(card) accountHolder != null -> visitor.visitAccountHolder(accountHolder) ipMetadata != null -> visitor.visitIpMetadata(ipMetadata) @@ -219,6 +229,10 @@ private constructor( cardTransaction.validate() } + override fun visitAchPayment(achPayment: AchPaymentFeature) { + achPayment.validate() + } + override fun visitCard(card: CardFeature) { card.validate() } @@ -276,6 +290,8 @@ private constructor( override fun visitCardTransaction(cardTransaction: CardTransactionFeature) = cardTransaction.validity() + override fun visitAchPayment(achPayment: AchPaymentFeature) = achPayment.validity() + override fun visitCard(card: CardFeature) = card.validity() override fun visitAccountHolder(accountHolder: AccountHolderFeature) = @@ -305,6 +321,7 @@ private constructor( tokenization == other.tokenization && achReceipt == other.achReceipt && cardTransaction == other.cardTransaction && + achPayment == other.achPayment && card == other.card && accountHolder == other.accountHolder && ipMetadata == other.ipMetadata && @@ -319,6 +336,7 @@ private constructor( tokenization, achReceipt, cardTransaction, + achPayment, card, accountHolder, ipMetadata, @@ -333,6 +351,7 @@ private constructor( tokenization != null -> "RuleFeature{tokenization=$tokenization}" achReceipt != null -> "RuleFeature{achReceipt=$achReceipt}" cardTransaction != null -> "RuleFeature{cardTransaction=$cardTransaction}" + achPayment != null -> "RuleFeature{achPayment=$achPayment}" card != null -> "RuleFeature{card=$card}" accountHolder != null -> "RuleFeature{accountHolder=$accountHolder}" ipMetadata != null -> "RuleFeature{ipMetadata=$ipMetadata}" @@ -364,6 +383,9 @@ private constructor( fun ofCardTransaction(cardTransaction: CardTransactionFeature) = RuleFeature(cardTransaction = cardTransaction) + @JvmStatic + fun ofAchPayment(achPayment: AchPaymentFeature) = RuleFeature(achPayment = achPayment) + @JvmStatic fun ofCard(card: CardFeature) = RuleFeature(card = card) @JvmStatic @@ -398,6 +420,8 @@ private constructor( fun visitCardTransaction(cardTransaction: CardTransactionFeature): T + fun visitAchPayment(achPayment: AchPaymentFeature): T + fun visitCard(card: CardFeature): T fun visitAccountHolder(accountHolder: AccountHolderFeature): T @@ -446,6 +470,9 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { RuleFeature(cardTransaction = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + RuleFeature(achPayment = it, _json = json) + }, tryDeserialize(node, jacksonTypeRef())?.let { RuleFeature(card = it, _json = json) }, @@ -489,6 +516,7 @@ private constructor( value.tokenization != null -> generator.writeObject(value.tokenization) value.achReceipt != null -> generator.writeObject(value.achReceipt) value.cardTransaction != null -> generator.writeObject(value.cardTransaction) + value.achPayment != null -> generator.writeObject(value.achPayment) value.card != null -> generator.writeObject(value.card) value.accountHolder != null -> generator.writeObject(value.accountHolder) value.ipMetadata != null -> generator.writeObject(value.ipMetadata) @@ -2161,6 +2189,338 @@ private constructor( "CardTransactionFeature{type=$type, name=$name, additionalProperties=$additionalProperties}" } + class AchPaymentFeature + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val type: JsonField, + private val name: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("name") @ExcludeMissing name: JsonField = JsonMissing.of(), + ) : this(type, name, mutableMapOf()) + + /** + * @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 type(): Type = type.getRequired("type") + + /** + * The variable name for this feature in the rule function signature + * + * @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") + + /** + * 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 + + /** + * 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 + + @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 [AchPaymentFeature]. + * + * The following fields are required: + * ```java + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AchPaymentFeature]. */ + class Builder internal constructor() { + + private var type: JsonField? = null + private var name: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(achPaymentFeature: AchPaymentFeature) = apply { + type = achPaymentFeature.type + name = achPaymentFeature.name + additionalProperties = achPaymentFeature.additionalProperties.toMutableMap() + } + + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] 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 } + + /** The variable name for this feature in the rule function signature */ + fun name(name: String) = name(JsonField.of(name)) + + /** + * 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 } + + 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 [AchPaymentFeature]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AchPaymentFeature = + AchPaymentFeature( + checkRequired("type", type), + name, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AchPaymentFeature = apply { + if (validated) { + return@apply + } + + type().validate() + name() + 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 = + (type.asKnown().getOrNull()?.validity() ?: 0) + (if (name.asKnown().isPresent) 1 else 0) + + class Type @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 ACH_PAYMENT = of("ACH_PAYMENT") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + ACH_PAYMENT + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + ACH_PAYMENT, + /** An enum member indicating that [Type] 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) { + ACH_PAYMENT -> Value.ACH_PAYMENT + 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) { + ACH_PAYMENT -> Known.ACH_PAYMENT + else -> throw LithicInvalidDataException("Unknown Type: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Type = 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AchPaymentFeature && + type == other.type && + name == other.name && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { Objects.hash(type, name, additionalProperties) } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AchPaymentFeature{type=$type, name=$name, additionalProperties=$additionalProperties}" + } + class CardFeature @JsonCreator(mode = JsonCreator.Mode.DISABLED) private constructor( diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TypescriptCodeParameters.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TypescriptCodeParameters.kt index e17313c8..55da6b55 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/TypescriptCodeParameters.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/TypescriptCodeParameters.kt @@ -170,6 +170,10 @@ private constructor( fun addFeature(cardTransaction: RuleFeature.CardTransactionFeature) = addFeature(RuleFeature.ofCardTransaction(cardTransaction)) + /** Alias for calling [addFeature] with `RuleFeature.ofAchPayment(achPayment)`. */ + fun addFeature(achPayment: RuleFeature.AchPaymentFeature) = + addFeature(RuleFeature.ofAchPayment(achPayment)) + /** Alias for calling [addFeature] with `RuleFeature.ofCard(card)`. */ fun addFeature(card: RuleFeature.CardFeature) = addFeature(RuleFeature.ofCard(card)) diff --git a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResultsResponse.kt b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResultsResponse.kt index 7667bf61..538d9d88 100644 --- a/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResultsResponse.kt +++ b/lithic-java-core/src/main/kotlin/com/lithic/api/models/V2ListResultsResponse.kt @@ -41,6 +41,8 @@ private constructor( private val authentication3dsResult: Authentication3dsResult? = null, private val tokenizationResult: TokenizationResult? = null, private val achResult: AchResult? = null, + private val cardTransactionUpdateResult: CardTransactionUpdateResult? = null, + private val achPaymentUpdateResult: AchPaymentUpdateResult? = null, private val _json: JsonValue? = null, ) { @@ -54,6 +56,12 @@ private constructor( fun achResult(): Optional = Optional.ofNullable(achResult) + fun cardTransactionUpdateResult(): Optional = + Optional.ofNullable(cardTransactionUpdateResult) + + fun achPaymentUpdateResult(): Optional = + Optional.ofNullable(achPaymentUpdateResult) + fun isAuthorizationResult(): Boolean = authorizationResult != null fun isAuthentication3dsResult(): Boolean = authentication3dsResult != null @@ -62,6 +70,10 @@ private constructor( fun isAchResult(): Boolean = achResult != null + fun isCardTransactionUpdateResult(): Boolean = cardTransactionUpdateResult != null + + fun isAchPaymentUpdateResult(): Boolean = achPaymentUpdateResult != null + fun asAuthorizationResult(): AuthorizationResult = authorizationResult.getOrThrow("authorizationResult") @@ -73,6 +85,12 @@ private constructor( fun asAchResult(): AchResult = achResult.getOrThrow("achResult") + fun asCardTransactionUpdateResult(): CardTransactionUpdateResult = + cardTransactionUpdateResult.getOrThrow("cardTransactionUpdateResult") + + fun asAchPaymentUpdateResult(): AchPaymentUpdateResult = + achPaymentUpdateResult.getOrThrow("achPaymentUpdateResult") + fun _json(): Optional = Optional.ofNullable(_json) /** @@ -111,6 +129,10 @@ private constructor( visitor.visitAuthentication3dsResult(authentication3dsResult) tokenizationResult != null -> visitor.visitTokenizationResult(tokenizationResult) achResult != null -> visitor.visitAchResult(achResult) + cardTransactionUpdateResult != null -> + visitor.visitCardTransactionUpdateResult(cardTransactionUpdateResult) + achPaymentUpdateResult != null -> + visitor.visitAchPaymentUpdateResult(achPaymentUpdateResult) else -> visitor.unknown(_json) } @@ -148,6 +170,18 @@ private constructor( override fun visitAchResult(achResult: AchResult) { achResult.validate() } + + override fun visitCardTransactionUpdateResult( + cardTransactionUpdateResult: CardTransactionUpdateResult + ) { + cardTransactionUpdateResult.validate() + } + + override fun visitAchPaymentUpdateResult( + achPaymentUpdateResult: AchPaymentUpdateResult + ) { + achPaymentUpdateResult.validate() + } } ) validated = true @@ -182,6 +216,14 @@ private constructor( override fun visitAchResult(achResult: AchResult) = achResult.validity() + override fun visitCardTransactionUpdateResult( + cardTransactionUpdateResult: CardTransactionUpdateResult + ) = cardTransactionUpdateResult.validity() + + override fun visitAchPaymentUpdateResult( + achPaymentUpdateResult: AchPaymentUpdateResult + ) = achPaymentUpdateResult.validity() + override fun unknown(json: JsonValue?) = 0 } ) @@ -195,11 +237,20 @@ private constructor( authorizationResult == other.authorizationResult && authentication3dsResult == other.authentication3dsResult && tokenizationResult == other.tokenizationResult && - achResult == other.achResult + achResult == other.achResult && + cardTransactionUpdateResult == other.cardTransactionUpdateResult && + achPaymentUpdateResult == other.achPaymentUpdateResult } override fun hashCode(): Int = - Objects.hash(authorizationResult, authentication3dsResult, tokenizationResult, achResult) + Objects.hash( + authorizationResult, + authentication3dsResult, + tokenizationResult, + achResult, + cardTransactionUpdateResult, + achPaymentUpdateResult, + ) override fun toString(): String = when { @@ -210,6 +261,10 @@ private constructor( tokenizationResult != null -> "V2ListResultsResponse{tokenizationResult=$tokenizationResult}" achResult != null -> "V2ListResultsResponse{achResult=$achResult}" + cardTransactionUpdateResult != null -> + "V2ListResultsResponse{cardTransactionUpdateResult=$cardTransactionUpdateResult}" + achPaymentUpdateResult != null -> + "V2ListResultsResponse{achPaymentUpdateResult=$achPaymentUpdateResult}" _json != null -> "V2ListResultsResponse{_unknown=$_json}" else -> throw IllegalStateException("Invalid V2ListResultsResponse") } @@ -230,6 +285,15 @@ private constructor( @JvmStatic fun ofAchResult(achResult: AchResult) = V2ListResultsResponse(achResult = achResult) + + @JvmStatic + fun ofCardTransactionUpdateResult( + cardTransactionUpdateResult: CardTransactionUpdateResult + ) = V2ListResultsResponse(cardTransactionUpdateResult = cardTransactionUpdateResult) + + @JvmStatic + fun ofAchPaymentUpdateResult(achPaymentUpdateResult: AchPaymentUpdateResult) = + V2ListResultsResponse(achPaymentUpdateResult = achPaymentUpdateResult) } /** @@ -246,6 +310,12 @@ private constructor( fun visitAchResult(achResult: AchResult): T + fun visitCardTransactionUpdateResult( + cardTransactionUpdateResult: CardTransactionUpdateResult + ): T + + fun visitAchPaymentUpdateResult(achPaymentUpdateResult: AchPaymentUpdateResult): T + /** * Maps an unknown variant of [V2ListResultsResponse] to a value of type [T]. * @@ -281,6 +351,12 @@ private constructor( tryDeserialize(node, jacksonTypeRef())?.let { V2ListResultsResponse(achResult = it, _json = json) }, + tryDeserialize(node, jacksonTypeRef())?.let { + V2ListResultsResponse(cardTransactionUpdateResult = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + V2ListResultsResponse(achPaymentUpdateResult = it, _json = json) + }, ) .filterNotNull() .allMaxBy { it.validity() } @@ -312,6 +388,10 @@ private constructor( generator.writeObject(value.authentication3dsResult) value.tokenizationResult != null -> generator.writeObject(value.tokenizationResult) value.achResult != null -> generator.writeObject(value.achResult) + value.cardTransactionUpdateResult != null -> + generator.writeObject(value.cardTransactionUpdateResult) + value.achPaymentUpdateResult != null -> + generator.writeObject(value.achPaymentUpdateResult) value._json != null -> generator.writeObject(value._json) else -> throw IllegalStateException("Invalid V2ListResultsResponse") } @@ -8554,4 +8634,4148 @@ private constructor( override fun toString() = "AchResult{token=$token, actions=$actions, authRuleToken=$authRuleToken, evaluationTime=$evaluationTime, eventStream=$eventStream, eventToken=$eventToken, mode=$mode, ruleVersion=$ruleVersion, transactionToken=$transactionToken, additionalProperties=$additionalProperties}" } + + class CardTransactionUpdateResult + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val actions: JsonField>, + private val authRuleToken: JsonField, + private val evaluationTime: JsonField, + private val eventStream: JsonField, + private val eventToken: JsonField, + private val mode: JsonField, + private val ruleVersion: JsonField, + private val transactionToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("actions") + @ExcludeMissing + actions: JsonField> = JsonMissing.of(), + @JsonProperty("auth_rule_token") + @ExcludeMissing + authRuleToken: JsonField = JsonMissing.of(), + @JsonProperty("evaluation_time") + @ExcludeMissing + evaluationTime: JsonField = JsonMissing.of(), + @JsonProperty("event_stream") + @ExcludeMissing + eventStream: JsonField = JsonMissing.of(), + @JsonProperty("event_token") + @ExcludeMissing + eventToken: JsonField = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + @JsonProperty("rule_version") + @ExcludeMissing + ruleVersion: JsonField = JsonMissing.of(), + @JsonProperty("transaction_token") + @ExcludeMissing + transactionToken: JsonField = JsonMissing.of(), + ) : this( + token, + actions, + authRuleToken, + evaluationTime, + eventStream, + eventToken, + mode, + ruleVersion, + transactionToken, + mutableMapOf(), + ) + + /** + * Globally unique identifier for the evaluation + * + * @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 token(): String = token.getRequired("token") + + /** + * Actions returned by the rule evaluation + * + * @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 actions(): List = actions.getRequired("actions") + + /** + * The Auth Rule token + * + * @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 authRuleToken(): String = authRuleToken.getRequired("auth_rule_token") + + /** + * Timestamp of the rule evaluation + * + * @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 evaluationTime(): OffsetDateTime = evaluationTime.getRequired("evaluation_time") + + /** + * The event stream during which the rule was evaluated + * + * @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 eventStream(): EventStream = eventStream.getRequired("event_stream") + + /** + * Token of the event that triggered the evaluation + * + * @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 eventToken(): String = eventToken.getRequired("event_token") + + /** + * The state of the Auth Rule + * + * @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 mode(): AuthRuleState = mode.getRequired("mode") + + /** + * Version of the rule that was evaluated + * + * @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 ruleVersion(): Long = ruleVersion.getRequired("rule_version") + + /** + * The token of the transaction that triggered the rule evaluation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionToken(): Optional = transactionToken.getOptional("transaction_token") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [actions]. + * + * Unlike [actions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("actions") @ExcludeMissing fun _actions(): JsonField> = actions + + /** + * Returns the raw JSON value of [authRuleToken]. + * + * Unlike [authRuleToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auth_rule_token") + @ExcludeMissing + fun _authRuleToken(): JsonField = authRuleToken + + /** + * Returns the raw JSON value of [evaluationTime]. + * + * Unlike [evaluationTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluation_time") + @ExcludeMissing + fun _evaluationTime(): JsonField = evaluationTime + + /** + * Returns the raw JSON value of [eventStream]. + * + * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_stream") + @ExcludeMissing + fun _eventStream(): JsonField = eventStream + + /** + * Returns the raw JSON value of [eventToken]. + * + * Unlike [eventToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_token") + @ExcludeMissing + fun _eventToken(): JsonField = eventToken + + /** + * Returns the raw JSON value of [mode]. + * + * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + + /** + * Returns the raw JSON value of [ruleVersion]. + * + * Unlike [ruleVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_version") + @ExcludeMissing + fun _ruleVersion(): JsonField = ruleVersion + + /** + * Returns the raw JSON value of [transactionToken]. + * + * Unlike [transactionToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken + + @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 + * [CardTransactionUpdateResult]. + * + * The following fields are required: + * ```java + * .token() + * .actions() + * .authRuleToken() + * .evaluationTime() + * .eventStream() + * .eventToken() + * .mode() + * .ruleVersion() + * .transactionToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CardTransactionUpdateResult]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var actions: JsonField>? = null + private var authRuleToken: JsonField? = null + private var evaluationTime: JsonField? = null + private var eventStream: JsonField? = null + private var eventToken: JsonField? = null + private var mode: JsonField? = null + private var ruleVersion: JsonField? = null + private var transactionToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(cardTransactionUpdateResult: CardTransactionUpdateResult) = apply { + token = cardTransactionUpdateResult.token + actions = cardTransactionUpdateResult.actions.map { it.toMutableList() } + authRuleToken = cardTransactionUpdateResult.authRuleToken + evaluationTime = cardTransactionUpdateResult.evaluationTime + eventStream = cardTransactionUpdateResult.eventStream + eventToken = cardTransactionUpdateResult.eventToken + mode = cardTransactionUpdateResult.mode + ruleVersion = cardTransactionUpdateResult.ruleVersion + transactionToken = cardTransactionUpdateResult.transactionToken + additionalProperties = + cardTransactionUpdateResult.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the evaluation */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Actions returned by the rule evaluation */ + fun actions(actions: List) = actions(JsonField.of(actions)) + + /** + * Sets [Builder.actions] to an arbitrary JSON value. + * + * You should usually call [Builder.actions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun actions(actions: JsonField>) = apply { + this.actions = actions.map { it.toMutableList() } + } + + /** + * Adds a single [Action] to [actions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAction(action: Action) = apply { + actions = + (actions ?: JsonField.of(mutableListOf())).also { + checkKnown("actions", it).add(action) + } + } + + /** Alias for calling [addAction] with `Action.ofTag(tag)`. */ + fun addAction(tag: Action.TagAction) = addAction(Action.ofTag(tag)) + + /** Alias for calling [addAction] with `Action.ofCreateCase(createCase)`. */ + fun addAction(createCase: Action.CreateCaseAction) = + addAction(Action.ofCreateCase(createCase)) + + /** The Auth Rule token */ + fun authRuleToken(authRuleToken: String) = authRuleToken(JsonField.of(authRuleToken)) + + /** + * Sets [Builder.authRuleToken] to an arbitrary JSON value. + * + * You should usually call [Builder.authRuleToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authRuleToken(authRuleToken: JsonField) = apply { + this.authRuleToken = authRuleToken + } + + /** Timestamp of the rule evaluation */ + fun evaluationTime(evaluationTime: OffsetDateTime) = + evaluationTime(JsonField.of(evaluationTime)) + + /** + * Sets [Builder.evaluationTime] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluationTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun evaluationTime(evaluationTime: JsonField) = apply { + this.evaluationTime = evaluationTime + } + + /** The event stream during which the rule was evaluated */ + fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) + + /** + * Sets [Builder.eventStream] to an arbitrary JSON value. + * + * You should usually call [Builder.eventStream] with a well-typed [EventStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventStream(eventStream: JsonField) = apply { + this.eventStream = eventStream + } + + /** Token of the event that triggered the evaluation */ + fun eventToken(eventToken: String) = eventToken(JsonField.of(eventToken)) + + /** + * Sets [Builder.eventToken] to an arbitrary JSON value. + * + * You should usually call [Builder.eventToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventToken(eventToken: JsonField) = apply { this.eventToken = eventToken } + + /** The state of the Auth Rule */ + fun mode(mode: AuthRuleState) = mode(JsonField.of(mode)) + + /** + * Sets [Builder.mode] to an arbitrary JSON value. + * + * You should usually call [Builder.mode] with a well-typed [AuthRuleState] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mode(mode: JsonField) = apply { this.mode = mode } + + /** Version of the rule that was evaluated */ + fun ruleVersion(ruleVersion: Long) = ruleVersion(JsonField.of(ruleVersion)) + + /** + * Sets [Builder.ruleVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleVersion] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ruleVersion(ruleVersion: JsonField) = apply { this.ruleVersion = ruleVersion } + + /** The token of the transaction that triggered the rule evaluation */ + fun transactionToken(transactionToken: String?) = + transactionToken(JsonField.ofNullable(transactionToken)) + + /** + * Alias for calling [Builder.transactionToken] with `transactionToken.orElse(null)`. + */ + fun transactionToken(transactionToken: Optional) = + transactionToken(transactionToken.getOrNull()) + + /** + * Sets [Builder.transactionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transactionToken(transactionToken: JsonField) = apply { + this.transactionToken = transactionToken + } + + 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 [CardTransactionUpdateResult]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .actions() + * .authRuleToken() + * .evaluationTime() + * .eventStream() + * .eventToken() + * .mode() + * .ruleVersion() + * .transactionToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CardTransactionUpdateResult = + CardTransactionUpdateResult( + checkRequired("token", token), + checkRequired("actions", actions).map { it.toImmutable() }, + checkRequired("authRuleToken", authRuleToken), + checkRequired("evaluationTime", evaluationTime), + checkRequired("eventStream", eventStream), + checkRequired("eventToken", eventToken), + checkRequired("mode", mode), + checkRequired("ruleVersion", ruleVersion), + checkRequired("transactionToken", transactionToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): CardTransactionUpdateResult = apply { + if (validated) { + return@apply + } + + token() + actions().forEach { it.validate() } + authRuleToken() + evaluationTime() + eventStream().validate() + eventToken() + mode().validate() + ruleVersion() + transactionToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (actions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (authRuleToken.asKnown().isPresent) 1 else 0) + + (if (evaluationTime.asKnown().isPresent) 1 else 0) + + (eventStream.asKnown().getOrNull()?.validity() ?: 0) + + (if (eventToken.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + + (if (ruleVersion.asKnown().isPresent) 1 else 0) + + (if (transactionToken.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Action.Deserializer::class) + @JsonSerialize(using = Action.Serializer::class) + class Action + private constructor( + private val tag: TagAction? = null, + private val createCase: CreateCaseAction? = null, + private val _json: JsonValue? = null, + ) { + + fun tag(): Optional = Optional.ofNullable(tag) + + fun createCase(): Optional = Optional.ofNullable(createCase) + + fun isTag(): Boolean = tag != null + + fun isCreateCase(): Boolean = createCase != null + + fun asTag(): TagAction = tag.getOrThrow("tag") + + fun asCreateCase(): CreateCaseAction = createCase.getOrThrow("createCase") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.lithic.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = action.accept(new Action.Visitor>() { + * @Override + * public Optional visitTag(TagAction tag) { + * return Optional.of(tag.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws LithicInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + tag != null -> visitor.visitTag(tag) + createCase != null -> visitor.visitCreateCase(createCase) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Action = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTag(tag: TagAction) { + tag.validate() + } + + override fun visitCreateCase(createCase: CreateCaseAction) { + createCase.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 visitTag(tag: TagAction) = tag.validity() + + override fun visitCreateCase(createCase: CreateCaseAction) = + createCase.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && tag == other.tag && createCase == other.createCase + } + + override fun hashCode(): Int = Objects.hash(tag, createCase) + + override fun toString(): String = + when { + tag != null -> "Action{tag=$tag}" + createCase != null -> "Action{createCase=$createCase}" + _json != null -> "Action{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Action") + } + + companion object { + + @JvmStatic fun ofTag(tag: TagAction) = Action(tag = tag) + + @JvmStatic + fun ofCreateCase(createCase: CreateCaseAction) = Action(createCase = createCase) + } + + /** + * An interface that defines how to map each variant of [Action] to a value of type [T]. + */ + interface Visitor { + + fun visitTag(tag: TagAction): T + + fun visitCreateCase(createCase: CreateCaseAction): T + + /** + * Maps an unknown variant of [Action] to a value of type [T]. + * + * An instance of [Action] 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 Action: $json") + } + } + + internal class Deserializer : BaseDeserializer(Action::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Action { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Action(tag = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Action(createCase = 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 -> Action(_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(Action::class) { + + override fun serialize( + value: Action, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.tag != null -> generator.writeObject(value.tag) + value.createCase != null -> generator.writeObject(value.createCase) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Action") + } + } + } + + class TagAction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val key: JsonField, + private val type: JsonField, + private val value: JsonField, + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + ) : this(key, type, value, explanation, mutableMapOf()) + + /** + * The key of the tag to apply to the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun key(): String = key.getRequired("key") + + /** + * Tag the transaction with key-value metadata + * + * @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 type(): Type = type.getRequired("type") + + /** + * The value of the tag to apply to the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun value(): String = value.getRequired("value") + + /** + * Optional explanation for why this action was taken + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * 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 + + /** + * 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 + + /** + * Returns the raw JSON value of [explanation]. + * + * Unlike [explanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("explanation") + @ExcludeMissing + fun _explanation(): JsonField = explanation + + @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 [TagAction]. + * + * The following fields are required: + * ```java + * .key() + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagAction]. */ + class Builder internal constructor() { + + private var key: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null + private var explanation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tagAction: TagAction) = apply { + key = tagAction.key + type = tagAction.type + value = tagAction.value + explanation = tagAction.explanation + additionalProperties = tagAction.additionalProperties.toMutableMap() + } + + /** The key of the tag to apply to the transaction */ + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + /** Tag the transaction with key-value metadata */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] 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 } + + /** The value of the tag to apply to the transaction */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] 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 } + + /** Optional explanation for why this action was taken */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * Sets [Builder.explanation] to an arbitrary JSON value. + * + * You should usually call [Builder.explanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun explanation(explanation: JsonField) = apply { + this.explanation = explanation + } + + 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 [TagAction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagAction = + TagAction( + checkRequired("key", key), + checkRequired("type", type), + checkRequired("value", value), + explanation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TagAction = apply { + if (validated) { + return@apply + } + + key() + type().validate() + value() + explanation() + 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 (key.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + (if (explanation.asKnown().isPresent) 1 else 0) + + /** Tag the transaction with key-value metadata */ + class Type @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 TAG = of("TAG") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TAG + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + TAG, + /** + * An enum member indicating that [Type] 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) { + TAG -> Value.TAG + 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) { + TAG -> Known.TAG + else -> throw LithicInvalidDataException("Unknown Type: $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 + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Type = 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagAction && + key == other.key && + type == other.type && + value == other.value && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(key, type, value, explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TagAction{key=$key, type=$type, value=$value, explanation=$explanation, additionalProperties=$additionalProperties}" + } + + class CreateCaseAction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val queueToken: JsonField, + private val scope: JsonField, + private val type: JsonField, + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("queue_token") + @ExcludeMissing + queueToken: JsonField = JsonMissing.of(), + @JsonProperty("scope") + @ExcludeMissing + scope: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + ) : this(queueToken, scope, type, explanation, mutableMapOf()) + + /** + * The token of the queue to create the case in + * + * @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 queueToken(): String = queueToken.getRequired("queue_token") + + /** + * The scope of the case to create + * + * @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 scope(): Scope = scope.getRequired("scope") + + /** + * Create a case for the transaction + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type or is + * unexpectedly missing or null (e.g. if the server responded with an unexpected + * value). + */ + fun type(): Type = type.getRequired("type") + + /** + * Optional explanation for why this action was taken + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * Returns the raw JSON value of [queueToken]. + * + * Unlike [queueToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("queue_token") + @ExcludeMissing + fun _queueToken(): JsonField = queueToken + + /** + * Returns the raw JSON value of [scope]. + * + * Unlike [scope], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope + + /** + * 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 + + /** + * Returns the raw JSON value of [explanation]. + * + * Unlike [explanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("explanation") + @ExcludeMissing + fun _explanation(): JsonField = explanation + + @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 [CreateCaseAction]. + * + * The following fields are required: + * ```java + * .queueToken() + * .scope() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateCaseAction]. */ + class Builder internal constructor() { + + private var queueToken: JsonField? = null + private var scope: JsonField? = null + private var type: JsonField? = null + private var explanation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createCaseAction: CreateCaseAction) = apply { + queueToken = createCaseAction.queueToken + scope = createCaseAction.scope + type = createCaseAction.type + explanation = createCaseAction.explanation + additionalProperties = createCaseAction.additionalProperties.toMutableMap() + } + + /** The token of the queue to create the case in */ + fun queueToken(queueToken: String) = queueToken(JsonField.of(queueToken)) + + /** + * Sets [Builder.queueToken] to an arbitrary JSON value. + * + * You should usually call [Builder.queueToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun queueToken(queueToken: JsonField) = apply { + this.queueToken = queueToken + } + + /** The scope of the case to create */ + fun scope(scope: Scope) = scope(JsonField.of(scope)) + + /** + * Sets [Builder.scope] to an arbitrary JSON value. + * + * You should usually call [Builder.scope] with a well-typed [Scope] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun scope(scope: JsonField) = apply { this.scope = scope } + + /** Create a case for the transaction */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] 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 } + + /** Optional explanation for why this action was taken */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * Sets [Builder.explanation] to an arbitrary JSON value. + * + * You should usually call [Builder.explanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun explanation(explanation: JsonField) = apply { + this.explanation = explanation + } + + 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 [CreateCaseAction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueToken() + * .scope() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreateCaseAction = + CreateCaseAction( + checkRequired("queueToken", queueToken), + checkRequired("scope", scope), + checkRequired("type", type), + explanation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CreateCaseAction = apply { + if (validated) { + return@apply + } + + queueToken() + scope().validate() + type().validate() + explanation() + 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 (queueToken.asKnown().isPresent) 1 else 0) + + (scope.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (explanation.asKnown().isPresent) 1 else 0) + + /** The scope of the case to create */ + class Scope @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 CARD = of("CARD") + + @JvmField val ACCOUNT = of("ACCOUNT") + + @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) + } + + /** An enum containing [Scope]'s known values. */ + enum class Known { + CARD, + ACCOUNT, + } + + /** + * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Scope] 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 { + CARD, + ACCOUNT, + /** + * An enum member indicating that [Scope] 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) { + CARD -> Value.CARD + ACCOUNT -> Value.ACCOUNT + 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) { + CARD -> Known.CARD + ACCOUNT -> Known.ACCOUNT + else -> throw LithicInvalidDataException("Unknown Scope: $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 + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Scope = 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 other is Scope && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Create a case for the transaction */ + class Type @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 CREATE_CASE = of("CREATE_CASE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CREATE_CASE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + CREATE_CASE, + /** + * An enum member indicating that [Type] 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) { + CREATE_CASE -> Value.CREATE_CASE + 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) { + CREATE_CASE -> Known.CREATE_CASE + else -> throw LithicInvalidDataException("Unknown Type: $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 + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Type = 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateCaseAction && + queueToken == other.queueToken && + scope == other.scope && + type == other.type && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(queueToken, scope, type, explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateCaseAction{queueToken=$queueToken, scope=$scope, type=$type, explanation=$explanation, additionalProperties=$additionalProperties}" + } + } + + /** The event stream during which the rule was evaluated */ + class EventStream @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 CARD_TRANSACTION_UPDATE = of("CARD_TRANSACTION_UPDATE") + + @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) + } + + /** An enum containing [EventStream]'s known values. */ + enum class Known { + CARD_TRANSACTION_UPDATE + } + + /** + * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventStream] 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 { + CARD_TRANSACTION_UPDATE, + /** + * An enum member indicating that [EventStream] 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) { + CARD_TRANSACTION_UPDATE -> Value.CARD_TRANSACTION_UPDATE + 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) { + CARD_TRANSACTION_UPDATE -> Known.CARD_TRANSACTION_UPDATE + else -> throw LithicInvalidDataException("Unknown EventStream: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): EventStream = 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 other is EventStream && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The state of the Auth Rule */ + class AuthRuleState @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 ACTIVE = of("ACTIVE") + + @JvmField val INACTIVE = of("INACTIVE") + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + /** An enum containing [AuthRuleState]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthRuleState] 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 { + ACTIVE, + INACTIVE, + /** + * An enum member indicating that [AuthRuleState] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AuthRuleState = 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 other is AuthRuleState && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CardTransactionUpdateResult && + token == other.token && + actions == other.actions && + authRuleToken == other.authRuleToken && + evaluationTime == other.evaluationTime && + eventStream == other.eventStream && + eventToken == other.eventToken && + mode == other.mode && + ruleVersion == other.ruleVersion && + transactionToken == other.transactionToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + actions, + authRuleToken, + evaluationTime, + eventStream, + eventToken, + mode, + ruleVersion, + transactionToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CardTransactionUpdateResult{token=$token, actions=$actions, authRuleToken=$authRuleToken, evaluationTime=$evaluationTime, eventStream=$eventStream, eventToken=$eventToken, mode=$mode, ruleVersion=$ruleVersion, transactionToken=$transactionToken, additionalProperties=$additionalProperties}" + } + + class AchPaymentUpdateResult + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val token: JsonField, + private val actions: JsonField>, + private val authRuleToken: JsonField, + private val evaluationTime: JsonField, + private val eventStream: JsonField, + private val eventToken: JsonField, + private val mode: JsonField, + private val ruleVersion: JsonField, + private val transactionToken: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("token") @ExcludeMissing token: JsonField = JsonMissing.of(), + @JsonProperty("actions") + @ExcludeMissing + actions: JsonField> = JsonMissing.of(), + @JsonProperty("auth_rule_token") + @ExcludeMissing + authRuleToken: JsonField = JsonMissing.of(), + @JsonProperty("evaluation_time") + @ExcludeMissing + evaluationTime: JsonField = JsonMissing.of(), + @JsonProperty("event_stream") + @ExcludeMissing + eventStream: JsonField = JsonMissing.of(), + @JsonProperty("event_token") + @ExcludeMissing + eventToken: JsonField = JsonMissing.of(), + @JsonProperty("mode") @ExcludeMissing mode: JsonField = JsonMissing.of(), + @JsonProperty("rule_version") + @ExcludeMissing + ruleVersion: JsonField = JsonMissing.of(), + @JsonProperty("transaction_token") + @ExcludeMissing + transactionToken: JsonField = JsonMissing.of(), + ) : this( + token, + actions, + authRuleToken, + evaluationTime, + eventStream, + eventToken, + mode, + ruleVersion, + transactionToken, + mutableMapOf(), + ) + + /** + * Globally unique identifier for the evaluation + * + * @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 token(): String = token.getRequired("token") + + /** + * Actions returned by the rule evaluation + * + * @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 actions(): List = actions.getRequired("actions") + + /** + * The Auth Rule token + * + * @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 authRuleToken(): String = authRuleToken.getRequired("auth_rule_token") + + /** + * Timestamp of the rule evaluation + * + * @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 evaluationTime(): OffsetDateTime = evaluationTime.getRequired("evaluation_time") + + /** + * The event stream during which the rule was evaluated + * + * @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 eventStream(): EventStream = eventStream.getRequired("event_stream") + + /** + * Token of the event that triggered the evaluation + * + * @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 eventToken(): String = eventToken.getRequired("event_token") + + /** + * The state of the Auth Rule + * + * @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 mode(): AuthRuleState = mode.getRequired("mode") + + /** + * Version of the rule that was evaluated + * + * @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 ruleVersion(): Long = ruleVersion.getRequired("rule_version") + + /** + * The token of the transaction that triggered the rule evaluation + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. if the + * server responded with an unexpected value). + */ + fun transactionToken(): Optional = transactionToken.getOptional("transaction_token") + + /** + * Returns the raw JSON value of [token]. + * + * Unlike [token], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("token") @ExcludeMissing fun _token(): JsonField = token + + /** + * Returns the raw JSON value of [actions]. + * + * Unlike [actions], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("actions") @ExcludeMissing fun _actions(): JsonField> = actions + + /** + * Returns the raw JSON value of [authRuleToken]. + * + * Unlike [authRuleToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("auth_rule_token") + @ExcludeMissing + fun _authRuleToken(): JsonField = authRuleToken + + /** + * Returns the raw JSON value of [evaluationTime]. + * + * Unlike [evaluationTime], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("evaluation_time") + @ExcludeMissing + fun _evaluationTime(): JsonField = evaluationTime + + /** + * Returns the raw JSON value of [eventStream]. + * + * Unlike [eventStream], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_stream") + @ExcludeMissing + fun _eventStream(): JsonField = eventStream + + /** + * Returns the raw JSON value of [eventToken]. + * + * Unlike [eventToken], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("event_token") + @ExcludeMissing + fun _eventToken(): JsonField = eventToken + + /** + * Returns the raw JSON value of [mode]. + * + * Unlike [mode], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("mode") @ExcludeMissing fun _mode(): JsonField = mode + + /** + * Returns the raw JSON value of [ruleVersion]. + * + * Unlike [ruleVersion], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("rule_version") + @ExcludeMissing + fun _ruleVersion(): JsonField = ruleVersion + + /** + * Returns the raw JSON value of [transactionToken]. + * + * Unlike [transactionToken], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("transaction_token") + @ExcludeMissing + fun _transactionToken(): JsonField = transactionToken + + @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 [AchPaymentUpdateResult]. + * + * The following fields are required: + * ```java + * .token() + * .actions() + * .authRuleToken() + * .evaluationTime() + * .eventStream() + * .eventToken() + * .mode() + * .ruleVersion() + * .transactionToken() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [AchPaymentUpdateResult]. */ + class Builder internal constructor() { + + private var token: JsonField? = null + private var actions: JsonField>? = null + private var authRuleToken: JsonField? = null + private var evaluationTime: JsonField? = null + private var eventStream: JsonField? = null + private var eventToken: JsonField? = null + private var mode: JsonField? = null + private var ruleVersion: JsonField? = null + private var transactionToken: JsonField? = null + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(achPaymentUpdateResult: AchPaymentUpdateResult) = apply { + token = achPaymentUpdateResult.token + actions = achPaymentUpdateResult.actions.map { it.toMutableList() } + authRuleToken = achPaymentUpdateResult.authRuleToken + evaluationTime = achPaymentUpdateResult.evaluationTime + eventStream = achPaymentUpdateResult.eventStream + eventToken = achPaymentUpdateResult.eventToken + mode = achPaymentUpdateResult.mode + ruleVersion = achPaymentUpdateResult.ruleVersion + transactionToken = achPaymentUpdateResult.transactionToken + additionalProperties = achPaymentUpdateResult.additionalProperties.toMutableMap() + } + + /** Globally unique identifier for the evaluation */ + fun token(token: String) = token(JsonField.of(token)) + + /** + * Sets [Builder.token] to an arbitrary JSON value. + * + * You should usually call [Builder.token] with a well-typed [String] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun token(token: JsonField) = apply { this.token = token } + + /** Actions returned by the rule evaluation */ + fun actions(actions: List) = actions(JsonField.of(actions)) + + /** + * Sets [Builder.actions] to an arbitrary JSON value. + * + * You should usually call [Builder.actions] with a well-typed `List` value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun actions(actions: JsonField>) = apply { + this.actions = actions.map { it.toMutableList() } + } + + /** + * Adds a single [Action] to [actions]. + * + * @throws IllegalStateException if the field was previously set to a non-list. + */ + fun addAction(action: Action) = apply { + actions = + (actions ?: JsonField.of(mutableListOf())).also { + checkKnown("actions", it).add(action) + } + } + + /** Alias for calling [addAction] with `Action.ofTag(tag)`. */ + fun addAction(tag: Action.TagAction) = addAction(Action.ofTag(tag)) + + /** Alias for calling [addAction] with `Action.ofCreateCase(createCase)`. */ + fun addAction(createCase: Action.CreateCaseAction) = + addAction(Action.ofCreateCase(createCase)) + + /** The Auth Rule token */ + fun authRuleToken(authRuleToken: String) = authRuleToken(JsonField.of(authRuleToken)) + + /** + * Sets [Builder.authRuleToken] to an arbitrary JSON value. + * + * You should usually call [Builder.authRuleToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun authRuleToken(authRuleToken: JsonField) = apply { + this.authRuleToken = authRuleToken + } + + /** Timestamp of the rule evaluation */ + fun evaluationTime(evaluationTime: OffsetDateTime) = + evaluationTime(JsonField.of(evaluationTime)) + + /** + * Sets [Builder.evaluationTime] to an arbitrary JSON value. + * + * You should usually call [Builder.evaluationTime] with a well-typed [OffsetDateTime] + * value instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun evaluationTime(evaluationTime: JsonField) = apply { + this.evaluationTime = evaluationTime + } + + /** The event stream during which the rule was evaluated */ + fun eventStream(eventStream: EventStream) = eventStream(JsonField.of(eventStream)) + + /** + * Sets [Builder.eventStream] to an arbitrary JSON value. + * + * You should usually call [Builder.eventStream] with a well-typed [EventStream] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventStream(eventStream: JsonField) = apply { + this.eventStream = eventStream + } + + /** Token of the event that triggered the evaluation */ + fun eventToken(eventToken: String) = eventToken(JsonField.of(eventToken)) + + /** + * Sets [Builder.eventToken] to an arbitrary JSON value. + * + * You should usually call [Builder.eventToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun eventToken(eventToken: JsonField) = apply { this.eventToken = eventToken } + + /** The state of the Auth Rule */ + fun mode(mode: AuthRuleState) = mode(JsonField.of(mode)) + + /** + * Sets [Builder.mode] to an arbitrary JSON value. + * + * You should usually call [Builder.mode] with a well-typed [AuthRuleState] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun mode(mode: JsonField) = apply { this.mode = mode } + + /** Version of the rule that was evaluated */ + fun ruleVersion(ruleVersion: Long) = ruleVersion(JsonField.of(ruleVersion)) + + /** + * Sets [Builder.ruleVersion] to an arbitrary JSON value. + * + * You should usually call [Builder.ruleVersion] with a well-typed [Long] value instead. + * This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun ruleVersion(ruleVersion: JsonField) = apply { this.ruleVersion = ruleVersion } + + /** The token of the transaction that triggered the rule evaluation */ + fun transactionToken(transactionToken: String?) = + transactionToken(JsonField.ofNullable(transactionToken)) + + /** + * Alias for calling [Builder.transactionToken] with `transactionToken.orElse(null)`. + */ + fun transactionToken(transactionToken: Optional) = + transactionToken(transactionToken.getOrNull()) + + /** + * Sets [Builder.transactionToken] to an arbitrary JSON value. + * + * You should usually call [Builder.transactionToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or not yet + * supported value. + */ + fun transactionToken(transactionToken: JsonField) = apply { + this.transactionToken = transactionToken + } + + 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 [AchPaymentUpdateResult]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .token() + * .actions() + * .authRuleToken() + * .evaluationTime() + * .eventStream() + * .eventToken() + * .mode() + * .ruleVersion() + * .transactionToken() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): AchPaymentUpdateResult = + AchPaymentUpdateResult( + checkRequired("token", token), + checkRequired("actions", actions).map { it.toImmutable() }, + checkRequired("authRuleToken", authRuleToken), + checkRequired("evaluationTime", evaluationTime), + checkRequired("eventStream", eventStream), + checkRequired("eventToken", eventToken), + checkRequired("mode", mode), + checkRequired("ruleVersion", ruleVersion), + checkRequired("transactionToken", transactionToken), + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AchPaymentUpdateResult = apply { + if (validated) { + return@apply + } + + token() + actions().forEach { it.validate() } + authRuleToken() + evaluationTime() + eventStream().validate() + eventToken() + mode().validate() + ruleVersion() + transactionToken() + validated = true + } + + fun isValid(): Boolean = + try { + validate() + true + } catch (e: LithicInvalidDataException) { + false + } + + /** + * Returns a score indicating how many valid values are contained in this object + * recursively. + * + * Used for best match union deserialization. + */ + @JvmSynthetic + internal fun validity(): Int = + (if (token.asKnown().isPresent) 1 else 0) + + (actions.asKnown().getOrNull()?.sumOf { it.validity().toInt() } ?: 0) + + (if (authRuleToken.asKnown().isPresent) 1 else 0) + + (if (evaluationTime.asKnown().isPresent) 1 else 0) + + (eventStream.asKnown().getOrNull()?.validity() ?: 0) + + (if (eventToken.asKnown().isPresent) 1 else 0) + + (mode.asKnown().getOrNull()?.validity() ?: 0) + + (if (ruleVersion.asKnown().isPresent) 1 else 0) + + (if (transactionToken.asKnown().isPresent) 1 else 0) + + @JsonDeserialize(using = Action.Deserializer::class) + @JsonSerialize(using = Action.Serializer::class) + class Action + private constructor( + private val tag: TagAction? = null, + private val createCase: CreateCaseAction? = null, + private val _json: JsonValue? = null, + ) { + + fun tag(): Optional = Optional.ofNullable(tag) + + fun createCase(): Optional = Optional.ofNullable(createCase) + + fun isTag(): Boolean = tag != null + + fun isCreateCase(): Boolean = createCase != null + + fun asTag(): TagAction = tag.getOrThrow("tag") + + fun asCreateCase(): CreateCaseAction = createCase.getOrThrow("createCase") + + fun _json(): Optional = Optional.ofNullable(_json) + + /** + * Maps this instance's current variant to a value of type [T] using the given + * [visitor]. + * + * Note that this method is _not_ forwards compatible with new variants from the API, + * unless [visitor] overrides [Visitor.unknown]. To handle variants not known to this + * version of the SDK gracefully, consider overriding [Visitor.unknown]: + * ```java + * import com.lithic.api.core.JsonValue; + * import java.util.Optional; + * + * Optional result = action.accept(new Action.Visitor>() { + * @Override + * public Optional visitTag(TagAction tag) { + * return Optional.of(tag.toString()); + * } + * + * // ... + * + * @Override + * public Optional unknown(JsonValue json) { + * // Or inspect the `json`. + * return Optional.empty(); + * } + * }); + * ``` + * + * @throws LithicInvalidDataException if [Visitor.unknown] is not overridden in + * [visitor] and the current variant is unknown. + */ + fun accept(visitor: Visitor): T = + when { + tag != null -> visitor.visitTag(tag) + createCase != null -> visitor.visitCreateCase(createCase) + else -> visitor.unknown(_json) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): Action = apply { + if (validated) { + return@apply + } + + accept( + object : Visitor { + override fun visitTag(tag: TagAction) { + tag.validate() + } + + override fun visitCreateCase(createCase: CreateCaseAction) { + createCase.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 visitTag(tag: TagAction) = tag.validity() + + override fun visitCreateCase(createCase: CreateCaseAction) = + createCase.validity() + + override fun unknown(json: JsonValue?) = 0 + } + ) + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is Action && tag == other.tag && createCase == other.createCase + } + + override fun hashCode(): Int = Objects.hash(tag, createCase) + + override fun toString(): String = + when { + tag != null -> "Action{tag=$tag}" + createCase != null -> "Action{createCase=$createCase}" + _json != null -> "Action{_unknown=$_json}" + else -> throw IllegalStateException("Invalid Action") + } + + companion object { + + @JvmStatic fun ofTag(tag: TagAction) = Action(tag = tag) + + @JvmStatic + fun ofCreateCase(createCase: CreateCaseAction) = Action(createCase = createCase) + } + + /** + * An interface that defines how to map each variant of [Action] to a value of type [T]. + */ + interface Visitor { + + fun visitTag(tag: TagAction): T + + fun visitCreateCase(createCase: CreateCaseAction): T + + /** + * Maps an unknown variant of [Action] to a value of type [T]. + * + * An instance of [Action] 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 Action: $json") + } + } + + internal class Deserializer : BaseDeserializer(Action::class) { + + override fun ObjectCodec.deserialize(node: JsonNode): Action { + val json = JsonValue.fromJsonNode(node) + + val bestMatches = + sequenceOf( + tryDeserialize(node, jacksonTypeRef())?.let { + Action(tag = it, _json = json) + }, + tryDeserialize(node, jacksonTypeRef())?.let { + Action(createCase = 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 -> Action(_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(Action::class) { + + override fun serialize( + value: Action, + generator: JsonGenerator, + provider: SerializerProvider, + ) { + when { + value.tag != null -> generator.writeObject(value.tag) + value.createCase != null -> generator.writeObject(value.createCase) + value._json != null -> generator.writeObject(value._json) + else -> throw IllegalStateException("Invalid Action") + } + } + } + + class TagAction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val key: JsonField, + private val type: JsonField, + private val value: JsonField, + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("key") @ExcludeMissing key: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + value: JsonField = JsonMissing.of(), + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + ) : this(key, type, value, explanation, mutableMapOf()) + + /** + * The key of the tag to apply to the payment + * + * @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 key(): String = key.getRequired("key") + + /** + * Tag the payment with key-value metadata + * + * @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 type(): Type = type.getRequired("type") + + /** + * The value of the tag to apply to the payment + * + * @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 value(): String = value.getRequired("value") + + /** + * Optional explanation for why this action was taken + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * Returns the raw JSON value of [key]. + * + * Unlike [key], this method doesn't throw if the JSON field has an unexpected type. + */ + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key + + /** + * 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 + + /** + * 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 + + /** + * Returns the raw JSON value of [explanation]. + * + * Unlike [explanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("explanation") + @ExcludeMissing + fun _explanation(): JsonField = explanation + + @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 [TagAction]. + * + * The following fields are required: + * ```java + * .key() + * .type() + * .value() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [TagAction]. */ + class Builder internal constructor() { + + private var key: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null + private var explanation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(tagAction: TagAction) = apply { + key = tagAction.key + type = tagAction.type + value = tagAction.value + explanation = tagAction.explanation + additionalProperties = tagAction.additionalProperties.toMutableMap() + } + + /** The key of the tag to apply to the payment */ + fun key(key: String) = key(JsonField.of(key)) + + /** + * Sets [Builder.key] to an arbitrary JSON value. + * + * You should usually call [Builder.key] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun key(key: JsonField) = apply { this.key = key } + + /** Tag the payment with key-value metadata */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] 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 } + + /** The value of the tag to apply to the payment */ + fun value(value: String) = value(JsonField.of(value)) + + /** + * Sets [Builder.value] to an arbitrary JSON value. + * + * You should usually call [Builder.value] with a well-typed [String] 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 } + + /** Optional explanation for why this action was taken */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * Sets [Builder.explanation] to an arbitrary JSON value. + * + * You should usually call [Builder.explanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun explanation(explanation: JsonField) = apply { + this.explanation = explanation + } + + 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 [TagAction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .key() + * .type() + * .value() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): TagAction = + TagAction( + checkRequired("key", key), + checkRequired("type", type), + checkRequired("value", value), + explanation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): TagAction = apply { + if (validated) { + return@apply + } + + key() + type().validate() + value() + explanation() + 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 (key.asKnown().isPresent) 1 else 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (value.asKnown().isPresent) 1 else 0) + + (if (explanation.asKnown().isPresent) 1 else 0) + + /** Tag the payment with key-value metadata */ + class Type @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 TAG = of("TAG") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + TAG + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + TAG, + /** + * An enum member indicating that [Type] 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) { + TAG -> Value.TAG + 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) { + TAG -> Known.TAG + else -> throw LithicInvalidDataException("Unknown Type: $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 + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Type = 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is TagAction && + key == other.key && + type == other.type && + value == other.value && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(key, type, value, explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "TagAction{key=$key, type=$type, value=$value, explanation=$explanation, additionalProperties=$additionalProperties}" + } + + class CreateCaseAction + @JsonCreator(mode = JsonCreator.Mode.DISABLED) + private constructor( + private val queueToken: JsonField, + private val scope: JsonField, + private val type: JsonField, + private val explanation: JsonField, + private val additionalProperties: MutableMap, + ) { + + @JsonCreator + private constructor( + @JsonProperty("queue_token") + @ExcludeMissing + queueToken: JsonField = JsonMissing.of(), + @JsonProperty("scope") + @ExcludeMissing + scope: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing type: JsonField = JsonMissing.of(), + @JsonProperty("explanation") + @ExcludeMissing + explanation: JsonField = JsonMissing.of(), + ) : this(queueToken, scope, type, explanation, mutableMapOf()) + + /** + * The token of the queue to create the case in + * + * @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 queueToken(): String = queueToken.getRequired("queue_token") + + /** + * The scope of the case to create + * + * @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 scope(): Scope = scope.getRequired("scope") + + /** + * Create a case for the payment + * + * @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 type(): Type = type.getRequired("type") + + /** + * Optional explanation for why this action was taken + * + * @throws LithicInvalidDataException if the JSON field has an unexpected type (e.g. + * if the server responded with an unexpected value). + */ + fun explanation(): Optional = explanation.getOptional("explanation") + + /** + * Returns the raw JSON value of [queueToken]. + * + * Unlike [queueToken], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("queue_token") + @ExcludeMissing + fun _queueToken(): JsonField = queueToken + + /** + * Returns the raw JSON value of [scope]. + * + * Unlike [scope], this method doesn't throw if the JSON field has an unexpected + * type. + */ + @JsonProperty("scope") @ExcludeMissing fun _scope(): JsonField = scope + + /** + * 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 + + /** + * Returns the raw JSON value of [explanation]. + * + * Unlike [explanation], this method doesn't throw if the JSON field has an + * unexpected type. + */ + @JsonProperty("explanation") + @ExcludeMissing + fun _explanation(): JsonField = explanation + + @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 [CreateCaseAction]. + * + * The following fields are required: + * ```java + * .queueToken() + * .scope() + * .type() + * ``` + */ + @JvmStatic fun builder() = Builder() + } + + /** A builder for [CreateCaseAction]. */ + class Builder internal constructor() { + + private var queueToken: JsonField? = null + private var scope: JsonField? = null + private var type: JsonField? = null + private var explanation: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(createCaseAction: CreateCaseAction) = apply { + queueToken = createCaseAction.queueToken + scope = createCaseAction.scope + type = createCaseAction.type + explanation = createCaseAction.explanation + additionalProperties = createCaseAction.additionalProperties.toMutableMap() + } + + /** The token of the queue to create the case in */ + fun queueToken(queueToken: String) = queueToken(JsonField.of(queueToken)) + + /** + * Sets [Builder.queueToken] to an arbitrary JSON value. + * + * You should usually call [Builder.queueToken] with a well-typed [String] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun queueToken(queueToken: JsonField) = apply { + this.queueToken = queueToken + } + + /** The scope of the case to create */ + fun scope(scope: Scope) = scope(JsonField.of(scope)) + + /** + * Sets [Builder.scope] to an arbitrary JSON value. + * + * You should usually call [Builder.scope] with a well-typed [Scope] value + * instead. This method is primarily for setting the field to an undocumented or + * not yet supported value. + */ + fun scope(scope: JsonField) = apply { this.scope = scope } + + /** Create a case for the payment */ + fun type(type: Type) = type(JsonField.of(type)) + + /** + * Sets [Builder.type] to an arbitrary JSON value. + * + * You should usually call [Builder.type] with a well-typed [Type] 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 } + + /** Optional explanation for why this action was taken */ + fun explanation(explanation: String) = explanation(JsonField.of(explanation)) + + /** + * Sets [Builder.explanation] to an arbitrary JSON value. + * + * You should usually call [Builder.explanation] with a well-typed [String] + * value instead. This method is primarily for setting the field to an + * undocumented or not yet supported value. + */ + fun explanation(explanation: JsonField) = apply { + this.explanation = explanation + } + + 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 [CreateCaseAction]. + * + * Further updates to this [Builder] will not mutate the returned instance. + * + * The following fields are required: + * ```java + * .queueToken() + * .scope() + * .type() + * ``` + * + * @throws IllegalStateException if any required field is unset. + */ + fun build(): CreateCaseAction = + CreateCaseAction( + checkRequired("queueToken", queueToken), + checkRequired("scope", scope), + checkRequired("type", type), + explanation, + additionalProperties.toMutableMap(), + ) + } + + private var validated: Boolean = false + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match + * its expected type. + */ + fun validate(): CreateCaseAction = apply { + if (validated) { + return@apply + } + + queueToken() + scope().validate() + type().validate() + explanation() + 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 (queueToken.asKnown().isPresent) 1 else 0) + + (scope.asKnown().getOrNull()?.validity() ?: 0) + + (type.asKnown().getOrNull()?.validity() ?: 0) + + (if (explanation.asKnown().isPresent) 1 else 0) + + /** The scope of the case to create */ + class Scope @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 FINANCIAL_ACCOUNT = of("FINANCIAL_ACCOUNT") + + @JvmStatic fun of(value: String) = Scope(JsonField.of(value)) + } + + /** An enum containing [Scope]'s known values. */ + enum class Known { + FINANCIAL_ACCOUNT + } + + /** + * An enum containing [Scope]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Scope] 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 { + FINANCIAL_ACCOUNT, + /** + * An enum member indicating that [Scope] 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) { + FINANCIAL_ACCOUNT -> Value.FINANCIAL_ACCOUNT + 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) { + FINANCIAL_ACCOUNT -> Known.FINANCIAL_ACCOUNT + else -> throw LithicInvalidDataException("Unknown Scope: $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 + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Scope = 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 other is Scope && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** Create a case for the payment */ + class Type @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 CREATE_CASE = of("CREATE_CASE") + + @JvmStatic fun of(value: String) = Type(JsonField.of(value)) + } + + /** An enum containing [Type]'s known values. */ + enum class Known { + CREATE_CASE + } + + /** + * An enum containing [Type]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [Type] 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 { + CREATE_CASE, + /** + * An enum member indicating that [Type] 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) { + CREATE_CASE -> Value.CREATE_CASE + 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) { + CREATE_CASE -> Known.CREATE_CASE + else -> throw LithicInvalidDataException("Unknown Type: $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 + + /** + * Validates that the types of all values in this object match their expected + * types recursively. + * + * This method is _not_ forwards compatible with new types from the API for + * existing fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't + * match its expected type. + */ + fun validate(): Type = 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 other is Type && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is CreateCaseAction && + queueToken == other.queueToken && + scope == other.scope && + type == other.type && + explanation == other.explanation && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash(queueToken, scope, type, explanation, additionalProperties) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "CreateCaseAction{queueToken=$queueToken, scope=$scope, type=$type, explanation=$explanation, additionalProperties=$additionalProperties}" + } + } + + /** The event stream during which the rule was evaluated */ + class EventStream @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 ACH_PAYMENT_UPDATE = of("ACH_PAYMENT_UPDATE") + + @JvmStatic fun of(value: String) = EventStream(JsonField.of(value)) + } + + /** An enum containing [EventStream]'s known values. */ + enum class Known { + ACH_PAYMENT_UPDATE + } + + /** + * An enum containing [EventStream]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [EventStream] 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 { + ACH_PAYMENT_UPDATE, + /** + * An enum member indicating that [EventStream] 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) { + ACH_PAYMENT_UPDATE -> Value.ACH_PAYMENT_UPDATE + 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) { + ACH_PAYMENT_UPDATE -> Known.ACH_PAYMENT_UPDATE + else -> throw LithicInvalidDataException("Unknown EventStream: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): EventStream = 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 other is EventStream && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + /** The state of the Auth Rule */ + class AuthRuleState @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 ACTIVE = of("ACTIVE") + + @JvmField val INACTIVE = of("INACTIVE") + + @JvmStatic fun of(value: String) = AuthRuleState(JsonField.of(value)) + } + + /** An enum containing [AuthRuleState]'s known values. */ + enum class Known { + ACTIVE, + INACTIVE, + } + + /** + * An enum containing [AuthRuleState]'s known values, as well as an [_UNKNOWN] member. + * + * An instance of [AuthRuleState] 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 { + ACTIVE, + INACTIVE, + /** + * An enum member indicating that [AuthRuleState] 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) { + ACTIVE -> Value.ACTIVE + INACTIVE -> Value.INACTIVE + 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) { + ACTIVE -> Known.ACTIVE + INACTIVE -> Known.INACTIVE + else -> throw LithicInvalidDataException("Unknown AuthRuleState: $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 + + /** + * Validates that the types of all values in this object match their expected types + * recursively. + * + * This method is _not_ forwards compatible with new types from the API for existing + * fields. + * + * @throws LithicInvalidDataException if any value type in this object doesn't match its + * expected type. + */ + fun validate(): AuthRuleState = 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 other is AuthRuleState && value == other.value + } + + override fun hashCode() = value.hashCode() + + override fun toString() = value.toString() + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return other is AchPaymentUpdateResult && + token == other.token && + actions == other.actions && + authRuleToken == other.authRuleToken && + evaluationTime == other.evaluationTime && + eventStream == other.eventStream && + eventToken == other.eventToken && + mode == other.mode && + ruleVersion == other.ruleVersion && + transactionToken == other.transactionToken && + additionalProperties == other.additionalProperties + } + + private val hashCode: Int by lazy { + Objects.hash( + token, + actions, + authRuleToken, + evaluationTime, + eventStream, + eventToken, + mode, + ruleVersion, + transactionToken, + additionalProperties, + ) + } + + override fun hashCode(): Int = hashCode + + override fun toString() = + "AchPaymentUpdateResult{token=$token, actions=$actions, authRuleToken=$authRuleToken, evaluationTime=$evaluationTime, eventStream=$eventStream, eventToken=$eventToken, mode=$mode, ruleVersion=$ruleVersion, transactionToken=$transactionToken, additionalProperties=$additionalProperties}" + } } diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/AchPaymentUpdateActionTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AchPaymentUpdateActionTest.kt new file mode 100644 index 00000000..c3773de6 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/AchPaymentUpdateActionTest.kt @@ -0,0 +1,106 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.JsonValue +import com.lithic.api.core.jsonMapper +import com.lithic.api.errors.LithicInvalidDataException +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test +import org.junit.jupiter.api.assertThrows +import org.junit.jupiter.params.ParameterizedTest +import org.junit.jupiter.params.provider.EnumSource + +internal class AchPaymentUpdateActionTest { + + @Test + fun ofTag() { + val tag = + AchPaymentUpdateAction.TagAction.builder() + .key("key") + .type(AchPaymentUpdateAction.TagAction.Type.TAG) + .value("value") + .build() + + val achPaymentUpdateAction = AchPaymentUpdateAction.ofTag(tag) + + assertThat(achPaymentUpdateAction.tag()).contains(tag) + assertThat(achPaymentUpdateAction.createCase()).isEmpty + } + + @Test + fun ofTagRoundtrip() { + val jsonMapper = jsonMapper() + val achPaymentUpdateAction = + AchPaymentUpdateAction.ofTag( + AchPaymentUpdateAction.TagAction.builder() + .key("key") + .type(AchPaymentUpdateAction.TagAction.Type.TAG) + .value("value") + .build() + ) + + val roundtrippedAchPaymentUpdateAction = + jsonMapper.readValue( + jsonMapper.writeValueAsString(achPaymentUpdateAction), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAchPaymentUpdateAction).isEqualTo(achPaymentUpdateAction) + } + + @Test + fun ofCreateCase() { + val createCase = + AchPaymentUpdateAction.CreateCaseAction.builder() + .queueToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scope(AchPaymentUpdateAction.CreateCaseAction.Scope.FINANCIAL_ACCOUNT) + .type(AchPaymentUpdateAction.CreateCaseAction.Type.CREATE_CASE) + .build() + + val achPaymentUpdateAction = AchPaymentUpdateAction.ofCreateCase(createCase) + + assertThat(achPaymentUpdateAction.tag()).isEmpty + assertThat(achPaymentUpdateAction.createCase()).contains(createCase) + } + + @Test + fun ofCreateCaseRoundtrip() { + val jsonMapper = jsonMapper() + val achPaymentUpdateAction = + AchPaymentUpdateAction.ofCreateCase( + AchPaymentUpdateAction.CreateCaseAction.builder() + .queueToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .scope(AchPaymentUpdateAction.CreateCaseAction.Scope.FINANCIAL_ACCOUNT) + .type(AchPaymentUpdateAction.CreateCaseAction.Type.CREATE_CASE) + .build() + ) + + val roundtrippedAchPaymentUpdateAction = + jsonMapper.readValue( + jsonMapper.writeValueAsString(achPaymentUpdateAction), + jacksonTypeRef(), + ) + + assertThat(roundtrippedAchPaymentUpdateAction).isEqualTo(achPaymentUpdateAction) + } + + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { + BOOLEAN(JsonValue.from(false)), + STRING(JsonValue.from("invalid")), + INTEGER(JsonValue.from(-1)), + FLOAT(JsonValue.from(3.14)), + ARRAY(JsonValue.from(listOf("invalid", "array"))), + } + + @ParameterizedTest + @EnumSource + fun incompatibleJsonShapeDeserializesToUnknown(testCase: IncompatibleJsonShapeTestCase) { + val achPaymentUpdateAction = + jsonMapper().convertValue(testCase.value, jacksonTypeRef()) + + val e = assertThrows { achPaymentUpdateAction.validate() } + assertThat(e).hasMessageStartingWith("Unknown ") + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/ConditionalAchPaymentUpdateActionParametersTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ConditionalAchPaymentUpdateActionParametersTest.kt new file mode 100644 index 00000000..cb34fe01 --- /dev/null +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/ConditionalAchPaymentUpdateActionParametersTest.kt @@ -0,0 +1,91 @@ +// File generated from our OpenAPI spec by Stainless. + +package com.lithic.api.models + +import com.fasterxml.jackson.module.kotlin.jacksonTypeRef +import com.lithic.api.core.jsonMapper +import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.Test + +internal class ConditionalAchPaymentUpdateActionParametersTest { + + @Test + fun create() { + val conditionalAchPaymentUpdateActionParameters = + ConditionalAchPaymentUpdateActionParameters.builder() + .action( + AchPaymentUpdateAction.TagAction.builder() + .key("key") + .type(AchPaymentUpdateAction.TagAction.Type.TAG) + .value("value") + .build() + ) + .addCondition( + ConditionalAchPaymentUpdateActionParameters.Condition.builder() + .attribute( + ConditionalAchPaymentUpdateActionParameters.Condition.Attribute + .TRANSACTION_AMOUNT + ) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + .build() + + assertThat(conditionalAchPaymentUpdateActionParameters.action()) + .isEqualTo( + AchPaymentUpdateAction.ofTag( + AchPaymentUpdateAction.TagAction.builder() + .key("key") + .type(AchPaymentUpdateAction.TagAction.Type.TAG) + .value("value") + .build() + ) + ) + assertThat(conditionalAchPaymentUpdateActionParameters.conditions()) + .containsExactly( + ConditionalAchPaymentUpdateActionParameters.Condition.builder() + .attribute( + ConditionalAchPaymentUpdateActionParameters.Condition.Attribute + .TRANSACTION_AMOUNT + ) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + } + + @Test + fun roundtrip() { + val jsonMapper = jsonMapper() + val conditionalAchPaymentUpdateActionParameters = + ConditionalAchPaymentUpdateActionParameters.builder() + .action( + AchPaymentUpdateAction.TagAction.builder() + .key("key") + .type(AchPaymentUpdateAction.TagAction.Type.TAG) + .value("value") + .build() + ) + .addCondition( + ConditionalAchPaymentUpdateActionParameters.Condition.builder() + .attribute( + ConditionalAchPaymentUpdateActionParameters.Condition.Attribute + .TRANSACTION_AMOUNT + ) + .operation(ConditionalOperation.IS_ONE_OF) + .value("string") + .build() + ) + .build() + + val roundtrippedConditionalAchPaymentUpdateActionParameters = + jsonMapper.readValue( + jsonMapper.writeValueAsString(conditionalAchPaymentUpdateActionParameters), + jacksonTypeRef(), + ) + + assertThat(roundtrippedConditionalAchPaymentUpdateActionParameters) + .isEqualTo(conditionalAchPaymentUpdateActionParameters) + } +} diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/RuleFeatureTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/RuleFeatureTest.kt index fbf9e23c..fcca3802 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/RuleFeatureTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/RuleFeatureTest.kt @@ -29,6 +29,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).isEmpty @@ -71,6 +72,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).isEmpty @@ -113,6 +115,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).contains(tokenization) assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).isEmpty @@ -155,6 +158,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).contains(achReceipt) assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).isEmpty @@ -197,6 +201,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).contains(cardTransaction) + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).isEmpty @@ -224,6 +229,49 @@ internal class RuleFeatureTest { assertThat(roundtrippedRuleFeature).isEqualTo(ruleFeature) } + @Test + fun ofAchPayment() { + val achPayment = + RuleFeature.AchPaymentFeature.builder() + .type(RuleFeature.AchPaymentFeature.Type.ACH_PAYMENT) + .name("name") + .build() + + val ruleFeature = RuleFeature.ofAchPayment(achPayment) + + assertThat(ruleFeature.authorization()).isEmpty + assertThat(ruleFeature.authentication()).isEmpty + assertThat(ruleFeature.tokenization()).isEmpty + assertThat(ruleFeature.achReceipt()).isEmpty + assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).contains(achPayment) + assertThat(ruleFeature.card()).isEmpty + assertThat(ruleFeature.accountHolder()).isEmpty + assertThat(ruleFeature.ipMetadata()).isEmpty + assertThat(ruleFeature.spendVelocity()).isEmpty + assertThat(ruleFeature.transactionHistorySignals()).isEmpty + } + + @Test + fun ofAchPaymentRoundtrip() { + val jsonMapper = jsonMapper() + val ruleFeature = + RuleFeature.ofAchPayment( + RuleFeature.AchPaymentFeature.builder() + .type(RuleFeature.AchPaymentFeature.Type.ACH_PAYMENT) + .name("name") + .build() + ) + + val roundtrippedRuleFeature = + jsonMapper.readValue( + jsonMapper.writeValueAsString(ruleFeature), + jacksonTypeRef(), + ) + + assertThat(roundtrippedRuleFeature).isEqualTo(ruleFeature) + } + @Test fun ofCard() { val card = @@ -239,6 +287,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).contains(card) assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).isEmpty @@ -281,6 +330,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).contains(accountHolder) assertThat(ruleFeature.ipMetadata()).isEmpty @@ -323,6 +373,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).contains(ipMetadata) @@ -381,6 +432,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).isEmpty @@ -442,6 +494,7 @@ internal class RuleFeatureTest { assertThat(ruleFeature.tokenization()).isEmpty assertThat(ruleFeature.achReceipt()).isEmpty assertThat(ruleFeature.cardTransaction()).isEmpty + assertThat(ruleFeature.achPayment()).isEmpty assertThat(ruleFeature.card()).isEmpty assertThat(ruleFeature.accountHolder()).isEmpty assertThat(ruleFeature.ipMetadata()).isEmpty diff --git a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResultsResponseTest.kt b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResultsResponseTest.kt index f803957d..456fe9e0 100644 --- a/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResultsResponseTest.kt +++ b/lithic-java-core/src/test/kotlin/com/lithic/api/models/V2ListResultsResponseTest.kt @@ -53,6 +53,8 @@ internal class V2ListResultsResponseTest { assertThat(v2ListResultsResponse.authentication3dsResult()).isEmpty assertThat(v2ListResultsResponse.tokenizationResult()).isEmpty assertThat(v2ListResultsResponse.achResult()).isEmpty + assertThat(v2ListResultsResponse.cardTransactionUpdateResult()).isEmpty + assertThat(v2ListResultsResponse.achPaymentUpdateResult()).isEmpty } @Test @@ -136,6 +138,8 @@ internal class V2ListResultsResponseTest { .contains(authentication3dsResult) assertThat(v2ListResultsResponse.tokenizationResult()).isEmpty assertThat(v2ListResultsResponse.achResult()).isEmpty + assertThat(v2ListResultsResponse.cardTransactionUpdateResult()).isEmpty + assertThat(v2ListResultsResponse.achPaymentUpdateResult()).isEmpty } @Test @@ -215,6 +219,8 @@ internal class V2ListResultsResponseTest { assertThat(v2ListResultsResponse.authentication3dsResult()).isEmpty assertThat(v2ListResultsResponse.tokenizationResult()).contains(tokenizationResult) assertThat(v2ListResultsResponse.achResult()).isEmpty + assertThat(v2ListResultsResponse.cardTransactionUpdateResult()).isEmpty + assertThat(v2ListResultsResponse.achPaymentUpdateResult()).isEmpty } @Test @@ -287,6 +293,8 @@ internal class V2ListResultsResponseTest { assertThat(v2ListResultsResponse.authentication3dsResult()).isEmpty assertThat(v2ListResultsResponse.tokenizationResult()).isEmpty assertThat(v2ListResultsResponse.achResult()).contains(achResult) + assertThat(v2ListResultsResponse.cardTransactionUpdateResult()).isEmpty + assertThat(v2ListResultsResponse.achPaymentUpdateResult()).isEmpty } @Test @@ -323,6 +331,163 @@ internal class V2ListResultsResponseTest { assertThat(roundtrippedV2ListResultsResponse).isEqualTo(v2ListResultsResponse) } + @Test + fun ofCardTransactionUpdateResult() { + val cardTransactionUpdateResult = + V2ListResultsResponse.CardTransactionUpdateResult.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAction( + V2ListResultsResponse.CardTransactionUpdateResult.Action.TagAction.builder() + .key("key") + .type( + V2ListResultsResponse.CardTransactionUpdateResult.Action.TagAction.Type + .TAG + ) + .value("value") + .explanation("explanation") + .build() + ) + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventStream( + V2ListResultsResponse.CardTransactionUpdateResult.EventStream + .CARD_TRANSACTION_UPDATE + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .mode(V2ListResultsResponse.CardTransactionUpdateResult.AuthRuleState.ACTIVE) + .ruleVersion(0L) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val v2ListResultsResponse = + V2ListResultsResponse.ofCardTransactionUpdateResult(cardTransactionUpdateResult) + + assertThat(v2ListResultsResponse.authorizationResult()).isEmpty + assertThat(v2ListResultsResponse.authentication3dsResult()).isEmpty + assertThat(v2ListResultsResponse.tokenizationResult()).isEmpty + assertThat(v2ListResultsResponse.achResult()).isEmpty + assertThat(v2ListResultsResponse.cardTransactionUpdateResult()) + .contains(cardTransactionUpdateResult) + assertThat(v2ListResultsResponse.achPaymentUpdateResult()).isEmpty + } + + @Test + fun ofCardTransactionUpdateResultRoundtrip() { + val jsonMapper = jsonMapper() + val v2ListResultsResponse = + V2ListResultsResponse.ofCardTransactionUpdateResult( + V2ListResultsResponse.CardTransactionUpdateResult.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAction( + V2ListResultsResponse.CardTransactionUpdateResult.Action.TagAction.builder() + .key("key") + .type( + V2ListResultsResponse.CardTransactionUpdateResult.Action.TagAction + .Type + .TAG + ) + .value("value") + .explanation("explanation") + .build() + ) + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventStream( + V2ListResultsResponse.CardTransactionUpdateResult.EventStream + .CARD_TRANSACTION_UPDATE + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .mode(V2ListResultsResponse.CardTransactionUpdateResult.AuthRuleState.ACTIVE) + .ruleVersion(0L) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val roundtrippedV2ListResultsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v2ListResultsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedV2ListResultsResponse).isEqualTo(v2ListResultsResponse) + } + + @Test + fun ofAchPaymentUpdateResult() { + val achPaymentUpdateResult = + V2ListResultsResponse.AchPaymentUpdateResult.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAction( + V2ListResultsResponse.AchPaymentUpdateResult.Action.TagAction.builder() + .key("key") + .type( + V2ListResultsResponse.AchPaymentUpdateResult.Action.TagAction.Type.TAG + ) + .value("value") + .explanation("explanation") + .build() + ) + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventStream( + V2ListResultsResponse.AchPaymentUpdateResult.EventStream.ACH_PAYMENT_UPDATE + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .mode(V2ListResultsResponse.AchPaymentUpdateResult.AuthRuleState.ACTIVE) + .ruleVersion(0L) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + + val v2ListResultsResponse = + V2ListResultsResponse.ofAchPaymentUpdateResult(achPaymentUpdateResult) + + assertThat(v2ListResultsResponse.authorizationResult()).isEmpty + assertThat(v2ListResultsResponse.authentication3dsResult()).isEmpty + assertThat(v2ListResultsResponse.tokenizationResult()).isEmpty + assertThat(v2ListResultsResponse.achResult()).isEmpty + assertThat(v2ListResultsResponse.cardTransactionUpdateResult()).isEmpty + assertThat(v2ListResultsResponse.achPaymentUpdateResult()).contains(achPaymentUpdateResult) + } + + @Test + fun ofAchPaymentUpdateResultRoundtrip() { + val jsonMapper = jsonMapper() + val v2ListResultsResponse = + V2ListResultsResponse.ofAchPaymentUpdateResult( + V2ListResultsResponse.AchPaymentUpdateResult.builder() + .token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .addAction( + V2ListResultsResponse.AchPaymentUpdateResult.Action.TagAction.builder() + .key("key") + .type( + V2ListResultsResponse.AchPaymentUpdateResult.Action.TagAction.Type + .TAG + ) + .value("value") + .explanation("explanation") + .build() + ) + .authRuleToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .evaluationTime(OffsetDateTime.parse("2019-12-27T18:11:19.117Z")) + .eventStream( + V2ListResultsResponse.AchPaymentUpdateResult.EventStream.ACH_PAYMENT_UPDATE + ) + .eventToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .mode(V2ListResultsResponse.AchPaymentUpdateResult.AuthRuleState.ACTIVE) + .ruleVersion(0L) + .transactionToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e") + .build() + ) + + val roundtrippedV2ListResultsResponse = + jsonMapper.readValue( + jsonMapper.writeValueAsString(v2ListResultsResponse), + jacksonTypeRef(), + ) + + assertThat(roundtrippedV2ListResultsResponse).isEqualTo(v2ListResultsResponse) + } + enum class IncompatibleJsonShapeTestCase(val value: JsonValue) { BOOLEAN(JsonValue.from(false)), STRING(JsonValue.from("invalid")),