Skip to content

Commit c38dc03

Browse files
stainless-botRobertCraigie
authored andcommitted
fix: add missing properties to AuthRule
1 parent ee26e11 commit c38dc03

6 files changed

Lines changed: 169 additions & 1 deletion

File tree

lithic-java-core/src/main/kotlin/com/lithic/api/models/AuthRule.kt

Lines changed: 139 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ import java.util.Optional
1919
@NoAutoDetect
2020
class AuthRule
2121
private constructor(
22+
private val token: JsonField<String>,
23+
private val state: JsonField<State>,
24+
private val previousAuthRuleTokens: JsonField<List<String>>,
2225
private val allowedMcc: JsonField<List<String>>,
2326
private val blockedMcc: JsonField<List<String>>,
2427
private val allowedCountries: JsonField<List<String>>,
@@ -34,6 +37,19 @@ private constructor(
3437

3538
private var hashCode: Int = 0
3639

40+
/** Globally unique identifier. */
41+
fun token(): Optional<String> = Optional.ofNullable(token.getNullable("token"))
42+
43+
/** Indicates whether the Auth Rule is ACTIVE or INACTIVE */
44+
fun state(): Optional<State> = Optional.ofNullable(state.getNullable("state"))
45+
46+
/**
47+
* Identifier for the Auth Rule(s) that a new Auth Rule replaced; will be returned only if an
48+
* Auth Rule is applied to entities that previously already had one applied.
49+
*/
50+
fun previousAuthRuleTokens(): Optional<List<String>> =
51+
Optional.ofNullable(previousAuthRuleTokens.getNullable("previous_auth_rule_tokens"))
52+
3753
/** Merchant category codes for which the Auth Rule permits transactions. */
3854
fun allowedMcc(): Optional<List<String>> =
3955
Optional.ofNullable(allowedMcc.getNullable("allowed_mcc"))
@@ -83,6 +99,20 @@ private constructor(
8399
fun programLevel(): Optional<Boolean> =
84100
Optional.ofNullable(programLevel.getNullable("program_level"))
85101

102+
/** Globally unique identifier. */
103+
@JsonProperty("token") @ExcludeMissing fun _token() = token
104+
105+
/** Indicates whether the Auth Rule is ACTIVE or INACTIVE */
106+
@JsonProperty("state") @ExcludeMissing fun _state() = state
107+
108+
/**
109+
* Identifier for the Auth Rule(s) that a new Auth Rule replaced; will be returned only if an
110+
* Auth Rule is applied to entities that previously already had one applied.
111+
*/
112+
@JsonProperty("previous_auth_rule_tokens")
113+
@ExcludeMissing
114+
fun _previousAuthRuleTokens() = previousAuthRuleTokens
115+
86116
/** Merchant category codes for which the Auth Rule permits transactions. */
87117
@JsonProperty("allowed_mcc") @ExcludeMissing fun _allowedMcc() = allowedMcc
88118

@@ -131,6 +161,9 @@ private constructor(
131161

132162
fun validate() = apply {
133163
if (!validated) {
164+
token()
165+
state()
166+
previousAuthRuleTokens()
134167
allowedMcc()
135168
blockedMcc()
136169
allowedCountries()
@@ -151,6 +184,9 @@ private constructor(
151184
}
152185

153186
return other is AuthRule &&
187+
this.token == other.token &&
188+
this.state == other.state &&
189+
this.previousAuthRuleTokens == other.previousAuthRuleTokens &&
154190
this.allowedMcc == other.allowedMcc &&
155191
this.blockedMcc == other.blockedMcc &&
156192
this.allowedCountries == other.allowedCountries &&
@@ -166,6 +202,9 @@ private constructor(
166202
if (hashCode == 0) {
167203
hashCode =
168204
Objects.hash(
205+
token,
206+
state,
207+
previousAuthRuleTokens,
169208
allowedMcc,
170209
blockedMcc,
171210
allowedCountries,
@@ -181,7 +220,7 @@ private constructor(
181220
}
182221

183222
override fun toString() =
184-
"AuthRule{allowedMcc=$allowedMcc, blockedMcc=$blockedMcc, allowedCountries=$allowedCountries, blockedCountries=$blockedCountries, avsType=$avsType, accountTokens=$accountTokens, cardTokens=$cardTokens, programLevel=$programLevel, additionalProperties=$additionalProperties}"
223+
"AuthRule{token=$token, state=$state, previousAuthRuleTokens=$previousAuthRuleTokens, allowedMcc=$allowedMcc, blockedMcc=$blockedMcc, allowedCountries=$allowedCountries, blockedCountries=$blockedCountries, avsType=$avsType, accountTokens=$accountTokens, cardTokens=$cardTokens, programLevel=$programLevel, additionalProperties=$additionalProperties}"
185224

186225
companion object {
187226

@@ -190,6 +229,9 @@ private constructor(
190229

191230
class Builder {
192231

232+
private var token: JsonField<String> = JsonMissing.of()
233+
private var state: JsonField<State> = JsonMissing.of()
234+
private var previousAuthRuleTokens: JsonField<List<String>> = JsonMissing.of()
193235
private var allowedMcc: JsonField<List<String>> = JsonMissing.of()
194236
private var blockedMcc: JsonField<List<String>> = JsonMissing.of()
195237
private var allowedCountries: JsonField<List<String>> = JsonMissing.of()
@@ -202,6 +244,9 @@ private constructor(
202244

203245
@JvmSynthetic
204246
internal fun from(authRule: AuthRule) = apply {
247+
this.token = authRule.token
248+
this.state = authRule.state
249+
this.previousAuthRuleTokens = authRule.previousAuthRuleTokens
205250
this.allowedMcc = authRule.allowedMcc
206251
this.blockedMcc = authRule.blockedMcc
207252
this.allowedCountries = authRule.allowedCountries
@@ -213,6 +258,39 @@ private constructor(
213258
additionalProperties(authRule.additionalProperties)
214259
}
215260

261+
/** Globally unique identifier. */
262+
fun token(token: String) = token(JsonField.of(token))
263+
264+
/** Globally unique identifier. */
265+
@JsonProperty("token")
266+
@ExcludeMissing
267+
fun token(token: JsonField<String>) = apply { this.token = token }
268+
269+
/** Indicates whether the Auth Rule is ACTIVE or INACTIVE */
270+
fun state(state: State) = state(JsonField.of(state))
271+
272+
/** Indicates whether the Auth Rule is ACTIVE or INACTIVE */
273+
@JsonProperty("state")
274+
@ExcludeMissing
275+
fun state(state: JsonField<State>) = apply { this.state = state }
276+
277+
/**
278+
* Identifier for the Auth Rule(s) that a new Auth Rule replaced; will be returned only if
279+
* an Auth Rule is applied to entities that previously already had one applied.
280+
*/
281+
fun previousAuthRuleTokens(previousAuthRuleTokens: List<String>) =
282+
previousAuthRuleTokens(JsonField.of(previousAuthRuleTokens))
283+
284+
/**
285+
* Identifier for the Auth Rule(s) that a new Auth Rule replaced; will be returned only if
286+
* an Auth Rule is applied to entities that previously already had one applied.
287+
*/
288+
@JsonProperty("previous_auth_rule_tokens")
289+
@ExcludeMissing
290+
fun previousAuthRuleTokens(previousAuthRuleTokens: JsonField<List<String>>) = apply {
291+
this.previousAuthRuleTokens = previousAuthRuleTokens
292+
}
293+
216294
/** Merchant category codes for which the Auth Rule permits transactions. */
217295
fun allowedMcc(allowedMcc: List<String>) = allowedMcc(JsonField.of(allowedMcc))
218296

@@ -339,6 +417,9 @@ private constructor(
339417

340418
fun build(): AuthRule =
341419
AuthRule(
420+
token,
421+
state,
422+
previousAuthRuleTokens.map { it.toUnmodifiable() },
342423
allowedMcc.map { it.toUnmodifiable() },
343424
blockedMcc.map { it.toUnmodifiable() },
344425
allowedCountries.map { it.toUnmodifiable() },
@@ -351,6 +432,63 @@ private constructor(
351432
)
352433
}
353434

435+
class State
436+
@JsonCreator
437+
private constructor(
438+
private val value: JsonField<String>,
439+
) {
440+
441+
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
442+
443+
override fun equals(other: Any?): Boolean {
444+
if (this === other) {
445+
return true
446+
}
447+
448+
return other is State && this.value == other.value
449+
}
450+
451+
override fun hashCode() = value.hashCode()
452+
453+
override fun toString() = value.toString()
454+
455+
companion object {
456+
457+
@JvmField val ACTIVE = State(JsonField.of("ACTIVE"))
458+
459+
@JvmField val INACTIVE = State(JsonField.of("INACTIVE"))
460+
461+
@JvmStatic fun of(value: String) = State(JsonField.of(value))
462+
}
463+
464+
enum class Known {
465+
ACTIVE,
466+
INACTIVE,
467+
}
468+
469+
enum class Value {
470+
ACTIVE,
471+
INACTIVE,
472+
_UNKNOWN,
473+
}
474+
475+
fun value(): Value =
476+
when (this) {
477+
ACTIVE -> Value.ACTIVE
478+
INACTIVE -> Value.INACTIVE
479+
else -> Value._UNKNOWN
480+
}
481+
482+
fun known(): Known =
483+
when (this) {
484+
ACTIVE -> Known.ACTIVE
485+
INACTIVE -> Known.INACTIVE
486+
else -> throw LithicInvalidDataException("Unknown State: $value")
487+
}
488+
489+
fun asString(): String = _value().asStringOrThrow()
490+
}
491+
354492
class AvsType
355493
@JsonCreator
356494
private constructor(

lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleApplyResponseTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class AuthRuleApplyResponseTest {
1111
AuthRuleApplyResponse.builder()
1212
.data(
1313
AuthRule.builder()
14+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
15+
.state(AuthRule.State.ACTIVE)
16+
.previousAuthRuleTokens(listOf("string"))
1417
.allowedMcc(listOf("string"))
1518
.blockedMcc(listOf("string"))
1619
.allowedCountries(listOf("string"))
@@ -26,6 +29,9 @@ class AuthRuleApplyResponseTest {
2629
assertThat(authRuleApplyResponse.data())
2730
.contains(
2831
AuthRule.builder()
32+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
33+
.state(AuthRule.State.ACTIVE)
34+
.previousAuthRuleTokens(listOf("string"))
2935
.allowedMcc(listOf("string"))
3036
.blockedMcc(listOf("string"))
3137
.allowedCountries(listOf("string"))

lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleCreateResponseTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class AuthRuleCreateResponseTest {
1111
AuthRuleCreateResponse.builder()
1212
.data(
1313
AuthRule.builder()
14+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
15+
.state(AuthRule.State.ACTIVE)
16+
.previousAuthRuleTokens(listOf("string"))
1417
.allowedMcc(listOf("string"))
1518
.blockedMcc(listOf("string"))
1619
.allowedCountries(listOf("string"))
@@ -26,6 +29,9 @@ class AuthRuleCreateResponseTest {
2629
assertThat(authRuleCreateResponse.data())
2730
.contains(
2831
AuthRule.builder()
32+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
33+
.state(AuthRule.State.ACTIVE)
34+
.previousAuthRuleTokens(listOf("string"))
2935
.allowedMcc(listOf("string"))
3036
.blockedMcc(listOf("string"))
3137
.allowedCountries(listOf("string"))

lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleRetrieveResponseTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ class AuthRuleRetrieveResponseTest {
1212
.data(
1313
listOf(
1414
AuthRule.builder()
15+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
16+
.state(AuthRule.State.ACTIVE)
17+
.previousAuthRuleTokens(listOf("string"))
1518
.allowedMcc(listOf("string"))
1619
.blockedMcc(listOf("string"))
1720
.allowedCountries(listOf("string"))
@@ -28,6 +31,9 @@ class AuthRuleRetrieveResponseTest {
2831
assertThat(authRuleRetrieveResponse.data().get())
2932
.containsExactly(
3033
AuthRule.builder()
34+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
35+
.state(AuthRule.State.ACTIVE)
36+
.previousAuthRuleTokens(listOf("string"))
3137
.allowedMcc(listOf("string"))
3238
.blockedMcc(listOf("string"))
3339
.allowedCountries(listOf("string"))

lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class AuthRuleTest {
99
fun createAuthRule() {
1010
val authRule =
1111
AuthRule.builder()
12+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
13+
.state(AuthRule.State.ACTIVE)
14+
.previousAuthRuleTokens(listOf("string"))
1215
.allowedMcc(listOf("string"))
1316
.blockedMcc(listOf("string"))
1417
.allowedCountries(listOf("string"))
@@ -19,6 +22,9 @@ class AuthRuleTest {
1922
.programLevel(true)
2023
.build()
2124
assertThat(authRule).isNotNull
25+
assertThat(authRule.token()).contains("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
26+
assertThat(authRule.state()).contains(AuthRule.State.ACTIVE)
27+
assertThat(authRule.previousAuthRuleTokens().get()).containsExactly("string")
2228
assertThat(authRule.allowedMcc().get()).containsExactly("string")
2329
assertThat(authRule.blockedMcc().get()).containsExactly("string")
2430
assertThat(authRule.allowedCountries().get()).containsExactly("string")

lithic-java-core/src/test/kotlin/com/lithic/api/models/AuthRuleUpdateResponseTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class AuthRuleUpdateResponseTest {
1111
AuthRuleUpdateResponse.builder()
1212
.data(
1313
AuthRule.builder()
14+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
15+
.state(AuthRule.State.ACTIVE)
16+
.previousAuthRuleTokens(listOf("string"))
1417
.allowedMcc(listOf("string"))
1518
.blockedMcc(listOf("string"))
1619
.allowedCountries(listOf("string"))
@@ -26,6 +29,9 @@ class AuthRuleUpdateResponseTest {
2629
assertThat(authRuleUpdateResponse.data())
2730
.contains(
2831
AuthRule.builder()
32+
.token("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
33+
.state(AuthRule.State.ACTIVE)
34+
.previousAuthRuleTokens(listOf("string"))
2935
.allowedMcc(listOf("string"))
3036
.blockedMcc(listOf("string"))
3137
.allowedCountries(listOf("string"))

0 commit comments

Comments
 (0)