From 4475382b482e9b20cb34dfd2e6896546bf86c485 Mon Sep 17 00:00:00 2001 From: Iván Ávalos Date: Sat, 8 Jan 2022 02:31:33 -0600 Subject: Finished events report, implemented GeofenceController, fixed geofencesGet() and many fixes --- .../TrackerMap/client/apis/GeofencesApi.kt | 45 +++++++++++++--------- 1 file changed, 26 insertions(+), 19 deletions(-) (limited to 'shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt') diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt index ede7586..dd9c89d 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GeofencesApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Geofence import mx.trackermap.TrackerMap.client.infrastructure.* -class GeofencesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class GeofencesApi(basePath: String = "https://demo.traccar.org/api") : ApiClient(basePath) { /** * Fetch a list of Geofences @@ -28,18 +28,25 @@ class GeofencesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A * @return kotlin.Array */ @Suppress("UNCHECKED_CAST") - suspend fun geofencesGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null, deviceId: kotlin.Int? = null, groupId: kotlin.Int? = null, refresh: kotlin.Boolean? = null): kotlin.Array { - val localVariableQuery: MultiValueMap = mapOf("all" to listOf("$all"), "userId" to listOf("$userId"), "deviceId" to listOf("$deviceId"), "groupId" to listOf("$groupId"), "refresh" to listOf("$refresh")) + suspend fun geofencesGet(all: Boolean? = null, userId: Int? = null, deviceId: Int? = null, groupId: Int? = null, refresh: Boolean? = null): Array { + val query: MutableMap> = mutableMapOf() + all?.let { query["all"] = listOf("$it") } + userId?.let { query["userId"] = listOf("$it") } + deviceId?.let { query["userId"] = listOf("$it") } + groupId?.let { query["groupId"] = listOf("$it") } + refresh?.let { query["refresh"] = listOf("$it") } + val localVariableQuery: MultiValueMap = query + val localVariableConfig = RequestConfig( RequestMethod.GET, "/geofences", query = localVariableQuery ) - val response = request>( + val response = request>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + ResponseType.Success -> (response as Success<*>).data as Array ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -48,12 +55,12 @@ class GeofencesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A } /** * Delete a Geofence - * - * @param id + * + * @param id * @return void */ - suspend fun geofencesIdDelete(id: kotlin.Int): Unit { - + suspend fun geofencesIdDelete(id: Int) { + val localVariableConfig = RequestConfig( RequestMethod.DELETE, "/geofences/{id}".replace("{" + "id" + "}", "$id") @@ -72,15 +79,15 @@ class GeofencesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A } /** * Update a Geofence - * - * @param body - * @param id + * + * @param body + * @param id * @return Geofence */ @Suppress("UNCHECKED_CAST") - suspend fun geofencesIdPut(body: Geofence, id: kotlin.Int): Geofence { - val localVariableBody: kotlin.Any? = body - + suspend fun geofencesIdPut(body: Geofence, id: Int): Geofence { + val localVariableBody: Any = body + val localVariableConfig = RequestConfig( RequestMethod.PUT, "/geofences/{id}".replace("{" + "id" + "}", "$id") @@ -99,14 +106,14 @@ class GeofencesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A } /** * Create a Geofence - * - * @param body + * + * @param body * @return Geofence */ @Suppress("UNCHECKED_CAST") suspend fun geofencesPost(body: Geofence): Geofence { - val localVariableBody: kotlin.Any? = body - + val localVariableBody: Any = body + val localVariableConfig = RequestConfig( RequestMethod.POST, "/geofences" -- cgit v1.2.3