Skip to content

Commit 2dc19a9

Browse files
authored
kotlin: Replace most query param classes with generated ones (#1587)
… and clean up the remaining ones to prepare for future replacement. Also leave the default for the `limit` on pagination APIs up to the server. I don't think we need to mention this in the changelog since so far the default has been the same as on the server side; however if we were to change the limit for some API on the server side, it makes much more sense to me that the new default would apply immediately and for everyone who doesn't specify it, rather than requiring a libs update for Kotlin users. Part of svix/monorepo-private#9576.
2 parents 7c18815 + 78eba9e commit 2dc19a9

File tree

10 files changed

+96
-51
lines changed

10 files changed

+96
-51
lines changed

ChangeLog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@
99
`MessageAttempt.listAttemptedDestinations` ([#1571])
1010
* Libs/JavaScript **(Breaking)**: Rename `EndpointStatsOptions` interface to
1111
`EndpointGetStatsOptions` ([#1585])
12+
* Libs/Kotlin **(Breaking)**: Remove `ListOptions` class. Usage of classes that were inheriting
13+
from it should not change though ([#1587])
1214
* Libs/Rust: Add `api::Authentication::expire_all` ([#1584])
1315
* Libs/Rust: Rename some `Options` types. The old names remain as deprecated type aliases ([#1584])
1416

1517
[#1568]: https://github.com/svix/svix-webhooks/pull/1568
1618
[#1571]: https://github.com/svix/svix-webhooks/pull/1571
1719
[#1584]: https://github.com/svix/svix-webhooks/pull/1584
1820
[#1585]: https://github.com/svix/svix-webhooks/pull/1585
21+
[#1587]: https://github.com/svix/svix-webhooks/pull/1587
1922

2023
## Version 1.44.0
2124
* Libs/JavaScript: Revert packaging-related change because it broke for some users ([#1556])

kotlin/lib/src/main/kotlin/Application.kt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,19 @@ import com.svix.kotlin.models.ApplicationPatch
88
import com.svix.kotlin.models.ListResponseApplicationOut
99
import com.svix.kotlin.models.Ordering
1010

11-
class ApplicationListOptions : ListOptions() {
11+
class ApplicationListOptions {
12+
var limit: Int? = null
13+
var iterator: String? = null
1214
var order: Ordering? = null
1315

14-
fun order(order: Ordering) = apply { this.order = order }
16+
/** Limit the number of returned items */
17+
fun limit(limit: Int) = apply { this.limit = limit }
1518

16-
override fun iterator(iterator: String): ApplicationListOptions = apply {
17-
super.iterator(iterator)
18-
}
19+
/** The iterator returned from a prior invocation */
20+
fun iterator(iterator: String) = apply { this.iterator = iterator }
1921

20-
override fun limit(limit: Int) = apply { super.limit(limit) }
22+
/** The sorting order of the returned items */
23+
fun order(order: Ordering) = apply { this.order = order }
2124
}
2225

2326
class Application internal constructor(token: String, options: SvixOptions) {

kotlin/lib/src/main/kotlin/BackgroundTask.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ import com.svix.kotlin.models.BackgroundTaskType
88
import com.svix.kotlin.models.ListResponseBackgroundTaskOut
99
import com.svix.kotlin.models.Ordering
1010

11-
class BackgroundTaskListOptions : ListOptions() {
11+
class BackgroundTaskListOptions {
12+
var iterator: String? = null
13+
var limit: Int? = null
1214
var status: BackgroundTaskStatus? = null
1315
var task: BackgroundTaskType? = null
1416
var order: Ordering? = null
@@ -19,9 +21,9 @@ class BackgroundTaskListOptions : ListOptions() {
1921

2022
fun task(task: BackgroundTaskType) = apply { this.task = task }
2123

22-
override fun iterator(iterator: String) = apply { super.iterator(iterator) }
24+
fun iterator(iterator: String) = apply { this.iterator = iterator }
2325

24-
override fun limit(limit: Int) = apply { super.limit(limit) }
26+
fun limit(limit: Int) = apply { this.limit = limit }
2527
}
2628

2729
class BackgroundTask internal constructor(token: String, options: SvixOptions) {

kotlin/lib/src/main/kotlin/Endpoint.kt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,30 @@ import com.svix.kotlin.models.RecoverIn
2121
import com.svix.kotlin.models.ReplayIn
2222
import java.time.OffsetDateTime
2323

24-
class EndpointListOptions : ListOptions() {
24+
class EndpointListOptions {
25+
var limit: Int? = null
26+
var iterator: String? = null
2527
var order: Ordering? = null
2628

27-
fun order(order: Ordering) = apply { this.order = order }
29+
/** Limit the number of returned items */
30+
fun limit(limit: Int) = apply { this.limit = limit }
2831

29-
override fun iterator(iterator: String) = apply { super.iterator(iterator) }
32+
/** The iterator returned from a prior invocation */
33+
fun iterator(iterator: String) = apply { this.iterator = iterator }
3034

31-
override fun limit(limit: Int) = apply { super.limit(limit) }
35+
/** The sorting order of the returned items */
36+
fun order(order: Ordering) = apply { this.order = order }
3237
}
3338

34-
class EndpointStatsOptions {
39+
class EndpointGetStatsOptions {
3540
var since: OffsetDateTime? = null
3641
var until: OffsetDateTime? = null
42+
43+
/** Filter the range to data starting from this date. */
44+
fun since(since: OffsetDateTime) = apply { this.since = since }
45+
46+
/** Filter the range to data ending by this date. */
47+
fun until(until: OffsetDateTime) = apply { this.until = until }
3748
}
3849

3950
class Endpoint internal constructor(token: String, options: SvixOptions) {
@@ -183,7 +194,7 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
183194
suspend fun getStats(
184195
appId: String,
185196
endpointId: String,
186-
options: EndpointStatsOptions = EndpointStatsOptions(),
197+
options: EndpointGetStatsOptions = EndpointGetStatsOptions(),
187198
): EndpointStats {
188199
try {
189200
return api.v1EndpointGetStats(appId, endpointId, options.since, options.until)

kotlin/lib/src/main/kotlin/EventType.kt

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,32 @@ import com.svix.kotlin.models.EventTypeOut
99
import com.svix.kotlin.models.EventTypePatch
1010
import com.svix.kotlin.models.EventTypeUpdate
1111
import com.svix.kotlin.models.ListResponseEventTypeOut
12+
import com.svix.kotlin.models.Ordering
1213

13-
class EventTypeListOptions() : ListOptions() {
14+
class EventTypeListOptions {
15+
var limit: Int? = null
16+
var iterator: String? = null
17+
var order: Ordering? = null
18+
var includeArchived: Boolean? = null
1419
var withContent: Boolean? = null
15-
var includeAchived: Boolean? = null
1620

17-
fun withContent(withContent: Boolean) = apply { this.withContent = withContent }
21+
/** Limit the number of returned items */
22+
fun limit(limit: Int) = apply { this.limit = limit }
23+
24+
/** The iterator returned from a prior invocation */
25+
fun iterator(iterator: String) = apply { this.iterator = iterator }
1826

19-
fun includeAchived(includeAchived: Boolean) = apply { this.includeAchived = includeAchived }
27+
/** The sorting order of the returned items */
28+
fun order(order: Ordering) = apply { this.order = order }
2029

21-
override fun iterator(iterator: String) = apply { super.iterator(iterator) }
30+
/** When `true` archived (deleted but not expunged) items are included in the response. */
31+
fun includeArchived(includeArchived: Boolean) = apply { this.includeArchived = includeArchived }
2232

23-
override fun limit(limit: Int) = apply { super.limit(limit) }
33+
@Deprecated("Use the new includeArchived() method")
34+
fun includeAchived(includeArchived: Boolean) = apply { this.includeArchived = includeArchived }
35+
36+
/** When `true` the full item (including the schema) is included in the response. */
37+
fun withContent(withContent: Boolean) = apply { this.withContent = withContent }
2438
}
2539

2640
class EventType internal constructor(token: String, options: SvixOptions) {
@@ -41,7 +55,7 @@ class EventType internal constructor(token: String, options: SvixOptions) {
4155
options.limit,
4256
options.iterator,
4357
null,
44-
options.includeAchived,
58+
options.includeArchived,
4559
options.withContent,
4660
)
4761
} catch (e: Exception) {

kotlin/lib/src/main/kotlin/Integration.kt

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@ import com.svix.kotlin.models.IntegrationUpdate
99
import com.svix.kotlin.models.ListResponseIntegrationOut
1010
import com.svix.kotlin.models.Ordering
1111

12-
class IntegrationListOptions : ListOptions() {
12+
class IntegrationListOptions {
13+
var limit: Int? = null
14+
var iterator: String? = null
1315
var order: Ordering? = null
1416

15-
override fun iterator(iterator: String) = apply { super.iterator(iterator) }
17+
/** Limit the number of returned items */
18+
fun limit(limit: Int) = apply { this.limit = limit }
1619

17-
override fun limit(limit: Int) = apply { super.limit(limit) }
20+
/** The iterator returned from a prior invocation */
21+
fun iterator(iterator: String) = apply { this.iterator = iterator }
1822

23+
/** The sorting order of the returned items */
1924
fun order(order: Ordering) = apply { this.order = order }
2025
}
2126

kotlin/lib/src/main/kotlin/ListOptions.kt

Lines changed: 0 additions & 10 deletions
This file was deleted.

kotlin/lib/src/main/kotlin/Message.kt

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,39 @@ import com.svix.kotlin.models.MessageIn
88
import com.svix.kotlin.models.MessageOut
99
import java.time.OffsetDateTime
1010

11-
class MessageListOptions : ListOptions() {
12-
var eventTypes: List<String>? = null
11+
class MessageListOptions {
12+
var limit: Int? = null
13+
var iterator: String? = null
14+
var channel: String? = null
1315
var before: OffsetDateTime? = null
1416
var after: OffsetDateTime? = null
15-
var channel: String? = null
1617
var withContent: Boolean? = null
1718
var tag: String? = null
19+
var eventTypes: List<String>? = null
1820

19-
fun eventTypes(eventTypes: List<String>) = apply { this.eventTypes = eventTypes }
20-
21-
fun before(before: OffsetDateTime) = apply { this.before = before }
21+
/** Limit the number of returned items */
22+
fun limit(limit: Int) = apply { this.limit = limit }
2223

23-
fun after(after: OffsetDateTime) = apply { this.after = after }
24+
/** The iterator returned from a prior invocation */
25+
fun iterator(iterator: String) = apply { this.iterator = iterator }
2426

27+
/** Filter response based on the channel. */
2528
fun channel(channel: String) = apply { this.channel = channel }
2629

27-
override fun iterator(iterator: String) = apply { super.iterator(iterator) }
30+
/** Only include items created before a certain date. */
31+
fun before(before: OffsetDateTime) = apply { this.before = before }
2832

29-
override fun limit(limit: Int) = apply { super.limit(limit) }
33+
/** Only include items created after a certain date. */
34+
fun after(after: OffsetDateTime) = apply { this.after = after }
3035

36+
/** When `true` message payloads are included in the response. */
3137
fun withContent(withContent: Boolean) = apply { this.withContent = withContent }
3238

39+
/** Filter messages matching the provided tag. */
3340
fun tag(tag: String) = apply { this.tag = tag }
41+
42+
/** Filter response based on the event type */
43+
fun eventTypes(eventTypes: List<String>) = apply { this.eventTypes = eventTypes }
3444
}
3545

3646
class Message internal constructor(token: String, options: SvixOptions) {

kotlin/lib/src/main/kotlin/MessageAttempt.kt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import com.svix.kotlin.models.StatusCodeClass
1212
import java.time.OffsetDateTime
1313

1414
class MessageAttemptListOptions(
15+
var iterator: String? = null,
16+
var limit: Int? = null,
1517
var messageStatus: MessageStatus? = null,
1618
var before: OffsetDateTime? = null,
1719
var after: OffsetDateTime? = null,
@@ -22,7 +24,7 @@ class MessageAttemptListOptions(
2224
var endpointId: String? = null,
2325
var withContent: Boolean? = null,
2426
var withMsg: Boolean? = null,
25-
) : ListOptions() {
27+
) {
2628
fun messageStatus(messageStatus: MessageStatus) = apply { this.messageStatus = messageStatus }
2729

2830
fun before(before: OffsetDateTime) = apply { this.before = before }
@@ -37,9 +39,9 @@ class MessageAttemptListOptions(
3739

3840
fun channel(channel: String) = apply { this.channel = channel }
3941

40-
override fun iterator(iterator: String) = apply { super.iterator(iterator) }
42+
fun iterator(iterator: String) = apply { this.iterator = iterator }
4143

42-
override fun limit(limit: Int) = apply { super.limit(limit) }
44+
fun limit(limit: Int) = apply { this.limit = limit }
4345

4446
fun endpointId(endpointId: String) = apply { this.endpointId = endpointId }
4547

kotlin/lib/src/main/kotlin/OperationalWebhookEndpoint.kt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@ import com.svix.kotlin.models.OperationalWebhookEndpointSecretOut
1010
import com.svix.kotlin.models.OperationalWebhookEndpointUpdate
1111
import com.svix.kotlin.models.Ordering
1212

13-
class OperationalWebhookEndpointListOptions : ListOptions() {
13+
class OperationalWebhookEndpointListOptions {
14+
var limit: Int? = null
15+
var iterator: String? = null
1416
var order: Ordering? = null
1517

16-
fun order(order: Ordering) = apply { this.order = order }
18+
/** Limit the number of returned items */
19+
fun limit(limit: Int) = apply { this.limit = limit }
1720

18-
override fun iterator(iterator: String) = apply { super.iterator(iterator) }
21+
/** The iterator returned from a prior invocation */
22+
fun iterator(iterator: String) = apply { this.iterator = iterator }
1923

20-
override fun limit(limit: Int) = apply { super.limit(limit) }
24+
/** The sorting order of the returned items */
25+
fun order(order: Ordering) = apply { this.order = order }
2126
}
2227

2328
class OperationalWebhookEndpoint internal constructor(token: String, options: SvixOptions) {

0 commit comments

Comments
 (0)