diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-24 15:12:11 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-24 15:12:11 -0600 |
commit | ac5eeffba586954042c9efcf196c2efcfe854c4a (patch) | |
tree | 20378bce6484d4c68203556d9f4e76d18fc566f3 /shared/src/commonMain/kotlin/mx | |
parent | 0381ae0b930ceb7b43ef1e66950c9bd6f9dfcc56 (diff) | |
parent | 7f1388bc554a3ee68a1865d2a219395805a79575 (diff) | |
download | etbsa-trackermap-mobile-ac5eeffba586954042c9efcf196c2efcfe854c4a.tar.gz etbsa-trackermap-mobile-ac5eeffba586954042c9efcf196c2efcfe854c4a.tar.bz2 etbsa-trackermap-mobile-ac5eeffba586954042c9efcf196c2efcfe854c4a.zip |
Merged main from upstream (unbranded)
Diffstat (limited to 'shared/src/commonMain/kotlin/mx')
51 files changed, 530 insertions, 188 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..2a67fd0 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..8dd2da8 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..8ee7436 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..74d105f 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..a9f47b8 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..360d6e1 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * @@ -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..d7174e5 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..620a25e 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..5b10e9e 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..290a14d 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..33aab48 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..61285e9 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..eff40ad 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 @@ -12,6 +12,7 @@ package mx.trackermap.TrackerMap.client.apis import io.ktor.content.* +import kotlinx.datetime.LocalDateTime import mx.trackermap.TrackerMap.client.models.Event import mx.trackermap.TrackerMap.client.models.Position import mx.trackermap.TrackerMap.client.models.Stop @@ -20,7 +21,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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * Fetch a list of Events within the time period for the Devices or Groups @@ -248,8 +249,8 @@ class ReportsApi(basePath: String = "https://demo.traccar.org/api") : ApiClient( */ @Suppress("UNCHECKED_CAST") suspend fun reportsSummaryGet( - from: java.time.LocalDateTime, - to: java.time.LocalDateTime, + from: LocalDateTime, + to: LocalDateTime, deviceId: Array<Int>? = null, groupId: Array<Int>? = null ): Array<ReportSummary> { @@ -291,8 +292,8 @@ class ReportsApi(basePath: String = "https://demo.traccar.org/api") : ApiClient( */ @Suppress("UNCHECKED_CAST") suspend fun reportsTripsGet( - from: java.time.LocalDateTime, - to: java.time.LocalDateTime, + from: LocalDateTime, + to: LocalDateTime, deviceId: Array<Int>? = null, groupId: Array<Int>? = null ): Array<ReportTrips> { 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..bf65dfe 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..3f90c4c 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * 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..296e589 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 @@ -11,11 +11,12 @@ */ package mx.trackermap.TrackerMap.client.apis +import kotlinx.datetime.LocalDateTime 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * Fetch server Statistics @@ -25,18 +26,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: LocalDateTime, to: 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..51f2138 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(defaultBaseUrl: String) : ApiClient(defaultBaseUrl) { /** * Fetch a list of Users diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiAbstractions.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiAbstractions.kt index f63f301..47ab320 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiAbstractions.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiAbstractions.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.client.infrastructure typealias MultiValueMap = Map<String, List<String>> 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..dd61893 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 @@ -1,10 +1,26 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.client.infrastructure import com.russhwolf.settings.Settings -import com.russhwolf.settings.string import io.ktor.client.* import io.ktor.client.call.* -import io.ktor.client.engine.cio.* +import io.ktor.client.features.* import io.ktor.client.features.json.* import io.ktor.client.features.json.serializer.KotlinxSerializer import io.ktor.client.features.logging.DEFAULT @@ -17,9 +33,12 @@ 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( + defaultBaseUrl: String = "", +) { companion object { protected const val ApiContentType = "Content-Type" protected const val ApiAccept = "Accept" @@ -28,7 +47,11 @@ open class ApiClient(val baseUrl: String) { protected const val ApiFormURLType = "application/x-www-form-urlencoded" protected const val ApiXmlMediaType = "application/xml" - val client: HttpClient = HttpClient(CIO) { + val client: HttpClient = HttpClient { + install(HttpTimeout) { + connectTimeoutMillis = 20_000 + requestTimeoutMillis = 20_000 + } install(JsonFeature) { serializer = KotlinxSerializer( KotlinJson { @@ -40,9 +63,6 @@ open class ApiClient(val baseUrl: String) { logger = Logger.DEFAULT level = LogLevel.ALL } - engine { - requestTimeout = 20_000 - } } val defaultHeaders: Map<String, String> = @@ -58,10 +78,12 @@ open class ApiClient(val baseUrl: String) { ) } + var baseUrl: String = "" var token: String = "" init { val settings = Settings() + baseUrl = settings.getString(SERVER_URL_KEY, defaultBaseUrl) token = settings.getString(ACCESS_TOKEN_KEY, "") } diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiInfrastructureResponse.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiInfrastructureResponse.kt index bc0b4fb..3e8cbed 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiInfrastructureResponse.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/ApiInfrastructureResponse.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.client.infrastructure enum class ResponseType { diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/Errors.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/Errors.kt index 3c44140..737f98c 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/Errors.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/Errors.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.client.infrastructure open class ClientException : RuntimeException { diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateAdapter.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateAdapter.kt index 7142665..f60d986 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateAdapter.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateAdapter.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.client.infrastructure import kotlinx.datetime.LocalDate diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateTimeAdapter.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateTimeAdapter.kt index d073ff4..cbfc311 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateTimeAdapter.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/LocalDateTimeAdapter.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.client.infrastructure import kotlinx.datetime.LocalDateTime diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/RequestConfig.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/RequestConfig.kt index 73205ff..ba5b12f 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/RequestConfig.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/RequestConfig.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.client.infrastructure /** diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/RequestMethod.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/RequestMethod.kt index f118678..2488ccb 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/RequestMethod.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/infrastructure/RequestMethod.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.client.infrastructure /** diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Attribute.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Attribute.kt index 0404967..7c139b5 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Attribute.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Attribute.kt @@ -11,6 +11,8 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable + /** * @@ -20,13 +22,14 @@ package mx.trackermap.TrackerMap.client.models * @param expression * @param type String|Number|Boolean */ +@Serializable data class Attribute ( - val id: kotlin.Int? = null, - val description: kotlin.String? = null, - val attribute: kotlin.String? = null, - val expression: kotlin.String? = null, + val id: Int? = null, + val description: String? = null, + val attribute: String? = null, + val expression: String? = null, /* String|Number|Boolean */ - val type: kotlin.String? = null + val type: String? = null ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Calendar.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Calendar.kt index c528673..6501ff4 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Calendar.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Calendar.kt @@ -11,6 +11,7 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonPrimitive @@ -19,8 +20,9 @@ import kotlinx.serialization.json.JsonPrimitive * @param id * @param name * @param `data` base64 encoded in iCalendar format - * @param attributes + * @param attributes */ +@Serializable data class Calendar ( val id: Int? = null, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/CommandType.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/CommandType.kt index 7b1a742..fa00d24 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/CommandType.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/CommandType.kt @@ -11,13 +11,16 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable + /** * * @param type */ +@Serializable data class CommandType ( - val type: kotlin.String? = null + val type: String? = null ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/DeviceAccumulators.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/DeviceAccumulators.kt index 43c8fb9..87cb0a7 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/DeviceAccumulators.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/DeviceAccumulators.kt @@ -11,6 +11,8 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable + /** * @@ -18,11 +20,12 @@ package mx.trackermap.TrackerMap.client.models * @param totalDistance in meters * @param hours */ +@Serializable data class DeviceAccumulators ( - val deviceId: kotlin.Int? = null, + val deviceId: Int? = null, /* in meters */ - val totalDistance: java.math.BigDecimal? = null, - val hours: java.math.BigDecimal? = null + val totalDistance: Double? = null, + val hours: Long? = null ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Driver.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Driver.kt index c83543e..309e4b9 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Driver.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Driver.kt @@ -11,6 +11,7 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonPrimitive @@ -21,6 +22,7 @@ import kotlinx.serialization.json.JsonPrimitive * @param uniqueId * @param attributes */ +@Serializable data class Driver ( val id: Int? = null, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt index 5e4b2d5..a008fa8 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt @@ -1,5 +1,8 @@ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable + +@Serializable data class EventInformation( val event: Event, val position: Position?, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Group.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Group.kt index b90e591..6ab32cd 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Group.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Group.kt @@ -11,6 +11,7 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonPrimitive @@ -21,6 +22,7 @@ import kotlinx.serialization.json.JsonPrimitive * @param groupId * @param attributes */ +@Serializable data class Group ( val id: Int? = null, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Maintenance.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Maintenance.kt index f9d4fcd..1979e1a 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Maintenance.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Maintenance.kt @@ -11,6 +11,7 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonPrimitive @@ -23,13 +24,14 @@ import kotlinx.serialization.json.JsonPrimitive * @param period * @param attributes */ +@Serializable data class Maintenance ( val id: Int? = null, val name: String? = null, val type: String? = null, - val start: java.math.BigDecimal? = null, - val period: java.math.BigDecimal? = null, + val start: Double? = null, + val period: Double? = null, val attributes: Map<String, JsonPrimitive> = mapOf() ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Notification.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Notification.kt index 2be5468..eb35ecd 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Notification.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Notification.kt @@ -11,6 +11,7 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonPrimitive @@ -25,6 +26,7 @@ import kotlinx.serialization.json.JsonPrimitive * @param calendarId * @param attributes */ +@Serializable data class Notification ( val id: Int? = null, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/NotificationType.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/NotificationType.kt index 55763ca..486c67b 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/NotificationType.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/NotificationType.kt @@ -11,13 +11,16 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable + /** * * @param type */ +@Serializable data class NotificationType ( - val type: kotlin.String? = null + val type: String? = null ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Permission.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Permission.kt index c4c236b..0d1be29 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Permission.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Permission.kt @@ -11,6 +11,8 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable + /** * This is a permission map that contain two object indexes. It is used to link/unlink objects. Order is important. Example: { deviceId:8, geofenceId: 16 } @@ -23,23 +25,24 @@ package mx.trackermap.TrackerMap.client.models * @param driverId Driver Id, can be second parameter only * @param managedUserId User Id, can be second parameter only and only in combination with userId */ +@Serializable data class Permission ( /* User Id, can be only first parameter */ - val userId: kotlin.Int? = null, + val userId: Int? = null, /* Device Id, can be first parameter or second only in combination with userId */ - val deviceId: kotlin.Int? = null, + val deviceId: Int? = null, /* Group Id, can be first parameter or second only in combination with userId */ - val groupId: kotlin.Int? = null, + val groupId: Int? = null, /* Geofence Id, can be second parameter only */ - val geofenceId: kotlin.Int? = null, + val geofenceId: Int? = null, /* Calendar Id, can be second parameter only and only in combination with userId */ - val calendarId: kotlin.Int? = null, + val calendarId: Int? = null, /* Computed Attribute Id, can be second parameter only */ - val attributeId: kotlin.Int? = null, + val attributeId: Int? = null, /* Driver Id, can be second parameter only */ - val driverId: kotlin.Int? = null, + val driverId: Int? = null, /* User Id, can be second parameter only and only in combination with userId */ - val managedUserId: kotlin.Int? = null + val managedUserId: Int? = null ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportSummary.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportSummary.kt index c6f59a6..25f5b9d 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportSummary.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportSummary.kt @@ -11,6 +11,8 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable + /** * @@ -22,18 +24,19 @@ package mx.trackermap.TrackerMap.client.models * @param spentFuel in liters * @param engineHours */ +@Serializable data class ReportSummary ( - val deviceId: kotlin.Int? = null, - val deviceName: kotlin.String? = null, + val deviceId: Int? = null, + val deviceName: String? = null, /* in knots */ - val maxSpeed: java.math.BigDecimal? = null, + val maxSpeed: Double? = null, /* in knots */ - val averageSpeed: java.math.BigDecimal? = null, + val averageSpeed: Double? = null, /* in meters */ - val distance: java.math.BigDecimal? = null, + val distance: Double? = null, /* in liters */ - val spentFuel: java.math.BigDecimal? = null, - val engineHours: kotlin.Int? = null + val spentFuel: Double? = null, + val engineHours: Double? = null ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportTrips.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportTrips.kt index d7e9598..666b2ad 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportTrips.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportTrips.kt @@ -11,6 +11,9 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.datetime.LocalDateTime +import kotlinx.serialization.Serializable + /** * @@ -32,30 +35,31 @@ package mx.trackermap.TrackerMap.client.models * @param driverUniqueId * @param driverName */ +@Serializable data class ReportTrips ( - val deviceId: kotlin.Int? = null, - val deviceName: kotlin.String? = null, + val deviceId: Int? = null, + val deviceName: String? = null, /* in knots */ - val maxSpeed: java.math.BigDecimal? = null, + val maxSpeed: Double? = null, /* in knots */ - val averageSpeed: java.math.BigDecimal? = null, + val averageSpeed: Double? = null, /* in meters */ - val distance: java.math.BigDecimal? = null, + val distance: Double? = null, /* in liters */ - val spentFuel: java.math.BigDecimal? = null, - val duration: kotlin.Int? = null, + val spentFuel: Double? = null, + val duration: Int? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ - val startTime: java.time.LocalDateTime? = null, - val startAddress: kotlin.String? = null, - val startLat: java.math.BigDecimal? = null, - val startLon: java.math.BigDecimal? = null, + val startTime: String? = null, + val startAddress: String? = null, + val startLat: Double? = null, + val startLon: Double? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ - val endTime: java.time.LocalDateTime? = null, - val endAddress: kotlin.String? = null, - val endLat: java.math.BigDecimal? = null, - val endLon: java.math.BigDecimal? = null, - val driverUniqueId: kotlin.Int? = null, - val driverName: kotlin.String? = null + val endTime: String? = null, + val endAddress: String? = null, + val endLat: Double? = null, + val endLon: Double? = null, + val driverUniqueId: Int? = null, + val driverName: String? = null ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Server.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Server.kt index d2ea44e..0c1e790 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Server.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Server.kt @@ -11,6 +11,7 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonPrimitive @@ -34,6 +35,7 @@ import kotlinx.serialization.json.JsonPrimitive * @param coordinateFormat * @param attributes */ +@Serializable data class Server ( val id: Int? = null, @@ -45,8 +47,8 @@ data class Server ( val bingKey: String? = null, val mapUrl: String? = null, val poiLayer: String? = null, - val latitude: java.math.BigDecimal? = null, - val longitude: java.math.BigDecimal? = null, + val latitude: Double? = null, + val longitude: Double? = null, val zoom: Int? = null, val twelveHourFormat: Boolean? = null, val version: String? = null, 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/client/models/Statistics.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Statistics.kt index 32027b9..4ad71ce 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Statistics.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Statistics.kt @@ -11,6 +11,8 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable + /** * @@ -21,14 +23,15 @@ package mx.trackermap.TrackerMap.client.models * @param messagesReceived * @param messagesStored */ +@Serializable data class Statistics ( /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ - val captureTime: java.time.LocalDateTime? = null, - val activeUsers: kotlin.Int? = null, - val activeDevices: kotlin.Int? = null, - val requests: kotlin.Int? = null, - val messagesReceived: kotlin.Int? = null, - val messagesStored: kotlin.Int? = null + val captureTime: String? = null, + val activeUsers: Int? = null, + val activeDevices: Int? = null, + val requests: Int? = null, + val messagesReceived: Int? = null, + val messagesStored: Int? = null ) { }
\ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt index e9b19b6..0e4c5c9 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/GeofencesController.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.controllers import kotlinx.coroutines.DelicateCoroutinesApi diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt index fcde002..b60a034 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt @@ -1,6 +1,22 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.controllers -import android.util.Log import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.flow.MutableStateFlow @@ -44,10 +60,6 @@ class ReportController( } val (currentDate, previousDate) = ReportDates.getDates(reportPeriod) - Log.d("UnitReportsVM", "Current report type: $reportType") - Log.d("UnitReportsVM", "Current report period: $reportType") - Log.d("UnitReportsVM", "Current date:${currentDate}") - Log.d("UnitReportsVM", "Previous date:${previousDate}") if (!xlsx) { reportFlow.value = Report.LoadingReport @@ -67,15 +79,11 @@ class ReportController( to: String, xlsx: Boolean ) { - Log.d("UnitReportsVM", "Fetching positions") - if (!xlsx) { val result = reportsApi.reportsRouteGet(from, to, deviceId) - Log.d("UnitReportsVM", "Positions report: $result") reportFlow.value = Report.PositionsReport(result) } else { val result = reportsApi.reportsRouteGetXlsx(from, to, deviceId) - Log.d("UnitReportsVM", "Positions report: $result") reportFlow.value = Report.XlsxReport(result) } @@ -88,7 +96,6 @@ class ReportController( types: List<EventInformation.Type>, xlsx: Boolean ) { - Log.d("UnitReportsVM", "Fetching events") if (!xlsx) { val positionsResult = reportsApi.reportsRouteGet(from, to, deviceId) @@ -106,14 +113,12 @@ class ReportController( )) } - Log.d("UnitReportsVM", "Events report: $result") reportFlow.value = Report.EventsReport(result.toTypedArray()) } else { val result = reportsApi.reportsEventsGetXlsx( from, to, EventInformation.reportTypesToStrings(types), deviceId ) - Log.d("UnitReportsVM", "Events report: $result") reportFlow.value = Report.XlsxReport(result) } } @@ -124,15 +129,11 @@ class ReportController( to: String, xlsx: Boolean ) { - Log.d("UnitReportsVM", "Fetching stops") - if (!xlsx) { val result = reportsApi.reportsStopsGet(from, to, deviceId) - Log.d("UnitReportsVM", "Stops report: $result") reportFlow.value = Report.StopsReport(result) } else { val result = reportsApi.reportsStopsGetXlsx(from, to, deviceId) - Log.d("UnitReportsVM", "Stops report: $result") reportFlow.value = Report.XlsxReport(result) } 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..a945ee9 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/SessionController.kt @@ -1,9 +1,24 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.controllers -import android.util.Log import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.delay import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.launch import kotlinx.serialization.json.JsonPrimitive @@ -20,6 +35,7 @@ class SessionController( sealed class LoginState { object Nothing: LoginState() object Loading: LoginState() + object UrlMissing: LoginState() object EmailMissing : LoginState() object PasswordMissing : LoginState() object Failure : LoginState() @@ -35,7 +51,6 @@ class SessionController( GlobalScope.launch { try { userFlow.value = sessionApi.sessionGet() - Log.d("LoginViewModel", userFlow.value.toString()) loginStateFlow.value = LoginState.Success } catch (e: Exception) { loginStateFlow.value = LoginState.Failure @@ -48,20 +63,24 @@ class SessionController( GlobalScope.launch { try { userFlow.value = sessionApi.sessionGet() - Log.d("LoginViewModel", userFlow.value.toString()) loginStateFlow.value = LoginState.Success } catch (e: Exception) { - Log.d("LoginViewModel", "No session") loginStateFlow.value = LoginState.Nothing } } } 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 +94,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 diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt index a9ebae2..b282a34 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/UnitsController.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.controllers import kotlinx.coroutines.CoroutineScope diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Coroutines.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Coroutines.kt index c953887..21b6fc1 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Coroutines.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Coroutines.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.utils import kotlinx.coroutines.delay diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt index c113bef..77d0d14 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.utils import kotlinx.datetime.* diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt index 1a0d27b..4476e39 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MapCalculus.kt @@ -1,7 +1,22 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.utils -import kotlin.math.roundToLong - class MapCalculus { companion object { /** diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MarkerType.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MarkerType.kt index 58d8d1c..cb2d159 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MarkerType.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/MarkerType.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.utils enum class MarkerType { diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt index 360cce8..5672536 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/ReportDates.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.utils import kotlinx.coroutines.DelicateCoroutinesApi diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/SpeedUnit.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/SpeedUnit.kt index bc9cdb4..a696b67 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/SpeedUnit.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/SpeedUnit.kt @@ -1,3 +1,20 @@ +/** + * TrackerMap + * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com> + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ package mx.trackermap.TrackerMap.utils enum class SpeedUnit { |