22
33package com.increase.api.models
44
5+ import com.fasterxml.jackson.annotation.JsonCreator
6+ import com.increase.api.core.Enum
7+ import com.increase.api.core.JsonField
58import com.increase.api.core.NoAutoDetect
69import com.increase.api.core.Params
710import com.increase.api.core.http.Headers
811import com.increase.api.core.http.QueryParams
12+ import com.increase.api.core.toImmutable
13+ import com.increase.api.errors.IncreaseInvalidDataException
914import java.time.OffsetDateTime
1015import java.time.format.DateTimeFormatter
1116import java.util.Objects
@@ -19,6 +24,7 @@ private constructor(
1924 private val cursor: String? ,
2025 private val idempotencyKey: String? ,
2126 private val limit: Long? ,
27+ private val status: Status ? ,
2228 private val additionalHeaders: Headers ,
2329 private val additionalQueryParams: QueryParams ,
2430) : Params {
@@ -41,6 +47,8 @@ private constructor(
4147 /* * Limit the size of the list that is returned. The default (and maximum) is 100 objects. */
4248 fun limit (): Optional <Long > = Optional .ofNullable(limit)
4349
50+ fun status (): Optional <Status > = Optional .ofNullable(status)
51+
4452 fun _additionalHeaders (): Headers = additionalHeaders
4553
4654 fun _additionalQueryParams (): QueryParams = additionalQueryParams
@@ -56,6 +64,7 @@ private constructor(
5664 this .cursor?.let { queryParams.put(" cursor" , listOf (it.toString())) }
5765 this .idempotencyKey?.let { queryParams.put(" idempotency_key" , listOf (it.toString())) }
5866 this .limit?.let { queryParams.put(" limit" , listOf (it.toString())) }
67+ this .status?.forEachQueryParam { key, values -> queryParams.put(" status.$key " , values) }
5968 queryParams.putAll(additionalQueryParams)
6069 return queryParams.build()
6170 }
@@ -78,6 +87,7 @@ private constructor(
7887 private var cursor: String? = null
7988 private var idempotencyKey: String? = null
8089 private var limit: Long? = null
90+ private var status: Status ? = null
8191 private var additionalHeaders: Headers .Builder = Headers .builder()
8292 private var additionalQueryParams: QueryParams .Builder = QueryParams .builder()
8393
@@ -88,6 +98,7 @@ private constructor(
8898 cursor = cardListParams.cursor
8999 idempotencyKey = cardListParams.idempotencyKey
90100 limit = cardListParams.limit
101+ status = cardListParams.status
91102 additionalHeaders = cardListParams.additionalHeaders.toBuilder()
92103 additionalQueryParams = cardListParams.additionalQueryParams.toBuilder()
93104 }
@@ -141,6 +152,10 @@ private constructor(
141152 @Suppress(" USELESS_CAST" ) // See https://youtrack.jetbrains.com/issue/KT-74228
142153 fun limit (limit : Optional <Long >) = limit(limit.orElse(null ) as Long? )
143154
155+ fun status (status : Status ? ) = apply { this .status = status }
156+
157+ fun status (status : Optional <Status >) = status(status.orElse(null ))
158+
144159 fun additionalHeaders (additionalHeaders : Headers ) = apply {
145160 this .additionalHeaders.clear()
146161 putAllAdditionalHeaders(additionalHeaders)
@@ -246,6 +261,7 @@ private constructor(
246261 cursor,
247262 idempotencyKey,
248263 limit,
264+ status,
249265 additionalHeaders.build(),
250266 additionalQueryParams.build(),
251267 )
@@ -446,16 +462,256 @@ private constructor(
446462 " CreatedAt{after=$after , before=$before , onOrAfter=$onOrAfter , onOrBefore=$onOrBefore , additionalProperties=$additionalProperties }"
447463 }
448464
465+ class Status
466+ private constructor (private val in_: List <In >? , private val additionalProperties: QueryParams ) {
467+
468+ /* *
469+ * Filter Cards by status. For GET requests, this should be encoded as a comma-delimited
470+ * string, such as `?in=one,two,three`.
471+ */
472+ fun in_ (): Optional <List <In >> = Optional .ofNullable(in_)
473+
474+ fun _additionalProperties (): QueryParams = additionalProperties
475+
476+ @JvmSynthetic
477+ internal fun forEachQueryParam (putParam : (String , List <String >) -> Unit ) {
478+ this .in_?.let { putParam(" in" , listOf (it.joinToString(separator = " ," ))) }
479+ additionalProperties.keys().forEach { putParam(it, additionalProperties.values(it)) }
480+ }
481+
482+ fun toBuilder () = Builder ().from(this )
483+
484+ companion object {
485+
486+ @JvmStatic fun builder () = Builder ()
487+ }
488+
489+ /* * A builder for [Status]. */
490+ class Builder internal constructor() {
491+
492+ private var in_: MutableList <In >? = null
493+ private var additionalProperties: QueryParams .Builder = QueryParams .builder()
494+
495+ @JvmSynthetic
496+ internal fun from (status : Status ) = apply {
497+ in_ = status.in_?.toMutableList()
498+ additionalProperties = status.additionalProperties.toBuilder()
499+ }
500+
501+ /* *
502+ * Filter Cards by status. For GET requests, this should be encoded as a comma-delimited
503+ * string, such as `?in=one,two,three`.
504+ */
505+ fun in_ (in_ : List <In >? ) = apply { this .in_ = in_?.toMutableList() }
506+
507+ /* *
508+ * Filter Cards by status. For GET requests, this should be encoded as a comma-delimited
509+ * string, such as `?in=one,two,three`.
510+ */
511+ fun in_ (in_ : Optional <List <In >>) = in_(in_.orElse(null ))
512+
513+ /* *
514+ * Filter Cards by status. For GET requests, this should be encoded as a comma-delimited
515+ * string, such as `?in=one,two,three`.
516+ */
517+ fun addIn (in_ : In ) = apply {
518+ this .in_ = (this .in_ ? : mutableListOf ()).apply { add(in_) }
519+ }
520+
521+ fun additionalProperties (additionalProperties : QueryParams ) = apply {
522+ this .additionalProperties.clear()
523+ putAllAdditionalProperties(additionalProperties)
524+ }
525+
526+ fun additionalProperties (additionalProperties : Map <String , Iterable <String >>) = apply {
527+ this .additionalProperties.clear()
528+ putAllAdditionalProperties(additionalProperties)
529+ }
530+
531+ fun putAdditionalProperty (key : String , value : String ) = apply {
532+ additionalProperties.put(key, value)
533+ }
534+
535+ fun putAdditionalProperties (key : String , values : Iterable <String >) = apply {
536+ additionalProperties.put(key, values)
537+ }
538+
539+ fun putAllAdditionalProperties (additionalProperties : QueryParams ) = apply {
540+ this .additionalProperties.putAll(additionalProperties)
541+ }
542+
543+ fun putAllAdditionalProperties (additionalProperties : Map <String , Iterable <String >>) =
544+ apply {
545+ this .additionalProperties.putAll(additionalProperties)
546+ }
547+
548+ fun replaceAdditionalProperties (key : String , value : String ) = apply {
549+ additionalProperties.replace(key, value)
550+ }
551+
552+ fun replaceAdditionalProperties (key : String , values : Iterable <String >) = apply {
553+ additionalProperties.replace(key, values)
554+ }
555+
556+ fun replaceAllAdditionalProperties (additionalProperties : QueryParams ) = apply {
557+ this .additionalProperties.replaceAll(additionalProperties)
558+ }
559+
560+ fun replaceAllAdditionalProperties (
561+ additionalProperties : Map <String , Iterable <String >>
562+ ) = apply { this .additionalProperties.replaceAll(additionalProperties) }
563+
564+ fun removeAdditionalProperties (key : String ) = apply { additionalProperties.remove(key) }
565+
566+ fun removeAllAdditionalProperties (keys : Set <String >) = apply {
567+ additionalProperties.removeAll(keys)
568+ }
569+
570+ fun build (): Status = Status (in_?.toImmutable(), additionalProperties.build())
571+ }
572+
573+ class In @JsonCreator private constructor(private val value : JsonField <String >) : Enum {
574+
575+ /* *
576+ * Returns this class instance's raw value.
577+ *
578+ * This is usually only useful if this instance was deserialized from data that doesn't
579+ * match any known member, and you want to know that value. For example, if the SDK is
580+ * on an older version than the API, then the API may respond with new members that the
581+ * SDK is unaware of.
582+ */
583+ @com.fasterxml.jackson.annotation.JsonValue fun _value (): JsonField <String > = value
584+
585+ companion object {
586+
587+ /* * The card is active. */
588+ @JvmField val ACTIVE = of(" active" )
589+
590+ /* * The card is temporarily disabled. */
591+ @JvmField val DISABLED = of(" disabled" )
592+
593+ /* * The card is permanently canceled. */
594+ @JvmField val CANCELED = of(" canceled" )
595+
596+ @JvmStatic fun of (value : String ) = In (JsonField .of(value))
597+ }
598+
599+ /* * An enum containing [In]'s known values. */
600+ enum class Known {
601+ /* * The card is active. */
602+ ACTIVE ,
603+ /* * The card is temporarily disabled. */
604+ DISABLED ,
605+ /* * The card is permanently canceled. */
606+ CANCELED ,
607+ }
608+
609+ /* *
610+ * An enum containing [In]'s known values, as well as an [_UNKNOWN] member.
611+ *
612+ * An instance of [In] can contain an unknown value in a couple of cases:
613+ * - It was deserialized from data that doesn't match any known member. For example, if
614+ * the SDK is on an older version than the API, then the API may respond with new
615+ * members that the SDK is unaware of.
616+ * - It was constructed with an arbitrary value using the [of] method.
617+ */
618+ enum class Value {
619+ /* * The card is active. */
620+ ACTIVE ,
621+ /* * The card is temporarily disabled. */
622+ DISABLED ,
623+ /* * The card is permanently canceled. */
624+ CANCELED ,
625+ /* * An enum member indicating that [In] was instantiated with an unknown value. */
626+ _UNKNOWN ,
627+ }
628+
629+ /* *
630+ * Returns an enum member corresponding to this class instance's value, or
631+ * [Value._UNKNOWN] if the class was instantiated with an unknown value.
632+ *
633+ * Use the [known] method instead if you're certain the value is always known or if you
634+ * want to throw for the unknown case.
635+ */
636+ fun value (): Value =
637+ when (this ) {
638+ ACTIVE -> Value .ACTIVE
639+ DISABLED -> Value .DISABLED
640+ CANCELED -> Value .CANCELED
641+ else -> Value ._UNKNOWN
642+ }
643+
644+ /* *
645+ * Returns an enum member corresponding to this class instance's value.
646+ *
647+ * Use the [value] method instead if you're uncertain the value is always known and
648+ * don't want to throw for the unknown case.
649+ *
650+ * @throws IncreaseInvalidDataException if this class instance's value is a not a known
651+ * member.
652+ */
653+ fun known (): Known =
654+ when (this ) {
655+ ACTIVE -> Known .ACTIVE
656+ DISABLED -> Known .DISABLED
657+ CANCELED -> Known .CANCELED
658+ else -> throw IncreaseInvalidDataException (" Unknown In: $value " )
659+ }
660+
661+ /* *
662+ * Returns this class instance's primitive wire representation.
663+ *
664+ * This differs from the [toString] method because that method is primarily for
665+ * debugging and generally doesn't throw.
666+ *
667+ * @throws IncreaseInvalidDataException if this class instance's value does not have the
668+ * expected primitive type.
669+ */
670+ fun asString (): String =
671+ _value ().asString().orElseThrow {
672+ IncreaseInvalidDataException (" Value is not a String" )
673+ }
674+
675+ override fun equals (other : Any? ): Boolean {
676+ if (this == = other) {
677+ return true
678+ }
679+
680+ return /* spotless:off */ other is In && value == other.value /* spotless:on */
681+ }
682+
683+ override fun hashCode () = value.hashCode()
684+
685+ override fun toString () = value.toString()
686+ }
687+
688+ override fun equals (other : Any? ): Boolean {
689+ if (this == = other) {
690+ return true
691+ }
692+
693+ return /* spotless:off */ other is Status && in_ == other.in_ && additionalProperties == other.additionalProperties /* spotless:on */
694+ }
695+
696+ /* spotless:off */
697+ private val hashCode: Int by lazy { Objects .hash(in_, additionalProperties) }
698+ /* spotless:on */
699+
700+ override fun hashCode (): Int = hashCode
701+
702+ override fun toString () = " Status{in_=$in_ , additionalProperties=$additionalProperties }"
703+ }
704+
449705 override fun equals (other : Any? ): Boolean {
450706 if (this == = other) {
451707 return true
452708 }
453709
454- return /* spotless:off */ other is CardListParams && accountId == other.accountId && createdAt == other.createdAt && cursor == other.cursor && idempotencyKey == other.idempotencyKey && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
710+ return /* spotless:off */ other is CardListParams && accountId == other.accountId && createdAt == other.createdAt && cursor == other.cursor && idempotencyKey == other.idempotencyKey && limit == other.limit && status == other.status && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
455711 }
456712
457- override fun hashCode (): Int = /* spotless:off */ Objects .hash(accountId, createdAt, cursor, idempotencyKey, limit, additionalHeaders, additionalQueryParams) /* spotless:on */
713+ override fun hashCode (): Int = /* spotless:off */ Objects .hash(accountId, createdAt, cursor, idempotencyKey, limit, status, additionalHeaders, additionalQueryParams) /* spotless:on */
458714
459715 override fun toString () =
460- " CardListParams{accountId=$accountId , createdAt=$createdAt , cursor=$cursor , idempotencyKey=$idempotencyKey , limit=$limit , additionalHeaders=$additionalHeaders , additionalQueryParams=$additionalQueryParams }"
716+ " CardListParams{accountId=$accountId , createdAt=$createdAt , cursor=$cursor , idempotencyKey=$idempotencyKey , limit=$limit , status= $status , additionalHeaders=$additionalHeaders , additionalQueryParams=$additionalQueryParams }"
461717}
0 commit comments