Skip to content

Commit 5c574fc

Browse files
feat(api): api update (#341)
1 parent 0b3a2fe commit 5c574fc

3 files changed

Lines changed: 96 additions & 6 deletions

File tree

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

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

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import com.withorb.api.core.NoAutoDetect
66
import com.withorb.api.core.Params
77
import com.withorb.api.core.http.Headers
88
import com.withorb.api.core.http.QueryParams
9+
import java.time.OffsetDateTime
10+
import java.time.format.DateTimeFormatter
911
import java.util.Objects
1012
import java.util.Optional
1113
import kotlin.jvm.optionals.getOrNull
@@ -17,12 +19,24 @@ import kotlin.jvm.optionals.getOrNull
1719
*/
1820
class CreditNoteListParams
1921
private constructor(
22+
private val createdAtGt: OffsetDateTime?,
23+
private val createdAtGte: OffsetDateTime?,
24+
private val createdAtLt: OffsetDateTime?,
25+
private val createdAtLte: OffsetDateTime?,
2026
private val cursor: String?,
2127
private val limit: Long?,
2228
private val additionalHeaders: Headers,
2329
private val additionalQueryParams: QueryParams,
2430
) : Params {
2531

32+
fun createdAtGt(): Optional<OffsetDateTime> = Optional.ofNullable(createdAtGt)
33+
34+
fun createdAtGte(): Optional<OffsetDateTime> = Optional.ofNullable(createdAtGte)
35+
36+
fun createdAtLt(): Optional<OffsetDateTime> = Optional.ofNullable(createdAtLt)
37+
38+
fun createdAtLte(): Optional<OffsetDateTime> = Optional.ofNullable(createdAtLte)
39+
2640
/**
2741
* Cursor for pagination. This can be populated by the `next_cursor` value returned from the
2842
* initial request.
@@ -40,6 +54,30 @@ private constructor(
4054

4155
override fun _queryParams(): QueryParams {
4256
val queryParams = QueryParams.builder()
57+
this.createdAtGt?.let {
58+
queryParams.put(
59+
"created_at[gt]",
60+
listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)),
61+
)
62+
}
63+
this.createdAtGte?.let {
64+
queryParams.put(
65+
"created_at[gte]",
66+
listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)),
67+
)
68+
}
69+
this.createdAtLt?.let {
70+
queryParams.put(
71+
"created_at[lt]",
72+
listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)),
73+
)
74+
}
75+
this.createdAtLte?.let {
76+
queryParams.put(
77+
"created_at[lte]",
78+
listOf(DateTimeFormatter.ISO_OFFSET_DATE_TIME.format(it)),
79+
)
80+
}
4381
this.cursor?.let { queryParams.put("cursor", listOf(it.toString())) }
4482
this.limit?.let { queryParams.put("limit", listOf(it.toString())) }
4583
queryParams.putAll(additionalQueryParams)
@@ -60,19 +98,47 @@ private constructor(
6098
@NoAutoDetect
6199
class Builder internal constructor() {
62100

101+
private var createdAtGt: OffsetDateTime? = null
102+
private var createdAtGte: OffsetDateTime? = null
103+
private var createdAtLt: OffsetDateTime? = null
104+
private var createdAtLte: OffsetDateTime? = null
63105
private var cursor: String? = null
64106
private var limit: Long? = null
65107
private var additionalHeaders: Headers.Builder = Headers.builder()
66108
private var additionalQueryParams: QueryParams.Builder = QueryParams.builder()
67109

68110
@JvmSynthetic
69111
internal fun from(creditNoteListParams: CreditNoteListParams) = apply {
112+
createdAtGt = creditNoteListParams.createdAtGt
113+
createdAtGte = creditNoteListParams.createdAtGte
114+
createdAtLt = creditNoteListParams.createdAtLt
115+
createdAtLte = creditNoteListParams.createdAtLte
70116
cursor = creditNoteListParams.cursor
71117
limit = creditNoteListParams.limit
72118
additionalHeaders = creditNoteListParams.additionalHeaders.toBuilder()
73119
additionalQueryParams = creditNoteListParams.additionalQueryParams.toBuilder()
74120
}
75121

122+
fun createdAtGt(createdAtGt: OffsetDateTime?) = apply { this.createdAtGt = createdAtGt }
123+
124+
fun createdAtGt(createdAtGt: Optional<OffsetDateTime>) =
125+
createdAtGt(createdAtGt.getOrNull())
126+
127+
fun createdAtGte(createdAtGte: OffsetDateTime?) = apply { this.createdAtGte = createdAtGte }
128+
129+
fun createdAtGte(createdAtGte: Optional<OffsetDateTime>) =
130+
createdAtGte(createdAtGte.getOrNull())
131+
132+
fun createdAtLt(createdAtLt: OffsetDateTime?) = apply { this.createdAtLt = createdAtLt }
133+
134+
fun createdAtLt(createdAtLt: Optional<OffsetDateTime>) =
135+
createdAtLt(createdAtLt.getOrNull())
136+
137+
fun createdAtLte(createdAtLte: OffsetDateTime?) = apply { this.createdAtLte = createdAtLte }
138+
139+
fun createdAtLte(createdAtLte: Optional<OffsetDateTime>) =
140+
createdAtLte(createdAtLte.getOrNull())
141+
76142
/**
77143
* Cursor for pagination. This can be populated by the `next_cursor` value returned from the
78144
* initial request.
@@ -194,6 +260,10 @@ private constructor(
194260

195261
fun build(): CreditNoteListParams =
196262
CreditNoteListParams(
263+
createdAtGt,
264+
createdAtGte,
265+
createdAtLt,
266+
createdAtLte,
197267
cursor,
198268
limit,
199269
additionalHeaders.build(),
@@ -206,11 +276,11 @@ private constructor(
206276
return true
207277
}
208278

209-
return /* spotless:off */ other is CreditNoteListParams && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
279+
return /* spotless:off */ other is CreditNoteListParams && createdAtGt == other.createdAtGt && createdAtGte == other.createdAtGte && createdAtLt == other.createdAtLt && createdAtLte == other.createdAtLte && cursor == other.cursor && limit == other.limit && additionalHeaders == other.additionalHeaders && additionalQueryParams == other.additionalQueryParams /* spotless:on */
210280
}
211281

212-
override fun hashCode(): Int = /* spotless:off */ Objects.hash(cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */
282+
override fun hashCode(): Int = /* spotless:off */ Objects.hash(createdAtGt, createdAtGte, createdAtLt, createdAtLte, cursor, limit, additionalHeaders, additionalQueryParams) /* spotless:on */
213283

214284
override fun toString() =
215-
"CreditNoteListParams{cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
285+
"CreditNoteListParams{createdAtGt=$createdAtGt, createdAtGte=$createdAtGte, createdAtLt=$createdAtLt, createdAtLte=$createdAtLte, cursor=$cursor, limit=$limit, additionalHeaders=$additionalHeaders, additionalQueryParams=$additionalQueryParams}"
216286
}

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

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,40 @@
33
package com.withorb.api.models
44

55
import com.withorb.api.core.http.QueryParams
6+
import java.time.OffsetDateTime
67
import org.assertj.core.api.Assertions.assertThat
78
import org.junit.jupiter.api.Test
89

910
class CreditNoteListParamsTest {
1011

1112
@Test
1213
fun create() {
13-
CreditNoteListParams.builder().cursor("cursor").limit(1L).build()
14+
CreditNoteListParams.builder()
15+
.createdAtGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
16+
.createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
17+
.createdAtLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
18+
.createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
19+
.cursor("cursor")
20+
.limit(1L)
21+
.build()
1422
}
1523

1624
@Test
1725
fun queryParams() {
18-
val params = CreditNoteListParams.builder().cursor("cursor").limit(1L).build()
26+
val params =
27+
CreditNoteListParams.builder()
28+
.createdAtGt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
29+
.createdAtGte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
30+
.createdAtLt(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
31+
.createdAtLte(OffsetDateTime.parse("2019-12-27T18:11:19.117Z"))
32+
.cursor("cursor")
33+
.limit(1L)
34+
.build()
1935
val expected = QueryParams.builder()
36+
expected.put("created_at[gt]", "2019-12-27T18:11:19.117Z")
37+
expected.put("created_at[gte]", "2019-12-27T18:11:19.117Z")
38+
expected.put("created_at[lt]", "2019-12-27T18:11:19.117Z")
39+
expected.put("created_at[lte]", "2019-12-27T18:11:19.117Z")
2040
expected.put("cursor", "cursor")
2141
expected.put("limit", "1")
2242
assertThat(params._queryParams()).isEqualTo(expected.build())

0 commit comments

Comments
 (0)