Skip to content

Commit 376bfe7

Browse files
feat(api): api update (#815)
1 parent af07cb5 commit 376bfe7

File tree

3 files changed

+218
-87
lines changed

3 files changed

+218
-87
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 201
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-d4eedf5add319b076d462be8b764246f0c3251ff60708906a90494e05ed8e93c.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/increase%2Fincrease-a39e9d1d0001ea729c1ee2e06ac456278e4fc9064790da323630e54ab02bf056.yml

increase-java-core/src/main/kotlin/com/increase/api/models/AccountListParams.kt

Lines changed: 205 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import com.increase.api.core.NoAutoDetect
99
import com.increase.api.core.Params
1010
import com.increase.api.core.http.Headers
1111
import com.increase.api.core.http.QueryParams
12+
import com.increase.api.core.toImmutable
1213
import com.increase.api.errors.IncreaseInvalidDataException
1314
import java.time.OffsetDateTime
1415
import java.time.format.DateTimeFormatter
@@ -54,7 +55,6 @@ private constructor(
5455
/** Filter Accounts for those in a specific Program. */
5556
fun programId(): Optional<String> = Optional.ofNullable(programId)
5657

57-
/** Filter Accounts for those with the specified status. */
5858
fun status(): Optional<Status> = Optional.ofNullable(status)
5959

6060
fun _additionalHeaders(): Headers = additionalHeaders
@@ -76,7 +76,7 @@ private constructor(
7676
}
7777
this.limit?.let { queryParams.put("limit", listOf(it.toString())) }
7878
this.programId?.let { queryParams.put("program_id", listOf(it.toString())) }
79-
this.status?.let { queryParams.put("status", listOf(it.toString())) }
79+
this.status?.forEachQueryParam { key, values -> queryParams.put("status.$key", values) }
8080
queryParams.putAll(additionalQueryParams)
8181
return queryParams.build()
8282
}
@@ -183,10 +183,8 @@ private constructor(
183183
/** Filter Accounts for those in a specific Program. */
184184
fun programId(programId: Optional<String>) = programId(programId.orElse(null))
185185

186-
/** Filter Accounts for those with the specified status. */
187186
fun status(status: Status?) = apply { this.status = status }
188187

189-
/** Filter Accounts for those with the specified status. */
190188
fun status(status: Optional<Status>) = status(status.orElse(null))
191189

192190
fun additionalHeaders(additionalHeaders: Headers) = apply {
@@ -497,111 +495,235 @@ private constructor(
497495
"CreatedAt{after=$after, before=$before, onOrAfter=$onOrAfter, onOrBefore=$onOrBefore, additionalProperties=$additionalProperties}"
498496
}
499497

500-
/** Filter Accounts for those with the specified status. */
501-
class Status @JsonCreator private constructor(private val value: JsonField<String>) : Enum {
498+
class Status
499+
private constructor(private val in_: List<In>?, private val additionalProperties: QueryParams) {
502500

503501
/**
504-
* Returns this class instance's raw value.
505-
*
506-
* This is usually only useful if this instance was deserialized from data that doesn't
507-
* match any known member, and you want to know that value. For example, if the SDK is on an
508-
* older version than the API, then the API may respond with new members that the SDK is
509-
* unaware of.
502+
* Filter Accounts for those with the specified status. For GET requests, this should be
503+
* encoded as a comma-delimited string, such as `?in=one,two,three`.
510504
*/
511-
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
505+
fun in_(): Optional<List<In>> = Optional.ofNullable(in_)
512506

513-
companion object {
507+
fun _additionalProperties(): QueryParams = additionalProperties
514508

515-
/** Closed Accounts on which no new activity can occur. */
516-
@JvmField val CLOSED = of("closed")
509+
@JvmSynthetic
510+
internal fun forEachQueryParam(putParam: (String, List<String>) -> Unit) {
511+
this.in_?.let { putParam("in", listOf(it.joinToString(separator = ","))) }
512+
additionalProperties.keys().forEach { putParam(it, additionalProperties.values(it)) }
513+
}
517514

518-
/** Open Accounts that are ready to use. */
519-
@JvmField val OPEN = of("open")
515+
fun toBuilder() = Builder().from(this)
520516

521-
@JvmStatic fun of(value: String) = Status(JsonField.of(value))
522-
}
517+
companion object {
523518

524-
/** An enum containing [Status]'s known values. */
525-
enum class Known {
526-
/** Closed Accounts on which no new activity can occur. */
527-
CLOSED,
528-
/** Open Accounts that are ready to use. */
529-
OPEN,
519+
@JvmStatic fun builder() = Builder()
530520
}
531521

532-
/**
533-
* An enum containing [Status]'s known values, as well as an [_UNKNOWN] member.
534-
*
535-
* An instance of [Status] can contain an unknown value in a couple of cases:
536-
* - It was deserialized from data that doesn't match any known member. For example, if the
537-
* SDK is on an older version than the API, then the API may respond with new members that
538-
* the SDK is unaware of.
539-
* - It was constructed with an arbitrary value using the [of] method.
540-
*/
541-
enum class Value {
542-
/** Closed Accounts on which no new activity can occur. */
543-
CLOSED,
544-
/** Open Accounts that are ready to use. */
545-
OPEN,
546-
/** An enum member indicating that [Status] was instantiated with an unknown value. */
547-
_UNKNOWN,
522+
/** A builder for [Status]. */
523+
class Builder internal constructor() {
524+
525+
private var in_: MutableList<In>? = null
526+
private var additionalProperties: QueryParams.Builder = QueryParams.builder()
527+
528+
@JvmSynthetic
529+
internal fun from(status: Status) = apply {
530+
in_ = status.in_?.toMutableList()
531+
additionalProperties = status.additionalProperties.toBuilder()
532+
}
533+
534+
/**
535+
* Filter Accounts for those with the specified status. For GET requests, this should be
536+
* encoded as a comma-delimited string, such as `?in=one,two,three`.
537+
*/
538+
fun in_(in_: List<In>?) = apply { this.in_ = in_?.toMutableList() }
539+
540+
/**
541+
* Filter Accounts for those with the specified status. For GET requests, this should be
542+
* encoded as a comma-delimited string, such as `?in=one,two,three`.
543+
*/
544+
fun in_(in_: Optional<List<In>>) = in_(in_.orElse(null))
545+
546+
/**
547+
* Filter Accounts for those with the specified status. For GET requests, this should be
548+
* encoded as a comma-delimited string, such as `?in=one,two,three`.
549+
*/
550+
fun addIn(in_: In) = apply {
551+
this.in_ = (this.in_ ?: mutableListOf()).apply { add(in_) }
552+
}
553+
554+
fun additionalProperties(additionalProperties: QueryParams) = apply {
555+
this.additionalProperties.clear()
556+
putAllAdditionalProperties(additionalProperties)
557+
}
558+
559+
fun additionalProperties(additionalProperties: Map<String, Iterable<String>>) = apply {
560+
this.additionalProperties.clear()
561+
putAllAdditionalProperties(additionalProperties)
562+
}
563+
564+
fun putAdditionalProperty(key: String, value: String) = apply {
565+
additionalProperties.put(key, value)
566+
}
567+
568+
fun putAdditionalProperties(key: String, values: Iterable<String>) = apply {
569+
additionalProperties.put(key, values)
570+
}
571+
572+
fun putAllAdditionalProperties(additionalProperties: QueryParams) = apply {
573+
this.additionalProperties.putAll(additionalProperties)
574+
}
575+
576+
fun putAllAdditionalProperties(additionalProperties: Map<String, Iterable<String>>) =
577+
apply {
578+
this.additionalProperties.putAll(additionalProperties)
579+
}
580+
581+
fun replaceAdditionalProperties(key: String, value: String) = apply {
582+
additionalProperties.replace(key, value)
583+
}
584+
585+
fun replaceAdditionalProperties(key: String, values: Iterable<String>) = apply {
586+
additionalProperties.replace(key, values)
587+
}
588+
589+
fun replaceAllAdditionalProperties(additionalProperties: QueryParams) = apply {
590+
this.additionalProperties.replaceAll(additionalProperties)
591+
}
592+
593+
fun replaceAllAdditionalProperties(
594+
additionalProperties: Map<String, Iterable<String>>
595+
) = apply { this.additionalProperties.replaceAll(additionalProperties) }
596+
597+
fun removeAdditionalProperties(key: String) = apply { additionalProperties.remove(key) }
598+
599+
fun removeAllAdditionalProperties(keys: Set<String>) = apply {
600+
additionalProperties.removeAll(keys)
601+
}
602+
603+
fun build(): Status = Status(in_?.toImmutable(), additionalProperties.build())
548604
}
549605

550-
/**
551-
* Returns an enum member corresponding to this class instance's value, or [Value._UNKNOWN]
552-
* if the class was instantiated with an unknown value.
553-
*
554-
* Use the [known] method instead if you're certain the value is always known or if you want
555-
* to throw for the unknown case.
556-
*/
557-
fun value(): Value =
558-
when (this) {
559-
CLOSED -> Value.CLOSED
560-
OPEN -> Value.OPEN
561-
else -> Value._UNKNOWN
606+
class In @JsonCreator private constructor(private val value: JsonField<String>) : Enum {
607+
608+
/**
609+
* Returns this class instance's raw value.
610+
*
611+
* This is usually only useful if this instance was deserialized from data that doesn't
612+
* match any known member, and you want to know that value. For example, if the SDK is
613+
* on an older version than the API, then the API may respond with new members that the
614+
* SDK is unaware of.
615+
*/
616+
@com.fasterxml.jackson.annotation.JsonValue fun _value(): JsonField<String> = value
617+
618+
companion object {
619+
620+
/** Closed Accounts on which no new activity can occur. */
621+
@JvmField val CLOSED = of("closed")
622+
623+
/** Open Accounts that are ready to use. */
624+
@JvmField val OPEN = of("open")
625+
626+
@JvmStatic fun of(value: String) = In(JsonField.of(value))
562627
}
563628

564-
/**
565-
* Returns an enum member corresponding to this class instance's value.
566-
*
567-
* Use the [value] method instead if you're uncertain the value is always known and don't
568-
* want to throw for the unknown case.
569-
*
570-
* @throws IncreaseInvalidDataException if this class instance's value is a not a known
571-
* member.
572-
*/
573-
fun known(): Known =
574-
when (this) {
575-
CLOSED -> Known.CLOSED
576-
OPEN -> Known.OPEN
577-
else -> throw IncreaseInvalidDataException("Unknown Status: $value")
629+
/** An enum containing [In]'s known values. */
630+
enum class Known {
631+
/** Closed Accounts on which no new activity can occur. */
632+
CLOSED,
633+
/** Open Accounts that are ready to use. */
634+
OPEN,
578635
}
579636

580-
/**
581-
* Returns this class instance's primitive wire representation.
582-
*
583-
* This differs from the [toString] method because that method is primarily for debugging
584-
* and generally doesn't throw.
585-
*
586-
* @throws IncreaseInvalidDataException if this class instance's value does not have the
587-
* expected primitive type.
588-
*/
589-
fun asString(): String =
590-
_value().asString().orElseThrow {
591-
IncreaseInvalidDataException("Value is not a String")
637+
/**
638+
* An enum containing [In]'s known values, as well as an [_UNKNOWN] member.
639+
*
640+
* An instance of [In] can contain an unknown value in a couple of cases:
641+
* - It was deserialized from data that doesn't match any known member. For example, if
642+
* the SDK is on an older version than the API, then the API may respond with new
643+
* members that the SDK is unaware of.
644+
* - It was constructed with an arbitrary value using the [of] method.
645+
*/
646+
enum class Value {
647+
/** Closed Accounts on which no new activity can occur. */
648+
CLOSED,
649+
/** Open Accounts that are ready to use. */
650+
OPEN,
651+
/** An enum member indicating that [In] was instantiated with an unknown value. */
652+
_UNKNOWN,
592653
}
593654

655+
/**
656+
* Returns an enum member corresponding to this class instance's value, or
657+
* [Value._UNKNOWN] if the class was instantiated with an unknown value.
658+
*
659+
* Use the [known] method instead if you're certain the value is always known or if you
660+
* want to throw for the unknown case.
661+
*/
662+
fun value(): Value =
663+
when (this) {
664+
CLOSED -> Value.CLOSED
665+
OPEN -> Value.OPEN
666+
else -> Value._UNKNOWN
667+
}
668+
669+
/**
670+
* Returns an enum member corresponding to this class instance's value.
671+
*
672+
* Use the [value] method instead if you're uncertain the value is always known and
673+
* don't want to throw for the unknown case.
674+
*
675+
* @throws IncreaseInvalidDataException if this class instance's value is a not a known
676+
* member.
677+
*/
678+
fun known(): Known =
679+
when (this) {
680+
CLOSED -> Known.CLOSED
681+
OPEN -> Known.OPEN
682+
else -> throw IncreaseInvalidDataException("Unknown In: $value")
683+
}
684+
685+
/**
686+
* Returns this class instance's primitive wire representation.
687+
*
688+
* This differs from the [toString] method because that method is primarily for
689+
* debugging and generally doesn't throw.
690+
*
691+
* @throws IncreaseInvalidDataException if this class instance's value does not have the
692+
* expected primitive type.
693+
*/
694+
fun asString(): String =
695+
_value().asString().orElseThrow {
696+
IncreaseInvalidDataException("Value is not a String")
697+
}
698+
699+
override fun equals(other: Any?): Boolean {
700+
if (this === other) {
701+
return true
702+
}
703+
704+
return /* spotless:off */ other is In && value == other.value /* spotless:on */
705+
}
706+
707+
override fun hashCode() = value.hashCode()
708+
709+
override fun toString() = value.toString()
710+
}
711+
594712
override fun equals(other: Any?): Boolean {
595713
if (this === other) {
596714
return true
597715
}
598716

599-
return /* spotless:off */ other is Status && value == other.value /* spotless:on */
717+
return /* spotless:off */ other is Status && in_ == other.in_ && additionalProperties == other.additionalProperties /* spotless:on */
600718
}
601719

602-
override fun hashCode() = value.hashCode()
720+
/* spotless:off */
721+
private val hashCode: Int by lazy { Objects.hash(in_, additionalProperties) }
722+
/* spotless:on */
723+
724+
override fun hashCode(): Int = hashCode
603725

604-
override fun toString() = value.toString()
726+
override fun toString() = "Status{in_=$in_, additionalProperties=$additionalProperties}"
605727
}
606728

607729
override fun equals(other: Any?): Boolean {

increase-java-core/src/test/kotlin/com/increase/api/models/AccountListParamsTest.kt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ class AccountListParamsTest {
2626
.informationalEntityId("informational_entity_id")
2727
.limit(1L)
2828
.programId("program_id")
29-
.status(AccountListParams.Status.CLOSED)
29+
.status(
30+
AccountListParams.Status.builder().addIn(AccountListParams.Status.In.CLOSED).build()
31+
)
3032
.build()
3133
}
3234

@@ -48,7 +50,11 @@ class AccountListParamsTest {
4850
.informationalEntityId("informational_entity_id")
4951
.limit(1L)
5052
.programId("program_id")
51-
.status(AccountListParams.Status.CLOSED)
53+
.status(
54+
AccountListParams.Status.builder()
55+
.addIn(AccountListParams.Status.In.CLOSED)
56+
.build()
57+
)
5258
.build()
5359
val expected = QueryParams.builder()
5460
AccountListParams.CreatedAt.builder()
@@ -64,7 +70,10 @@ class AccountListParamsTest {
6470
expected.put("informational_entity_id", "informational_entity_id")
6571
expected.put("limit", "1")
6672
expected.put("program_id", "program_id")
67-
expected.put("status", AccountListParams.Status.CLOSED.toString())
73+
AccountListParams.Status.builder()
74+
.addIn(AccountListParams.Status.In.CLOSED)
75+
.build()
76+
.forEachQueryParam { key, values -> expected.put("status.$key", values) }
6877
assertThat(params._queryParams()).isEqualTo(expected.build())
6978
}
7079

0 commit comments

Comments
 (0)