diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-20 21:26:02 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-20 21:26:02 -0600 |
commit | 83efbccf0a3783ace6d91073d391bce6924553a9 (patch) | |
tree | aedd31f46b8dfc18aaad9a3263f3d6be0399691b /shared/src | |
parent | 968d39d0ffbb27beebc931618764360878477c27 (diff) | |
parent | 7da841d2de9ac0526c3863e85d7d603facabb95c (diff) | |
download | etbsa-trackermap-mobile-83efbccf0a3783ace6d91073d391bce6924553a9.tar.gz etbsa-trackermap-mobile-83efbccf0a3783ace6d91073d391bce6924553a9.tar.bz2 etbsa-trackermap-mobile-83efbccf0a3783ace6d91073d391bce6924553a9.zip |
Merge url_switch from upstream and branded
Diffstat (limited to 'shared/src')
20 files changed, 117 insertions, 102 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt index 388df19..1c9b663 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/AttributesApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Attribute import mx.trackermap.TrackerMap.client.infrastructure.* -class AttributesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class AttributesApi : ApiClient() { /** * Fetch a list of Attributes @@ -28,18 +28,18 @@ class AttributesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : * @return kotlin.Array<Attribute> */ @Suppress("UNCHECKED_CAST") - suspend fun attributesComputedGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null, deviceId: kotlin.Int? = null, groupId: kotlin.Int? = null, refresh: kotlin.Boolean? = null): kotlin.Array<Attribute> { + suspend fun attributesComputedGet(all: Boolean? = null, userId: Int? = null, deviceId: Int? = null, groupId: Int? = null, refresh: Boolean? = null): Array<Attribute> { val localVariableQuery: MultiValueMap = mapOf("all" to listOf("$all"), "userId" to listOf("$userId"), "deviceId" to listOf("$deviceId"), "groupId" to listOf("$groupId"), "refresh" to listOf("$refresh")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/attributes/computed", query = localVariableQuery ) - val response = request<kotlin.Array<Attribute>>( + val response = request<Array<Attribute>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Attribute> + ResponseType.Success -> (response as Success<*>).data as Array<Attribute> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -52,7 +52,7 @@ class AttributesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : * @param id * @return void */ - suspend fun attributesComputedIdDelete(id: kotlin.Int): Unit { + suspend fun attributesComputedIdDelete(id: Int) { val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -78,8 +78,8 @@ class AttributesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : * @return Attribute */ @Suppress("UNCHECKED_CAST") - suspend fun attributesComputedIdPut(body: Attribute, id: kotlin.Int): Attribute { - val localVariableBody: kotlin.Any? = body + suspend fun attributesComputedIdPut(body: Attribute, id: Int): Attribute { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -105,7 +105,7 @@ class AttributesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : */ @Suppress("UNCHECKED_CAST") suspend fun attributesComputedPost(body: Attribute): Attribute { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt index 70e3a02..56ee7b5 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CalendarsApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Calendar import mx.trackermap.TrackerMap.client.infrastructure.* -class CalendarsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class CalendarsApi : ApiClient() { /** * Fetch a list of Calendars @@ -25,18 +25,18 @@ class CalendarsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A * @return kotlin.Array<Calendar> */ @Suppress("UNCHECKED_CAST") - suspend fun calendarsGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null): kotlin.Array<Calendar> { + suspend fun calendarsGet(all: Boolean? = null, userId: Int? = null): Array<Calendar> { val localVariableQuery: MultiValueMap = mapOf("all" to listOf("$all"), "userId" to listOf("$userId")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/calendars", query = localVariableQuery ) - val response = request<kotlin.Array<Calendar>>( + val response = request<Array<Calendar>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Calendar> + ResponseType.Success -> (response as Success<*>).data as Array<Calendar> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -49,7 +49,7 @@ class CalendarsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A * @param id * @return void */ - suspend fun calendarsIdDelete(id: kotlin.Int): Unit { + suspend fun calendarsIdDelete(id: Int) { val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -75,8 +75,8 @@ class CalendarsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A * @return Calendar */ @Suppress("UNCHECKED_CAST") - suspend fun calendarsIdPut(body: Calendar, id: kotlin.Int): Calendar { - val localVariableBody: kotlin.Any? = body + suspend fun calendarsIdPut(body: Calendar, id: Int): Calendar { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -102,7 +102,7 @@ class CalendarsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A */ @Suppress("UNCHECKED_CAST") suspend fun calendarsPost(body: Calendar): Calendar { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt index e840888..f00bc93 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/CommandsApi.kt @@ -16,7 +16,7 @@ import mx.trackermap.TrackerMap.client.models.CommandType import mx.trackermap.TrackerMap.client.infrastructure.* -class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class CommandsApi : ApiClient() { /** * Fetch a list of Saved Commands @@ -29,7 +29,7 @@ class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Ap * @return kotlin.Array<Command> */ @Suppress("UNCHECKED_CAST") - suspend fun commandsGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null, deviceId: kotlin.Int? = null, groupId: kotlin.Int? = null, refresh: kotlin.Boolean? = null): kotlin.Array<Command> { + suspend fun commandsGet(all: Boolean? = null, userId: Int? = null, deviceId: Int? = null, groupId: Int? = null, refresh: Boolean? = null): Array<Command> { val query: MutableMap<String, List<String>> = mutableMapOf() all?.let { query["all"] = listOf("$it") } userId?.let { query["userId"] = listOf("$it") } @@ -42,12 +42,12 @@ class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Ap RequestMethod.GET, "/commands", query = localVariableQuery ) - val response = request<kotlin.Array<Command>>( + val response = request<Array<Command>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Command> + ResponseType.Success -> (response as Success<*>).data as Array<Command> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -60,7 +60,7 @@ class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Ap * @param id * @return void */ - suspend fun commandsIdDelete(id: kotlin.Int): Unit { + suspend fun commandsIdDelete(id: Int) { val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -86,8 +86,8 @@ class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Ap * @return Command */ @Suppress("UNCHECKED_CAST") - suspend fun commandsIdPut(body: Command, id: kotlin.Int): Command { - val localVariableBody: kotlin.Any? = body + suspend fun commandsIdPut(body: Command, id: Int): Command { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -113,7 +113,7 @@ class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Ap */ @Suppress("UNCHECKED_CAST") suspend fun commandsPost(body: Command): Command { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, @@ -138,18 +138,18 @@ class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Ap * @return kotlin.Array<Command> */ @Suppress("UNCHECKED_CAST") - suspend fun commandsSendGet(deviceId: kotlin.Int? = null): kotlin.Array<Command> { + suspend fun commandsSendGet(deviceId: Int? = null): Array<Command> { val localVariableQuery: MultiValueMap = mapOf("deviceId" to listOf("$deviceId")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/commands/send", query = localVariableQuery ) - val response = request<kotlin.Array<Command>>( + val response = request<Array<Command>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Command> + ResponseType.Success -> (response as Success<*>).data as Array<Command> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -164,7 +164,7 @@ class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Ap */ @Suppress("UNCHECKED_CAST") suspend fun commandsSendPost(body: Command): Command { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, @@ -191,18 +191,18 @@ class CommandsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Ap * @return kotlin.Array<CommandType> */ @Suppress("UNCHECKED_CAST") - suspend fun commandsTypesGet(deviceId: kotlin.Int? = null, protocol: kotlin.String? = null, textChannel: kotlin.Boolean? = null): kotlin.Array<CommandType> { + suspend fun commandsTypesGet(deviceId: Int? = null, protocol: String? = null, textChannel: Boolean? = null): Array<CommandType> { val localVariableQuery: MultiValueMap = mapOf("deviceId" to listOf("$deviceId"), "protocol" to listOf("$protocol"), "textChannel" to listOf("$textChannel")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/commands/types", query = localVariableQuery ) - val response = request<kotlin.Array<CommandType>>( + val response = request<Array<CommandType>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<CommandType> + ResponseType.Success -> (response as Success<*>).data as Array<CommandType> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt index 331cc4e..22903d1 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DevicesApi.kt @@ -16,7 +16,7 @@ import mx.trackermap.TrackerMap.client.models.DeviceAccumulators import mx.trackermap.TrackerMap.client.infrastructure.* -class DevicesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class DevicesApi : ApiClient() { /** * Fetch a list of Devices @@ -28,24 +28,24 @@ class DevicesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @return kotlin.Array<Device> */ @Suppress("UNCHECKED_CAST") - suspend fun devicesGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null, id: kotlin.Int? = null, uniqueId: kotlin.String? = null): kotlin.Array<Device> { + suspend fun devicesGet(all: Boolean? = null, userId: Int? = null, id: Int? = null, uniqueId: String? = null): Array<Device> { val query: MutableMap<String, List<String>> = mutableMapOf() all?.let { query["all"] = listOf("$it") } userId?.let { query["userId"] = listOf("$it") } id?.let { query["id"] = listOf("$it") } - uniqueId?.let { query["uniqueId"] = listOf("$it") } + uniqueId?.let { query["uniqueId"] = listOf(it) } val localVariableQuery: MultiValueMap = query val localVariableConfig = RequestConfig( RequestMethod.GET, "/devices", query = localVariableQuery ) - val response = request<kotlin.Array<Device>>( + val response = request<Array<Device>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Device> + ResponseType.Success -> (response as Success<*>).data as Array<Device> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -59,8 +59,8 @@ class DevicesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @param id * @return void */ - suspend fun devicesIdAccumulatorsPut(body: DeviceAccumulators, id: kotlin.Int): Unit { - val localVariableBody: kotlin.Any? = body + suspend fun devicesIdAccumulatorsPut(body: DeviceAccumulators, id: Int) { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -84,7 +84,7 @@ class DevicesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @param id * @return void */ - suspend fun devicesIdDelete(id: kotlin.Int): Unit { + suspend fun devicesIdDelete(id: Int) { val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -110,8 +110,8 @@ class DevicesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @return Device */ @Suppress("UNCHECKED_CAST") - suspend fun devicesIdPut(body: Device, id: kotlin.Int): Device { - val localVariableBody: kotlin.Any? = body + suspend fun devicesIdPut(body: Device, id: Int): Device { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -137,7 +137,7 @@ class DevicesApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api */ @Suppress("UNCHECKED_CAST") suspend fun devicesPost(body: Device): Device { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt index 2a8f92c..7cf26d0 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/DriversApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Driver import mx.trackermap.TrackerMap.client.infrastructure.* -class DriversApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class DriversApi : ApiClient() { /** * Fetch a list of Drivers @@ -28,18 +28,18 @@ class DriversApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @return kotlin.Array<Driver> */ @Suppress("UNCHECKED_CAST") - suspend fun driversGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null, deviceId: kotlin.Int? = null, groupId: kotlin.Int? = null, refresh: kotlin.Boolean? = null): kotlin.Array<Driver> { + suspend fun driversGet(all: Boolean? = null, userId: Int? = null, deviceId: Int? = null, groupId: Int? = null, refresh: Boolean? = null): Array<Driver> { val localVariableQuery: MultiValueMap = mapOf("all" to listOf("$all"), "userId" to listOf("$userId"), "deviceId" to listOf("$deviceId"), "groupId" to listOf("$groupId"), "refresh" to listOf("$refresh")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/drivers", query = localVariableQuery ) - val response = request<kotlin.Array<Driver>>( + val response = request<Array<Driver>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Driver> + ResponseType.Success -> (response as Success<*>).data as Array<Driver> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -52,7 +52,7 @@ class DriversApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @param id * @return void */ - suspend fun driversIdDelete(id: kotlin.Int): Unit { + suspend fun driversIdDelete(id: Int) { val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -78,8 +78,8 @@ class DriversApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api * @return Driver */ @Suppress("UNCHECKED_CAST") - suspend fun driversIdPut(body: Driver, id: kotlin.Int): Driver { - val localVariableBody: kotlin.Any? = body + suspend fun driversIdPut(body: Driver, id: Int): Driver { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -105,7 +105,7 @@ class DriversApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api */ @Suppress("UNCHECKED_CAST") suspend fun driversPost(body: Driver): Driver { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt index 8c1f2b0..5e5b8e6 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/EventsApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Event import mx.trackermap.TrackerMap.client.infrastructure.* -class EventsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class EventsApi : ApiClient() { /** * @@ -24,7 +24,7 @@ class EventsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiC * @return Event */ @Suppress("UNCHECKED_CAST") - suspend fun eventsIdGet(id: kotlin.Int): Event { + suspend fun eventsIdGet(id: Int): Event { val localVariableConfig = RequestConfig( RequestMethod.GET, 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 dd9c89d..23ac8c8 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: String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class GeofencesApi : ApiClient() { /** * Fetch a list of Geofences diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt index c86e66c..3b0dfa1 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/GroupsApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Group import mx.trackermap.TrackerMap.client.infrastructure.* -class GroupsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class GroupsApi : ApiClient() { /** * Fetch a list of Groups @@ -25,18 +25,18 @@ class GroupsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiC * @return kotlin.Array<Group> */ @Suppress("UNCHECKED_CAST") - suspend fun groupsGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null): kotlin.Array<Group> { + suspend fun groupsGet(all: Boolean? = null, userId: Int? = null): Array<Group> { val localVariableQuery: MultiValueMap = mapOf("all" to listOf("$all"), "userId" to listOf("$userId")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/groups", query = localVariableQuery ) - val response = request<kotlin.Array<Group>>( + val response = request<Array<Group>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Group> + ResponseType.Success -> (response as Success<*>).data as Array<Group> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -49,7 +49,7 @@ class GroupsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiC * @param id * @return void */ - suspend fun groupsIdDelete(id: kotlin.Int): Unit { + suspend fun groupsIdDelete(id: Int) { val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -75,8 +75,8 @@ class GroupsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiC * @return Group */ @Suppress("UNCHECKED_CAST") - suspend fun groupsIdPut(body: Group, id: kotlin.Int): Group { - val localVariableBody: kotlin.Any? = body + suspend fun groupsIdPut(body: Group, id: Int): Group { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -102,7 +102,7 @@ class GroupsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiC */ @Suppress("UNCHECKED_CAST") suspend fun groupsPost(body: Group): Group { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt index 7fcee92..92480fe 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/MaintenanceApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Maintenance import mx.trackermap.TrackerMap.client.infrastructure.* -class MaintenanceApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class MaintenanceApi : ApiClient() { /** * Fetch a list of Maintenance @@ -28,18 +28,18 @@ class MaintenanceApi(basePath: kotlin.String = "https://demo.traccar.org/api") : * @return kotlin.Array<Maintenance> */ @Suppress("UNCHECKED_CAST") - suspend fun maintenanceGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null, deviceId: kotlin.Int? = null, groupId: kotlin.Int? = null, refresh: kotlin.Boolean? = null): kotlin.Array<Maintenance> { + suspend fun maintenanceGet(all: Boolean? = null, userId: Int? = null, deviceId: Int? = null, groupId: Int? = null, refresh: Boolean? = null): Array<Maintenance> { val localVariableQuery: MultiValueMap = mapOf("all" to listOf("$all"), "userId" to listOf("$userId"), "deviceId" to listOf("$deviceId"), "groupId" to listOf("$groupId"), "refresh" to listOf("$refresh")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/maintenance", query = localVariableQuery ) - val response = request<kotlin.Array<Maintenance>>( + val response = request<Array<Maintenance>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Maintenance> + ResponseType.Success -> (response as Success<*>).data as Array<Maintenance> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -52,7 +52,7 @@ class MaintenanceApi(basePath: kotlin.String = "https://demo.traccar.org/api") : * @param id * @return void */ - suspend fun maintenanceIdDelete(id: kotlin.Int): Unit { + suspend fun maintenanceIdDelete(id: Int) { val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -78,8 +78,8 @@ class MaintenanceApi(basePath: kotlin.String = "https://demo.traccar.org/api") : * @return Maintenance */ @Suppress("UNCHECKED_CAST") - suspend fun maintenanceIdPut(body: Maintenance, id: kotlin.Int): Maintenance { - val localVariableBody: kotlin.Any? = body + suspend fun maintenanceIdPut(body: Maintenance, id: Int): Maintenance { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -105,7 +105,7 @@ class MaintenanceApi(basePath: kotlin.String = "https://demo.traccar.org/api") : */ @Suppress("UNCHECKED_CAST") suspend fun maintenancePost(body: Maintenance): Maintenance { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt index 86c34d0..1f0d744 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/NotificationsApi.kt @@ -16,7 +16,7 @@ import mx.trackermap.TrackerMap.client.models.NotificationType import mx.trackermap.TrackerMap.client.infrastructure.* -class NotificationsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class NotificationsApi : ApiClient() { /** * Fetch a list of Notifications @@ -29,18 +29,18 @@ class NotificationsApi(basePath: kotlin.String = "https://demo.traccar.org/api") * @return kotlin.Array<Notification> */ @Suppress("UNCHECKED_CAST") - suspend fun notificationsGet(all: kotlin.Boolean? = null, userId: kotlin.Int? = null, deviceId: kotlin.Int? = null, groupId: kotlin.Int? = null, refresh: kotlin.Boolean? = null): kotlin.Array<Notification> { + suspend fun notificationsGet(all: Boolean? = null, userId: Int? = null, deviceId: Int? = null, groupId: Int? = null, refresh: Boolean? = null): Array<Notification> { val localVariableQuery: MultiValueMap = mapOf("all" to listOf("$all"), "userId" to listOf("$userId"), "deviceId" to listOf("$deviceId"), "groupId" to listOf("$groupId"), "refresh" to listOf("$refresh")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/notifications", query = localVariableQuery ) - val response = request<kotlin.Array<Notification>>( + val response = request<Array<Notification>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Notification> + ResponseType.Success -> (response as Success<*>).data as Array<Notification> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") @@ -53,7 +53,7 @@ class NotificationsApi(basePath: kotlin.String = "https://demo.traccar.org/api") * @param id * @return void */ - suspend fun notificationsIdDelete(id: kotlin.Int): Unit { + suspend fun notificationsIdDelete(id: Int) { val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -79,8 +79,8 @@ class NotificationsApi(basePath: kotlin.String = "https://demo.traccar.org/api") * @return Notification */ @Suppress("UNCHECKED_CAST") - suspend fun notificationsIdPut(body: Notification, id: kotlin.Int): Notification { - val localVariableBody: kotlin.Any? = body + suspend fun notificationsIdPut(body: Notification, id: Int): Notification { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, @@ -106,7 +106,7 @@ class NotificationsApi(basePath: kotlin.String = "https://demo.traccar.org/api") */ @Suppress("UNCHECKED_CAST") suspend fun notificationsPost(body: Notification): Notification { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, @@ -129,7 +129,7 @@ class NotificationsApi(basePath: kotlin.String = "https://demo.traccar.org/api") * * @return void */ - suspend fun notificationsTestPost(): Unit { + suspend fun notificationsTestPost(){ val localVariableConfig = RequestConfig( RequestMethod.POST, @@ -153,18 +153,18 @@ class NotificationsApi(basePath: kotlin.String = "https://demo.traccar.org/api") * @return kotlin.Array<NotificationType> */ @Suppress("UNCHECKED_CAST") - suspend fun notificationsTypesGet(): kotlin.Array<NotificationType> { + suspend fun notificationsTypesGet(): Array<NotificationType> { val localVariableConfig = RequestConfig( RequestMethod.GET, "/notifications/types" ) - val response = request<kotlin.Array<NotificationType>>( + val response = request<Array<NotificationType>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<NotificationType> + ResponseType.Success -> (response as Success<*>).data as Array<NotificationType> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt index bfa2c2e..02c9348 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PermissionsApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Permission import mx.trackermap.TrackerMap.client.infrastructure.* -class PermissionsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class PermissionsApi : ApiClient() { /** * Unlink an Object from another Object @@ -23,8 +23,8 @@ class PermissionsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : * @param body * @return void */ - suspend fun permissionsDelete(body: Permission): Unit { - val localVariableBody: kotlin.Any? = body + suspend fun permissionsDelete(body: Permission) { + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.DELETE, @@ -50,7 +50,7 @@ class PermissionsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : */ @Suppress("UNCHECKED_CAST") suspend fun permissionsPost(body: Permission): Permission { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.POST, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt index 278611f..ecbf649 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/PositionsApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Position import mx.trackermap.TrackerMap.client.infrastructure.* -class PositionsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class PositionsApi : ApiClient() { /** * Fetches a list of Positions @@ -27,7 +27,7 @@ class PositionsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A * @return kotlin.Array<Position> */ @Suppress("UNCHECKED_CAST") - suspend fun positionsGet(deviceId: kotlin.Int? = null, from: LocalDateTimeAdapter? = null, to: LocalDateTimeAdapter? = null, id: kotlin.Int? = null): kotlin.Array<Position> { + suspend fun positionsGet(deviceId: Int? = null, from: LocalDateTimeAdapter? = null, to: LocalDateTimeAdapter? = null, id: Int? = null): Array<Position> { val query: MutableMap<String, List<String>> = mutableMapOf() deviceId?.let { query["deviceId"] = listOf("$it") } from?.let { query["from"] = listOf("$it") } @@ -39,12 +39,12 @@ class PositionsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : A RequestMethod.GET, "/positions", query = localVariableQuery ) - val response = request<kotlin.Array<Position>>( + val response = request<Array<Position>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Position> + ResponseType.Success -> (response as Success<*>).data as Array<Position> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt index d77064e..3dbee22 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt @@ -20,7 +20,7 @@ import mx.trackermap.TrackerMap.client.models.ReportTrips import mx.trackermap.TrackerMap.client.infrastructure.* -class ReportsApi(basePath: String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class ReportsApi : ApiClient() { /** * Fetch a list of Events within the time period for the Devices or Groups diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt index 659761b..3c7787d 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ServerApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Server import mx.trackermap.TrackerMap.client.infrastructure.* -class ServerApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class ServerApi : ApiClient() { /** * Fetch Server information @@ -49,7 +49,7 @@ class ServerApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiC */ @Suppress("UNCHECKED_CAST") suspend fun serverPut(body: Server): Server { - val localVariableBody: kotlin.Any? = body + val localVariableBody: Any = body val localVariableConfig = RequestConfig( RequestMethod.PUT, 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 b57f126..ad9e450 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 @@ -15,9 +15,10 @@ import com.russhwolf.settings.Settings import mx.trackermap.TrackerMap.client.models.User import mx.trackermap.TrackerMap.client.infrastructure.* +const val SERVER_URL_KEY = "server_url" const val ACCESS_TOKEN_KEY = "access_token" -class SessionApi(basePath: String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class SessionApi : ApiClient() { /** * Close the Session @@ -90,7 +91,6 @@ class SessionApi(basePath: String = "https://demo.traccar.org/api") : ApiClient( @Suppress("UNCHECKED_CAST") suspend fun sessionPost(email: String, password: String): User { val localVariableBody = mapOf("email" to email, "password" to password) - val localVariableHeaders = mapOf("Content-Type" to "application/x-www-form-urlencoded") val localVariableConfig = RequestConfig( RequestMethod.POST, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt index f7651ac..1857cc5 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/StatisticsApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.Statistics import mx.trackermap.TrackerMap.client.infrastructure.* -class StatisticsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class StatisticsApi : ApiClient() { /** * Fetch server Statistics @@ -25,18 +25,18 @@ class StatisticsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : * @return kotlin.Array<Statistics> */ @Suppress("UNCHECKED_CAST") - suspend fun statisticsGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime): kotlin.Array<Statistics> { + suspend fun statisticsGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime): Array<Statistics> { val localVariableQuery: MultiValueMap = mapOf("from" to listOf("$from"), "to" to listOf("$to")) val localVariableConfig = RequestConfig( RequestMethod.GET, "/statistics", query = localVariableQuery ) - val response = request<kotlin.Array<Statistics>>( + val response = request<Array<Statistics>>( localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Statistics> + ResponseType.Success -> (response as Success<*>).data as Array<Statistics> ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt index 858cd10..7b8d837 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/UsersApi.kt @@ -15,7 +15,7 @@ import mx.trackermap.TrackerMap.client.models.User import mx.trackermap.TrackerMap.client.infrastructure.* -class UsersApi(basePath: String = "https://demo.traccar.org/api") : ApiClient(basePath) { +class UsersApi : ApiClient() { /** * Fetch a list of Users diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt index 606fef0..88aaa26 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiClient.kt @@ -17,9 +17,10 @@ import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.util.* import mx.trackermap.TrackerMap.client.apis.ACCESS_TOKEN_KEY +import mx.trackermap.TrackerMap.client.apis.SERVER_URL_KEY import kotlinx.serialization.json.Json as KotlinJson -open class ApiClient(val baseUrl: String) { +open class ApiClient() { companion object { protected const val ApiContentType = "Content-Type" protected const val ApiAccept = "Accept" @@ -58,10 +59,12 @@ open class ApiClient(val baseUrl: String) { ) } + var baseUrl: String = "" var token: String = "" init { val settings = Settings() + baseUrl = settings.getString(SERVER_URL_KEY, "") token = settings.getString(ACCESS_TOKEN_KEY, "") } diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Session_body.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Session_body.kt index e98ff34..52c5abc 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Session_body.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Session_body.kt @@ -12,11 +12,14 @@ package mx.trackermap.TrackerMap.client.models /** - * + * + * @param url * @param email - * @param password + * @param password + * @param fcmToken */ data class SessionBody ( + val url: String, val email: String, val password: String, val fcmToken: String? = null diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt index 2ce4dc6..7d944b7 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt @@ -20,6 +20,7 @@ class SessionController( sealed class LoginState { object Nothing: LoginState() object Loading: LoginState() + object UrlMissing: LoginState() object EmailMissing : LoginState() object PasswordMissing : LoginState() object Failure : LoginState() @@ -58,10 +59,16 @@ class SessionController( } fun login(body: SessionBody) { + val url = body.url.trim() val email = body.email.trim() val password = body.password.trim() val token = body.fcmToken + if (url.isEmpty()) { + loginStateFlow.value = LoginState.UrlMissing + return + } + if (email.isEmpty()) { loginStateFlow.value = LoginState.EmailMissing return @@ -75,6 +82,8 @@ class SessionController( loginStateFlow.value = LoginState.Loading GlobalScope.launch { try { + sessionApi.baseUrl = url + usersApi.baseUrl = sessionApi.baseUrl val session = sessionApi.sessionPost(email, password) userFlow.value = session usersApi.token = sessionApi.token |