Skip to content

Commit 53e7110

Browse files
author
lithic-sdk-bot[bot]
committed
feat(api): add card_tags filter to list auth rules endpoint
Stainless-Generated-From: d7c8a16d221808fa11379e32135c61a270d4ce01
1 parent 286c4a9 commit 53e7110

3 files changed

Lines changed: 144 additions & 2 deletions

File tree

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

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class AuthRuleV2ListParams
1919
private constructor(
2020
private val accountToken: String?,
2121
private val businessAccountToken: String?,
22+
private val cardTags: CardTags?,
2223
private val cardToken: String?,
2324
private val endingBefore: String?,
2425
private val eventStream: EventStream?,
@@ -36,6 +37,14 @@ private constructor(
3637
/** Only return Auth Rules that are bound to the provided business account token. */
3738
fun businessAccountToken(): Optional<String> = Optional.ofNullable(businessAccountToken)
3839

40+
/**
41+
* Only return Auth Rules that would apply to a card carrying all of these tags, e.g.
42+
* `card_tags[segment]=gold&card_tags[region]=eu`. Returns rules bound to any of the tags and
43+
* leaves out rules that exclude one of them. Each key may be given once, with up to 10 keys.
44+
* Cannot be combined with `card_token`, `account_token` or `business_account_token`.
45+
*/
46+
fun cardTags(): Optional<CardTags> = Optional.ofNullable(cardTags)
47+
3948
/** Only return Auth Rules that are bound to the provided card token. */
4049
fun cardToken(): Optional<String> = Optional.ofNullable(cardToken)
4150

@@ -93,6 +102,7 @@ private constructor(
93102

94103
private var accountToken: String? = null
95104
private var businessAccountToken: String? = null
105+
private var cardTags: CardTags? = null
96106
private var cardToken: String? = null
97107
private var endingBefore: String? = null
98108
private var eventStream: EventStream? = null
@@ -107,6 +117,7 @@ private constructor(
107117
internal fun from(authRuleV2ListParams: AuthRuleV2ListParams) = apply {
108118
accountToken = authRuleV2ListParams.accountToken
109119
businessAccountToken = authRuleV2ListParams.businessAccountToken
120+
cardTags = authRuleV2ListParams.cardTags
110121
cardToken = authRuleV2ListParams.cardToken
111122
endingBefore = authRuleV2ListParams.endingBefore
112123
eventStream = authRuleV2ListParams.eventStream
@@ -136,6 +147,17 @@ private constructor(
136147
fun businessAccountToken(businessAccountToken: Optional<String>) =
137148
businessAccountToken(businessAccountToken.getOrNull())
138149

150+
/**
151+
* Only return Auth Rules that would apply to a card carrying all of these tags, e.g.
152+
* `card_tags[segment]=gold&card_tags[region]=eu`. Returns rules bound to any of the tags
153+
* and leaves out rules that exclude one of them. Each key may be given once, with up to 10
154+
* keys. Cannot be combined with `card_token`, `account_token` or `business_account_token`.
155+
*/
156+
fun cardTags(cardTags: CardTags?) = apply { this.cardTags = cardTags }
157+
158+
/** Alias for calling [Builder.cardTags] with `cardTags.orElse(null)`. */
159+
fun cardTags(cardTags: Optional<CardTags>) = cardTags(cardTags.getOrNull())
160+
139161
/** Only return Auth Rules that are bound to the provided card token. */
140162
fun cardToken(cardToken: String?) = apply { this.cardToken = cardToken }
141163

@@ -320,6 +342,7 @@ private constructor(
320342
AuthRuleV2ListParams(
321343
accountToken,
322344
businessAccountToken,
345+
cardTags,
323346
cardToken,
324347
endingBefore,
325348
eventStream,
@@ -339,6 +362,13 @@ private constructor(
339362
.apply {
340363
accountToken?.let { put("account_token", it) }
341364
businessAccountToken?.let { put("business_account_token", it) }
365+
cardTags?.let {
366+
it._additionalProperties().keys().forEach { key ->
367+
it._additionalProperties().values(key).forEach { value ->
368+
put("card_tags[$key]", value)
369+
}
370+
}
371+
}
342372
cardToken?.let { put("card_token", it) }
343373
endingBefore?.let { put("ending_before", it) }
344374
eventStream?.let { put("event_stream", it.toString()) }
@@ -350,6 +380,107 @@ private constructor(
350380
}
351381
.build()
352382

383+
/**
384+
* Only return Auth Rules that would apply to a card carrying all of these tags, e.g.
385+
* `card_tags[segment]=gold&card_tags[region]=eu`. Returns rules bound to any of the tags and
386+
* leaves out rules that exclude one of them. Each key may be given once, with up to 10 keys.
387+
* Cannot be combined with `card_token`, `account_token` or `business_account_token`.
388+
*/
389+
class CardTags private constructor(private val additionalProperties: QueryParams) {
390+
391+
/** Query params to send with the request. */
392+
fun _additionalProperties(): QueryParams = additionalProperties
393+
394+
fun toBuilder() = Builder().from(this)
395+
396+
companion object {
397+
398+
/** Returns a mutable builder for constructing an instance of [CardTags]. */
399+
@JvmStatic fun builder() = Builder()
400+
}
401+
402+
/** A builder for [CardTags]. */
403+
class Builder internal constructor() {
404+
405+
private var additionalProperties: QueryParams.Builder = QueryParams.builder()
406+
407+
@JvmSynthetic
408+
internal fun from(cardTags: CardTags) = apply {
409+
additionalProperties = cardTags.additionalProperties.toBuilder()
410+
}
411+
412+
fun additionalProperties(additionalProperties: QueryParams) = apply {
413+
this.additionalProperties.clear()
414+
putAllAdditionalProperties(additionalProperties)
415+
}
416+
417+
fun additionalProperties(additionalProperties: Map<String, Iterable<String>>) = apply {
418+
this.additionalProperties.clear()
419+
putAllAdditionalProperties(additionalProperties)
420+
}
421+
422+
fun putAdditionalProperty(key: String, value: String) = apply {
423+
additionalProperties.put(key, value)
424+
}
425+
426+
fun putAdditionalProperties(key: String, values: Iterable<String>) = apply {
427+
additionalProperties.put(key, values)
428+
}
429+
430+
fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply {
431+
this.additionalProperties.putAll(additionalProperties)
432+
}
433+
434+
fun putAllAdditionalProperties(additionalProperties: Map<String, Iterable<String>>) =
435+
apply {
436+
this.additionalProperties.putAll(additionalProperties)
437+
}
438+
439+
fun replaceAdditionalProperties(key: String, value: String) = apply {
440+
additionalProperties.replace(key, value)
441+
}
442+
443+
fun replaceAdditionalProperties(key: String, values: Iterable<String>) = apply {
444+
additionalProperties.replace(key, values)
445+
}
446+
447+
fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply {
448+
this.additionalProperties.replaceAll(additionalProperties)
449+
}
450+
451+
fun replaceAllAdditionalProperties(
452+
additionalProperties: Map<String, Iterable<String>>
453+
) = apply { this.additionalProperties.replaceAll(additionalProperties) }
454+
455+
fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) }
456+
457+
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
458+
additionalProperties.removeAll(keys)
459+
}
460+
461+
/**
462+
* Returns an immutable instance of [CardTags].
463+
*
464+
* Further updates to this [Builder] will not mutate the returned instance.
465+
*/
466+
fun build(): CardTags = CardTags(additionalProperties.build())
467+
}
468+
469+
override fun equals(other: Any?): Boolean {
470+
if (this === other) {
471+
return true
472+
}
473+
474+
return other is CardTags && additionalProperties == other.additionalProperties
475+
}
476+
477+
private val hashCode: Int by lazy { Objects.hash(additionalProperties) }
478+
479+
override fun hashCode(): Int = hashCode
480+
481+
override fun toString() = "CardTags{additionalProperties=$additionalProperties}"
482+
}
483+
353484
/**
354485
* Only return Auth Rules that are bound to the provided scope. When no token is provided,
355486
* `CARD` also returns Auth Rules that include a `CARD_TAG` entity.
@@ -514,6 +645,7 @@ private constructor(
514645
return other is AuthRuleV2ListParams &&
515646
accountToken == other.accountToken &&
516647
businessAccountToken == other.businessAccountToken &&
648+
cardTags == other.cardTags &&
517649
cardToken == other.cardToken &&
518650
endingBefore == other.endingBefore &&
519651
eventStream == other.eventStream &&
@@ -529,6 +661,7 @@ private constructor(
529661
Objects.hash(
530662
accountToken,
531663
businessAccountToken,
664+
cardTags,
532665
cardToken,
533666
endingBefore,
534667
eventStream,
@@ -541,5 +674,5 @@ private constructor(
541674
)
542675

543676
override fun toString() =
544-
"AuthRuleV2ListParams{accountToken=$accountToken, businessAccountToken=$businessAccountToken, cardToken=$cardToken, endingBefore=$endingBefore, eventStream=$eventStream, eventStreams=$eventStreams, pageSize=$pageSize, scope=$scope, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
677+
"AuthRuleV2ListParams{accountToken=$accountToken, businessAccountToken=$businessAccountToken, cardTags=$cardTags, cardToken=$cardToken, endingBefore=$endingBefore, eventStream=$eventStream, eventStreams=$eventStreams, pageSize=$pageSize, scope=$scope, startingAfter=$startingAfter, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
545678
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ internal class AuthRuleV2ListParamsTest {
1313
AuthRuleV2ListParams.builder()
1414
.accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
1515
.businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
16+
.cardTags(
17+
AuthRuleV2ListParams.CardTags.builder().putAdditionalProperty("foo", "x").build()
18+
)
1619
.cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
1720
.endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
1821
.eventStream(EventStream.AUTHORIZATION)
@@ -29,6 +32,11 @@ internal class AuthRuleV2ListParamsTest {
2932
AuthRuleV2ListParams.builder()
3033
.accountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
3134
.businessAccountToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
35+
.cardTags(
36+
AuthRuleV2ListParams.CardTags.builder()
37+
.putAdditionalProperty("foo", "x")
38+
.build()
39+
)
3240
.cardToken("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
3341
.endingBefore("182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
3442
.eventStream(EventStream.AUTHORIZATION)
@@ -45,6 +53,7 @@ internal class AuthRuleV2ListParamsTest {
4553
QueryParams.builder()
4654
.put("account_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
4755
.put("business_account_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
56+
.put("card_tags[foo]", "x")
4857
.put("card_token", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
4958
.put("ending_before", "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e")
5059
.put("event_stream", "AUTHORIZATION")

‎scripts/mock‎

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)