Skip to content

Commit

Permalink
kotlin: Format with ktfmt --kotlinlang-style (#1575)
Browse files Browse the repository at this point in the history
Like #1574. We want to replace
some files with auto-generated ones, to reduce the diff and make it
readable once it's generated, we should apply auto-formatting at all
times.

I tried setting up a gradle plugin for this, but unfortunately things
are a bit broken for me locally, so that didn't work out.
  • Loading branch information
svix-jplatte authored Dec 18, 2024
2 parents 4f71b19 + ea76cfc commit cc8d266
Show file tree
Hide file tree
Showing 16 changed files with 131 additions and 254 deletions.
14 changes: 5 additions & 9 deletions kotlin/lib/src/main/kotlin/Application.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ class Application internal constructor(token: String, options: SvixOptions) {
options.numRetries?.let { api.numRetries = it }
}

suspend fun list(options: ApplicationListOptions = ApplicationListOptions()): ListResponseApplicationOut {
suspend fun list(
options: ApplicationListOptions = ApplicationListOptions()
): ListResponseApplicationOut {
try {
return api.v1ApplicationList(options.limit, options.iterator, options.order)
} catch (e: Exception) {
Expand Down Expand Up @@ -55,21 +57,15 @@ class Application internal constructor(token: String, options: SvixOptions) {
}
}

suspend fun update(
appId: String,
applicationIn: ApplicationIn,
): ApplicationOut {
suspend fun update(appId: String, applicationIn: ApplicationIn): ApplicationOut {
try {
return api.v1ApplicationUpdate(appId, applicationIn)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
}

suspend fun patch(
appId: String,
applicationPatch: ApplicationPatch,
): ApplicationOut {
suspend fun patch(appId: String, applicationPatch: ApplicationPatch): ApplicationOut {
try {
return api.v1ApplicationPatch(appId, applicationPatch)
} catch (e: Exception) {
Expand Down
4 changes: 3 additions & 1 deletion kotlin/lib/src/main/kotlin/ApplicationListOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ class ApplicationListOptions : ListOptions() {

fun order(order: Ordering) = apply { this.order = order }

override fun iterator(iterator: String): ApplicationListOptions = apply { super.iterator(iterator) }
override fun iterator(iterator: String): ApplicationListOptions = apply {
super.iterator(iterator)
}

override fun limit(limit: Int) = apply { super.limit(limit) }
}
6 changes: 5 additions & 1 deletion kotlin/lib/src/main/kotlin/Authentication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ class Authentication internal constructor(token: String, options: SvixOptions) {
options: PostOptions = PostOptions(),
): AppPortalAccessOut {
try {
return api.v1AuthenticationAppPortalAccess(appId, appPortalAccessIn, options.idempotencyKey)
return api.v1AuthenticationAppPortalAccess(
appId,
appPortalAccessIn,
options.idempotencyKey,
)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand Down
12 changes: 10 additions & 2 deletions kotlin/lib/src/main/kotlin/BackgroundTask.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ class BackgroundTask internal constructor(token: String, options: SvixOptions) {
options.numRetries?.let { api.numRetries = it }
}

suspend fun list(options: BackgroundTaskListOptions = BackgroundTaskListOptions()): ListResponseBackgroundTaskOut {
suspend fun list(
options: BackgroundTaskListOptions = BackgroundTaskListOptions()
): ListResponseBackgroundTaskOut {
try {
return api.listBackgroundTasks(options.status, options.task, options.limit, options.iterator, options.order)
return api.listBackgroundTasks(
options.status,
options.task,
options.limit,
options.iterator,
options.order,
)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand Down
111 changes: 19 additions & 92 deletions kotlin/lib/src/main/kotlin/Endpoint.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,7 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
options: EndpointListOptions = EndpointListOptions(),
): ListResponseEndpointOut {
try {
return api.v1EndpointList(
appId,
options.limit,
options.iterator,
options.order,
)
return api.v1EndpointList(appId, options.limit, options.iterator, options.order)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -51,20 +46,13 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
options: PostOptions = PostOptions(),
): EndpointOut {
try {
return api.v1EndpointCreate(
appId,
endpointIn,
options.idempotencyKey,
)
return api.v1EndpointCreate(appId, endpointIn, options.idempotencyKey)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
}

suspend fun get(
appId: String,
endpointId: String,
): EndpointOut {
suspend fun get(appId: String, endpointId: String): EndpointOut {
try {
return api.v1EndpointGet(endpointId, appId)
} catch (e: Exception) {
Expand All @@ -78,11 +66,7 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
endpointUpdate: EndpointUpdate,
): EndpointOut {
try {
return api.v1EndpointUpdate(
appId,
endpointId,
endpointUpdate,
)
return api.v1EndpointUpdate(appId, endpointId, endpointUpdate)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -94,36 +78,23 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
endpointPatch: EndpointPatch,
): EndpointOut {
try {
return api.v1EndpointPatch(
appId,
endpointId,
endpointPatch,
)
return api.v1EndpointPatch(appId, endpointId, endpointPatch)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
}

suspend fun delete(
appId: String,
endpointId: String,
) {
suspend fun delete(appId: String, endpointId: String) {
try {
api.v1EndpointDelete(appId, endpointId)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
}

suspend fun getSecret(
appId: String,
endpointId: String,
): EndpointSecretOut {
suspend fun getSecret(appId: String, endpointId: String): EndpointSecretOut {
try {
return api.v1EndpointGetSecret(
appId,
endpointId,
)
return api.v1EndpointGetSecret(appId, endpointId)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand Down Expand Up @@ -154,26 +125,15 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
options: PostOptions = PostOptions(),
) {
try {
api.v1EndpointRecover(
appId,
endpointId,
recoverIn,
options.idempotencyKey,
)
api.v1EndpointRecover(appId, endpointId, recoverIn, options.idempotencyKey)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
}

suspend fun getHeaders(
appId: String,
endpointId: String,
): EndpointHeadersOut {
suspend fun getHeaders(appId: String, endpointId: String): EndpointHeadersOut {
try {
return api.v1EndpointGetHeaders(
appId,
endpointId,
)
return api.v1EndpointGetHeaders(appId, endpointId)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -185,11 +145,7 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
endpointHeadersIn: EndpointHeadersIn,
) {
try {
api.v1EndpointUpdateHeaders(
appId,
endpointId,
endpointHeadersIn,
)
api.v1EndpointUpdateHeaders(appId, endpointId, endpointHeadersIn)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -201,11 +157,7 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
endpointHeadersIn: EndpointHeadersPatchIn,
) {
try {
api.v1EndpointPatchHeaders(
appId,
endpointId,
endpointHeadersIn,
)
api.v1EndpointPatchHeaders(appId, endpointId, endpointHeadersIn)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -217,12 +169,7 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
options: EndpointStatsOptions = EndpointStatsOptions(),
): EndpointStats {
try {
return api.v1EndpointGetStats(
appId,
endpointId,
options.since,
options.until,
)
return api.v1EndpointGetStats(appId, endpointId, options.since, options.until)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -235,26 +182,15 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
options: PostOptions = PostOptions(),
) {
try {
api.v1EndpointReplay(
appId,
endpointId,
replayIn,
options.idempotencyKey,
)
api.v1EndpointReplay(appId, endpointId, replayIn, options.idempotencyKey)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
}

suspend fun transformationGet(
appId: String,
endpointId: String,
): EndpointTransformationOut {
suspend fun transformationGet(appId: String, endpointId: String): EndpointTransformationOut {
try {
return api.v1EndpointTransformationGet(
appId,
endpointId,
)
return api.v1EndpointTransformationGet(appId, endpointId)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -266,11 +202,7 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
endpointTransformationIn: EndpointTransformationIn,
) {
try {
api.v1EndpointTransformationPartialUpdate(
appId,
endpointId,
endpointTransformationIn,
)
api.v1EndpointTransformationPartialUpdate(appId, endpointId, endpointTransformationIn)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -283,12 +215,7 @@ class Endpoint internal constructor(token: String, options: SvixOptions) {
options: PostOptions = PostOptions(),
) {
try {
api.v1EndpointSendExample(
appId,
endpointId,
eventExampleIn,
options.idempotencyKey,
)
api.v1EndpointSendExample(appId, endpointId, eventExampleIn, options.idempotencyKey)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand Down
22 changes: 12 additions & 10 deletions kotlin/lib/src/main/kotlin/EventType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ class EventType internal constructor(token: String, options: SvixOptions) {
options.numRetries?.let { api.numRetries = it }
}

suspend fun list(options: EventTypeListOptions = EventTypeListOptions()): ListResponseEventTypeOut {
suspend fun list(
options: EventTypeListOptions = EventTypeListOptions()
): ListResponseEventTypeOut {
try {
return api.v1EventTypeList(options.limit, options.iterator, null, options.includeAchived, options.withContent)
return api.v1EventTypeList(
options.limit,
options.iterator,
null,
options.includeAchived,
options.withContent,
)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand All @@ -47,21 +55,15 @@ class EventType internal constructor(token: String, options: SvixOptions) {
}
}

suspend fun update(
eventTypeName: String,
eventTypeUpdate: EventTypeUpdate,
): EventTypeOut {
suspend fun update(eventTypeName: String, eventTypeUpdate: EventTypeUpdate): EventTypeOut {
try {
return api.v1EventTypeUpdate(eventTypeName, eventTypeUpdate)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
}

suspend fun patch(
eventTypeName: String,
eventTypePatch: EventTypePatch,
): EventTypeOut {
suspend fun patch(eventTypeName: String, eventTypePatch: EventTypePatch): EventTypeOut {
try {
return api.v1EventTypePatch(eventTypeName, eventTypePatch)
} catch (e: Exception) {
Expand Down
21 changes: 4 additions & 17 deletions kotlin/lib/src/main/kotlin/Integration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ class Integration internal constructor(token: String, options: SvixOptions) {
}
}

suspend fun get(
appId: String,
integId: String,
): IntegrationOut {
suspend fun get(appId: String, integId: String): IntegrationOut {
try {
return api.v1IntegrationGet(appId, integId)
} catch (e: Exception) {
Expand All @@ -64,21 +61,15 @@ class Integration internal constructor(token: String, options: SvixOptions) {
}
}

suspend fun delete(
appId: String,
integId: String,
) {
suspend fun delete(appId: String, integId: String) {
try {
api.v1IntegrationDelete(appId, integId)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
}

suspend fun getKey(
appId: String,
integId: String,
): IntegrationKeyOut {
suspend fun getKey(appId: String, integId: String): IntegrationKeyOut {
try {
return api.v1IntegrationGetKey(appId, integId)
} catch (e: Exception) {
Expand All @@ -92,11 +83,7 @@ class Integration internal constructor(token: String, options: SvixOptions) {
options: PostOptions = PostOptions(),
): IntegrationKeyOut {
try {
return api.v1IntegrationRotateKey(
appId,
integId,
options.idempotencyKey,
)
return api.v1IntegrationRotateKey(appId, integId, options.idempotencyKey)
} catch (e: Exception) {
throw ApiException.wrap(e)
}
Expand Down
Loading

0 comments on commit cc8d266

Please sign in to comment.