aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin
diff options
context:
space:
mode:
authorIsidro Henoch <imhenoch@protonmail.com>2022-01-12 15:09:52 -0600
committerIsidro Henoch <imhenoch@protonmail.com>2022-01-12 15:09:52 -0600
commitcc7cfcb2d65a1164f5b75ae4292ea9a099746038 (patch)
treee3c4c78016fe2bac20bef92098d0d02b3c6f6ed2 /shared/src/commonMain/kotlin
parent9b5850870bef2770f281d51b5c96ac9103ab3667 (diff)
downloadetbsa-trackermap-mobile-cc7cfcb2d65a1164f5b75ae4292ea9a099746038.tar.gz
etbsa-trackermap-mobile-cc7cfcb2d65a1164f5b75ae4292ea9a099746038.tar.bz2
etbsa-trackermap-mobile-cc7cfcb2d65a1164f5b75ae4292ea9a099746038.zip
Adds the user information functionality
- Displays the user information - Allows the user to sign out
Diffstat (limited to 'shared/src/commonMain/kotlin')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/SessionApi.kt13
1 files changed, 8 insertions, 5 deletions
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<String, List<String>> = mutableMapOf()
+ token?.let { query["userId"] = listOf(it) }
val localVariableConfig = RequestConfig(
RequestMethod.GET,
- "/session", query = localVariableQuery
+ "/session", query = query
)
val response = request<User>(
localVariableConfig