From cc7cfcb2d65a1164f5b75ae4292ea9a099746038 Mon Sep 17 00:00:00 2001 From: Isidro Henoch Date: Wed, 12 Jan 2022 15:09:52 -0600 Subject: Adds the user information functionality - Displays the user information - Allows the user to sign out --- .../mx/trackermap/TrackerMap/client/apis/SessionApi.kt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'shared/src/commonMain/kotlin') diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt index 4344de0..417a818 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt @@ -25,7 +25,6 @@ class SessionApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @return void */ suspend fun sessionDelete(): Unit { - val localVariableConfig = RequestConfig( RequestMethod.DELETE, "/session" @@ -35,7 +34,10 @@ class SessionApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api ) return when (response.responseType) { - ResponseType.Success -> Unit + ResponseType.Success -> { + val settings = Settings() + settings.remove(ACCESS_TOKEN_KEY) + } ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException( @@ -54,11 +56,12 @@ class SessionApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @return User */ @Suppress("UNCHECKED_CAST") - suspend fun sessionGet(token: kotlin.String? = null): User { - val localVariableQuery: MultiValueMap = mapOf("token" to listOf("$token")) + suspend fun sessionGet(token: String? = null): User { + val query: MutableMap> = mutableMapOf() + token?.let { query["userId"] = listOf(it) } val localVariableConfig = RequestConfig( RequestMethod.GET, - "/session", query = localVariableQuery + "/session", query = query ) val response = request( localVariableConfig -- cgit v1.2.3