11package com.lithic.api.models
22
3+ import com.fasterxml.jackson.annotation.JsonCreator
4+ import com.lithic.api.core.JsonField
5+ import com.lithic.api.core.JsonValue
36import com.lithic.api.core.NoAutoDetect
47import com.lithic.api.core.toUnmodifiable
8+ import com.lithic.api.errors.LithicInvalidDataException
59import com.lithic.api.models.*
610import java.time.OffsetDateTime
711import java.util.Objects
@@ -10,6 +14,7 @@ import java.util.Optional
1014class CardListParams
1115constructor (
1216 private val accountToken: String? ,
17+ private val state: State ? ,
1318 private val begin: OffsetDateTime ? ,
1419 private val end: OffsetDateTime ? ,
1520 private val page: Long? ,
@@ -20,6 +25,8 @@ constructor(
2025
2126 fun accountToken (): Optional <String > = Optional .ofNullable(accountToken)
2227
28+ fun state (): Optional <State > = Optional .ofNullable(state)
29+
2330 fun begin (): Optional <OffsetDateTime > = Optional .ofNullable(begin)
2431
2532 fun end (): Optional <OffsetDateTime > = Optional .ofNullable(end)
@@ -32,6 +39,7 @@ constructor(
3239 internal fun getQueryParams (): Map <String , List <String >> {
3340 val params = mutableMapOf<String , List <String >>()
3441 this .accountToken?.let { params.put(" account_token" , listOf (it.toString())) }
42+ this .state?.let { params.put(" state" , listOf (it.toString())) }
3543 this .begin?.let { params.put(" begin" , listOf (it.toString())) }
3644 this .end?.let { params.put(" end" , listOf (it.toString())) }
3745 this .page?.let { params.put(" page" , listOf (it.toString())) }
@@ -53,6 +61,7 @@ constructor(
5361
5462 return other is CardListParams &&
5563 this .accountToken == other.accountToken &&
64+ this .state == other.state &&
5665 this .begin == other.begin &&
5766 this .end == other.end &&
5867 this .page == other.page &&
@@ -64,6 +73,7 @@ constructor(
6473 override fun hashCode (): Int {
6574 return Objects .hash(
6675 accountToken,
76+ state,
6777 begin,
6878 end,
6979 page,
@@ -74,7 +84,7 @@ constructor(
7484 }
7585
7686 override fun toString () =
77- " CardListParams{accountToken=$accountToken , begin=$begin , end=$end , page=$page , pageSize=$pageSize , additionalQueryParams=$additionalQueryParams , additionalHeaders=$additionalHeaders }"
87+ " CardListParams{accountToken=$accountToken , state= $state , begin=$begin , end=$end , page=$page , pageSize=$pageSize , additionalQueryParams=$additionalQueryParams , additionalHeaders=$additionalHeaders }"
7888
7989 fun toBuilder () = Builder ().from(this )
8090
@@ -87,6 +97,7 @@ constructor(
8797 class Builder {
8898
8999 private var accountToken: String? = null
100+ private var state: State ? = null
90101 private var begin: OffsetDateTime ? = null
91102 private var end: OffsetDateTime ? = null
92103 private var page: Long? = null
@@ -97,6 +108,7 @@ constructor(
97108 @JvmSynthetic
98109 internal fun from (cardListParams : CardListParams ) = apply {
99110 this .accountToken = cardListParams.accountToken
111+ this .state = cardListParams.state
100112 this .begin = cardListParams.begin
101113 this .end = cardListParams.end
102114 this .page = cardListParams.page
@@ -108,6 +120,9 @@ constructor(
108120 /* * Returns cards associated with the specified account. */
109121 fun accountToken (accountToken : String ) = apply { this .accountToken = accountToken }
110122
123+ /* * Returns cards with the specified state. */
124+ fun state (state : State ) = apply { this .state = state }
125+
111126 /* *
112127 * Date string in RFC 3339 format. Only entries created after the specified date will be
113128 * included. UTC time zone.
@@ -169,6 +184,7 @@ constructor(
169184 fun build (): CardListParams =
170185 CardListParams (
171186 accountToken,
187+ state,
172188 begin,
173189 end,
174190 page,
@@ -177,4 +193,79 @@ constructor(
177193 additionalHeaders.mapValues { it.value.toUnmodifiable() }.toUnmodifiable(),
178194 )
179195 }
196+
197+ class State
198+ @JsonCreator
199+ private constructor (
200+ private val value: JsonField <String >,
201+ ) {
202+
203+ @com.fasterxml.jackson.annotation.JsonValue fun _value (): JsonField <String > = value
204+
205+ override fun equals (other : Any? ): Boolean {
206+ if (this == = other) {
207+ return true
208+ }
209+
210+ return other is State && this .value == other.value
211+ }
212+
213+ override fun hashCode () = value.hashCode()
214+
215+ override fun toString () = value.toString()
216+
217+ companion object {
218+
219+ @JvmField val OPEN = State (JsonField .of(" OPEN" ))
220+
221+ @JvmField val PAUSED = State (JsonField .of(" PAUSED" ))
222+
223+ @JvmField val CLOSED = State (JsonField .of(" CLOSED" ))
224+
225+ @JvmField val PENDING_FULFILLMENT = State (JsonField .of(" PENDING_FULFILLMENT" ))
226+
227+ @JvmField val PENDING_ACTIVATION = State (JsonField .of(" PENDING_ACTIVATION" ))
228+
229+ @JvmStatic fun of (value : String ) = State (JsonField .of(value))
230+ }
231+
232+ enum class Known {
233+ OPEN ,
234+ PAUSED ,
235+ CLOSED ,
236+ PENDING_FULFILLMENT ,
237+ PENDING_ACTIVATION ,
238+ }
239+
240+ enum class Value {
241+ OPEN ,
242+ PAUSED ,
243+ CLOSED ,
244+ PENDING_FULFILLMENT ,
245+ PENDING_ACTIVATION ,
246+ _UNKNOWN ,
247+ }
248+
249+ fun value (): Value =
250+ when (this ) {
251+ OPEN -> Value .OPEN
252+ PAUSED -> Value .PAUSED
253+ CLOSED -> Value .CLOSED
254+ PENDING_FULFILLMENT -> Value .PENDING_FULFILLMENT
255+ PENDING_ACTIVATION -> Value .PENDING_ACTIVATION
256+ else -> Value ._UNKNOWN
257+ }
258+
259+ fun known (): Known =
260+ when (this ) {
261+ OPEN -> Known .OPEN
262+ PAUSED -> Known .PAUSED
263+ CLOSED -> Known .CLOSED
264+ PENDING_FULFILLMENT -> Known .PENDING_FULFILLMENT
265+ PENDING_ACTIVATION -> Known .PENDING_ACTIVATION
266+ else -> throw LithicInvalidDataException (" Unknown State: $value " )
267+ }
268+
269+ fun asString (): String = _value ().asStringOrThrow()
270+ }
180271}
0 commit comments