Skip to content

Commit f5c8c0b

Browse files
chore(api): correctly support ExternalCustomerID array filter on Subscriptions.List (#340)
1 parent fb8b1a2 commit f5c8c0b

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
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: 103
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-979330185e8fda7b2bc2440075fe81c66132fc87ff3c548e93dd05db35ba3172.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/orb%2Forb-e3aeba4569f0d304b27804cc2cdd9888f3f58628fe426e206ab49e164e5417bd.yml

orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private constructor(
3535
private val createdAtLte: OffsetDateTime?,
3636
private val cursor: String?,
3737
private val customerId: List<String>?,
38-
private val externalCustomerId: String?,
38+
private val externalCustomerId: List<String>?,
3939
private val limit: Long?,
4040
private val status: Status?,
4141
private val additionalHeaders: Headers,
@@ -58,7 +58,7 @@ private constructor(
5858

5959
fun customerId(): Optional<List<String>> = Optional.ofNullable(customerId)
6060

61-
fun externalCustomerId(): Optional<String> = Optional.ofNullable(externalCustomerId)
61+
fun externalCustomerId(): Optional<List<String>> = Optional.ofNullable(externalCustomerId)
6262

6363
/** The number of items to fetch. Defaults to 20. */
6464
fun limit(): Optional<Long> = Optional.ofNullable(limit)
@@ -100,7 +100,7 @@ private constructor(
100100
this.cursor?.let { queryParams.put("cursor", listOf(it.toString())) }
101101
this.customerId?.let { queryParams.put("customer_id[]", it.map(Any::toString)) }
102102
this.externalCustomerId?.let {
103-
queryParams.put("external_customer_id", listOf(it.toString()))
103+
queryParams.put("external_customer_id[]", it.map(Any::toString))
104104
}
105105
this.limit?.let { queryParams.put("limit", listOf(it.toString())) }
106106
this.status?.let { queryParams.put("status", listOf(it.toString())) }
@@ -128,7 +128,7 @@ private constructor(
128128
private var createdAtLte: OffsetDateTime? = null
129129
private var cursor: String? = null
130130
private var customerId: MutableList<String>? = null
131-
private var externalCustomerId: String? = null
131+
private var externalCustomerId: MutableList<String>? = null
132132
private var limit: Long? = null
133133
private var status: Status? = null
134134
private var additionalHeaders: Headers.Builder = Headers.builder()
@@ -142,7 +142,7 @@ private constructor(
142142
createdAtLte = subscriptionListParams.createdAtLte
143143
cursor = subscriptionListParams.cursor
144144
customerId = subscriptionListParams.customerId?.toMutableList()
145-
externalCustomerId = subscriptionListParams.externalCustomerId
145+
externalCustomerId = subscriptionListParams.externalCustomerId?.toMutableList()
146146
limit = subscriptionListParams.limit
147147
status = subscriptionListParams.status
148148
additionalHeaders = subscriptionListParams.additionalHeaders.toBuilder()
@@ -191,13 +191,18 @@ private constructor(
191191
this.customerId = (this.customerId ?: mutableListOf()).apply { add(customerId) }
192192
}
193193

194-
fun externalCustomerId(externalCustomerId: String?) = apply {
195-
this.externalCustomerId = externalCustomerId
194+
fun externalCustomerId(externalCustomerId: List<String>?) = apply {
195+
this.externalCustomerId = externalCustomerId?.toMutableList()
196196
}
197197

198-
fun externalCustomerId(externalCustomerId: Optional<String>) =
198+
fun externalCustomerId(externalCustomerId: Optional<List<String>>) =
199199
externalCustomerId(externalCustomerId.getOrNull())
200200

201+
fun addExternalCustomerId(externalCustomerId: String) = apply {
202+
this.externalCustomerId =
203+
(this.externalCustomerId ?: mutableListOf()).apply { add(externalCustomerId) }
204+
}
205+
201206
/** The number of items to fetch. Defaults to 20. */
202207
fun limit(limit: Long?) = apply { this.limit = limit }
203208

@@ -317,7 +322,7 @@ private constructor(
317322
createdAtLte,
318323
cursor,
319324
customerId?.toImmutable(),
320-
externalCustomerId,
325+
externalCustomerId?.toImmutable(),
321326
limit,
322327
status,
323328
additionalHeaders.build(),

orb-java-core/src/test/kotlin/com/withorb/api/models/SubscriptionListParamsTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class SubscriptionListParamsTest {
1818
.createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
1919
.cursor("cursor")
2020
.addCustomerId("string")
21-
.externalCustomerId("external_customer_id")
21+
.addExternalCustomerId("string")
2222
.limit(1L)
2323
.status(SubscriptionListParams.Status.ACTIVE)
2424
.build()
@@ -34,7 +34,7 @@ class SubscriptionListParamsTest {
3434
.createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
3535
.cursor("cursor")
3636
.addCustomerId("string")
37-
.externalCustomerId("external_customer_id")
37+
.addExternalCustomerId("string")
3838
.limit(1L)
3939
.status(SubscriptionListParams.Status.ACTIVE)
4040
.build()
@@ -45,7 +45,7 @@ class SubscriptionListParamsTest {
4545
expected.put("created_at[lte]", "2019-12-27T18:11:19.117Z")
4646
expected.put("cursor", "cursor")
4747
expected.put("customer_id[]", "string")
48-
expected.put("external_customer_id", "external_customer_id")
48+
expected.put("external_customer_id[]", "string")
4949
expected.put("limit", "1")
5050
expected.put("status", SubscriptionListParams.Status.ACTIVE.toString())
5151
assertThat(params._queryParams()).isEqualTo(expected.build())

0 commit comments

Comments
 (0)