aboutsummaryrefslogtreecommitdiff
path: root/shared
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
commit9424b6b94d36f0f538576399b949884f6db29ac2 (patch)
treee3c4c78016fe2bac20bef92098d0d02b3c6f6ed2 /shared
parent90d9c04e66f7e7564ee1639d6b01bb34fe05239d (diff)
downloadetbsa-trackermap-mobile-9424b6b94d36f0f538576399b949884f6db29ac2.tar.gz
etbsa-trackermap-mobile-9424b6b94d36f0f538576399b949884f6db29ac2.tar.bz2
etbsa-trackermap-mobile-9424b6b94d36f0f538576399b949884f6db29ac2.zip
Adds the user information functionality
- Displays the user information - Allows the user to sign out
Diffstat (limited to 'shared')
-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