From f37c6de28b014af0cdbf278986a668030f54cc55 Mon Sep 17 00:00:00 2001 From: Isidro Henoch Date: Mon, 27 Dec 2021 14:27:17 -0600 Subject: Implements the report functionality, UI is missing --- .../TrackerMap/client/apis/ReportsApi.kt | 164 +++++++++++++++------ .../trackermap/TrackerMap/client/models/Event.kt | 4 +- .../TrackerMap/client/models/Position.kt | 6 +- .../TrackerMap/client/models/ReportStops.kt | 44 ------ .../mx/trackermap/TrackerMap/client/models/Stop.kt | 47 ++++++ 5 files changed, 169 insertions(+), 96 deletions(-) delete mode 100644 shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportStops.kt create mode 100644 shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Stop.kt (limited to 'shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client') 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 0caa945..43feaa6 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 @@ -13,7 +13,7 @@ package mx.trackermap.TrackerMap.client.apis import mx.trackermap.TrackerMap.client.models.Event import mx.trackermap.TrackerMap.client.models.Position -import mx.trackermap.TrackerMap.client.models.ReportStops +import mx.trackermap.TrackerMap.client.models.Stop import mx.trackermap.TrackerMap.client.models.ReportSummary import mx.trackermap.TrackerMap.client.models.ReportTrips @@ -24,142 +24,210 @@ class ReportsApi(basePath: kotlin.String = "https://demo.traccar.org/api") : Api /** * Fetch a list of Events within the time period for the Devices or Groups * At least one _deviceId_ or one _groupId_ must be passed - * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` - * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` * @param deviceId (optional) * @param groupId (optional) * @param type % can be used to return events of all types (optional) * @return kotlin.Array */ @Suppress("UNCHECKED_CAST") - suspend fun reportsEventsGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array? = null, groupId: kotlin.Array? = null, type: kotlin.Array? = null): kotlin.Array { - val localVariableQuery: MultiValueMap = mapOf("deviceId" to toMultiValue(deviceId!!.toList(), "multi"), "groupId" to toMultiValue(groupId!!.toList(), "multi"), "type" to toMultiValue(type!!.toList(), "csv"), "from" to listOf("$from"), "to" to listOf("$to")) + suspend fun reportsEventsGet( + from: String, + to: String, + deviceId: Int + ): kotlin.Array { + val localVariableQuery: MultiValueMap = mapOf( + "deviceId" to toMultiValue(listOf(deviceId), "multi"), + "from" to listOf(from), + "to" to listOf(to) + ) val localVariableConfig = RequestConfig( - RequestMethod.GET, - "/reports/events", query = localVariableQuery + RequestMethod.GET, + "/reports/events", query = localVariableQuery ) val response = request>( - localVariableConfig + localVariableConfig ) return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException( + (response as ClientError<*>).body as? String ?: "Client error" + ) + ResponseType.ServerError -> throw ServerException( + (response as ServerError<*>).message ?: "Server error" + ) } } + /** * Fetch a list of Positions within the time period for the Devices or Groups * At least one _deviceId_ or one _groupId_ must be passed - * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` - * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` * @param deviceId (optional) * @param groupId (optional) * @return kotlin.Array */ @Suppress("UNCHECKED_CAST") - suspend fun reportsRouteGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array? = null, groupId: kotlin.Array? = null): kotlin.Array { - val localVariableQuery: MultiValueMap = mapOf("deviceId" to toMultiValue(deviceId!!.toList(), "multi"), "groupId" to toMultiValue(groupId!!.toList(), "multi"), "from" to listOf("$from"), "to" to listOf("$to")) + suspend fun reportsRouteGet( + from: String, + to: String, + deviceId: Int + ): kotlin.Array { + val localVariableQuery: MultiValueMap = mapOf( + "deviceId" to toMultiValue(listOf(deviceId), "multi"), + "from" to listOf(from), + "to" to listOf(to) + ) val localVariableConfig = RequestConfig( - RequestMethod.GET, - "/reports/route", query = localVariableQuery + RequestMethod.GET, + "/reports/route", query = localVariableQuery ) val response = request>( - localVariableConfig + localVariableConfig ) return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException( + (response as ClientError<*>).body as? String ?: "Client error" + ) + ResponseType.ServerError -> throw ServerException( + (response as ServerError<*>).message ?: "Server error" + ) } } + /** * Fetch a list of ReportStops within the time period for the Devices or Groups * At least one _deviceId_ or one _groupId_ must be passed - * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` - * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` * @param deviceId (optional) * @param groupId (optional) * @return kotlin.Array */ @Suppress("UNCHECKED_CAST") - suspend fun reportsStopsGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array? = null, groupId: kotlin.Array? = null): kotlin.Array { - val localVariableQuery: MultiValueMap = mapOf("deviceId" to toMultiValue(deviceId!!.toList(), "multi"), "groupId" to toMultiValue(groupId!!.toList(), "multi"), "from" to listOf("$from"), "to" to listOf("$to")) + suspend fun reportsStopsGet( + from: String, + to: String, + deviceId: Int + ): kotlin.Array { + val localVariableQuery: MultiValueMap = mapOf( + "deviceId" to toMultiValue(listOf(deviceId), "multi"), + "from" to listOf(from), + "to" to listOf(to) + ) val localVariableConfig = RequestConfig( - RequestMethod.GET, - "/reports/stops", query = localVariableQuery + RequestMethod.GET, + "/reports/stops", query = localVariableQuery ) - val response = request>( - localVariableConfig + val response = request>( + localVariableConfig ) return when (response.responseType) { - ResponseType.Success -> (response as Success<*>).data as kotlin.Array + ResponseType.Success -> (response as Success<*>).data as kotlin.Array ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException( + (response as ClientError<*>).body as? String ?: "Client error" + ) + ResponseType.ServerError -> throw ServerException( + (response as ServerError<*>).message ?: "Server error" + ) } } + /** * Fetch a list of ReportSummary within the time period for the Devices or Groups * At least one _deviceId_ or one _groupId_ must be passed - * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` - * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` * @param deviceId (optional) * @param groupId (optional) * @return kotlin.Array */ @Suppress("UNCHECKED_CAST") - suspend fun reportsSummaryGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array? = null, groupId: kotlin.Array? = null): kotlin.Array { - val localVariableQuery: MultiValueMap = mapOf("deviceId" to toMultiValue(deviceId!!.toList(), "multi"), "groupId" to toMultiValue(groupId!!.toList(), "multi"), "from" to listOf("$from"), "to" to listOf("$to")) + suspend fun reportsSummaryGet( + from: java.time.LocalDateTime, + to: java.time.LocalDateTime, + deviceId: kotlin.Array? = null, + groupId: kotlin.Array? = null + ): kotlin.Array { + val localVariableQuery: MultiValueMap = mapOf( + "deviceId" to toMultiValue(deviceId!!.toList(), "multi"), + "groupId" to toMultiValue(groupId!!.toList(), "multi"), + "from" to listOf("$from"), + "to" to listOf("$to") + ) val localVariableConfig = RequestConfig( - RequestMethod.GET, - "/reports/summary", query = localVariableQuery + RequestMethod.GET, + "/reports/summary", query = localVariableQuery ) val response = request>( - localVariableConfig + localVariableConfig ) return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException( + (response as ClientError<*>).body as? String ?: "Client error" + ) + ResponseType.ServerError -> throw ServerException( + (response as ServerError<*>).message ?: "Server error" + ) } } + /** * Fetch a list of ReportTrips within the time period for the Devices or Groups * At least one _deviceId_ or one _groupId_ must be passed - * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` - * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param from in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param to in IS0 8601 format. eg. `1963-11-22T18:30:00Z` * @param deviceId (optional) * @param groupId (optional) * @return kotlin.Array */ @Suppress("UNCHECKED_CAST") - suspend fun reportsTripsGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array? = null, groupId: kotlin.Array? = null): kotlin.Array { - val localVariableQuery: MultiValueMap = mapOf("deviceId" to toMultiValue(deviceId!!.toList(), "multi"), "groupId" to toMultiValue(groupId!!.toList(), "multi"), "from" to listOf("$from"), "to" to listOf("$to")) + suspend fun reportsTripsGet( + from: java.time.LocalDateTime, + to: java.time.LocalDateTime, + deviceId: kotlin.Array? = null, + groupId: kotlin.Array? = null + ): kotlin.Array { + val localVariableQuery: MultiValueMap = mapOf( + "deviceId" to toMultiValue(deviceId!!.toList(), "multi"), + "groupId" to toMultiValue(groupId!!.toList(), "multi"), + "from" to listOf("$from"), + "to" to listOf("$to") + ) val localVariableConfig = RequestConfig( - RequestMethod.GET, - "/reports/trips", query = localVariableQuery + RequestMethod.GET, + "/reports/trips", query = localVariableQuery ) val response = request>( - localVariableConfig + localVariableConfig ) return when (response.responseType) { ResponseType.Success -> (response as Success<*>).data as kotlin.Array ResponseType.Informational -> TODO() ResponseType.Redirection -> TODO() - ResponseType.ClientError -> throw ClientException((response as ClientError<*>).body as? String ?: "Client error") - ResponseType.ServerError -> throw ServerException((response as ServerError<*>).message ?: "Server error") + ResponseType.ClientError -> throw ClientException( + (response as ClientError<*>).body as? String ?: "Client error" + ) + ResponseType.ServerError -> throw ServerException( + (response as ServerError<*>).message ?: "Server error" + ) } } } diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Event.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Event.kt index e504600..741ae57 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Event.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Event.kt @@ -11,6 +11,7 @@ */ package mx.trackermap.TrackerMap.client.models +import kotlinx.serialization.Serializable import kotlinx.serialization.json.JsonPrimitive @@ -25,12 +26,13 @@ import kotlinx.serialization.json.JsonPrimitive * @param maintenanceId * @param attributes */ +@Serializable data class Event ( val id: Int? = null, val type: String? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ - val eventTime: java.time.LocalDateTime? = null, + val eventTime: String? = null, val deviceId: Int? = null, val positionId: Int? = null, val geofenceId: Int? = null, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt index 9a16615..5286b46 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt @@ -46,11 +46,11 @@ data class Position ( val deviceId: Int? = null, val protocol: String? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ -// val deviceTime: LocalDateTime? = null, + val deviceTime: String? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ -// val fixTime: LocalDateTime? = null, + val fixTime: String? = null, /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ -// val serverTime: LocalDateTime? = null, + val serverTime: String? = null, val outdated: Boolean? = null, val valid: Boolean? = null, val latitude: Double? = null, diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportStops.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportStops.kt deleted file mode 100644 index bdd4cbe..0000000 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportStops.kt +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Traccar - * Traccar GPS tracking server API documentation. To use the API you need to have a server instance. For testing purposes you can use one of free [demo servers](https://www.traccar.org/demo-server/). For production use you can install your own server or get a [subscription service](https://www.traccar.org/product/tracking-server/). - * - * OpenAPI spec version: 4.14 - * Contact: support@traccar.org - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ -package mx.trackermap.TrackerMap.client.models - - -/** - * - * @param deviceId - * @param deviceName - * @param duration - * @param startTime in IS0 8601 format. eg. `1963-11-22T18:30:00Z` - * @param address - * @param lat - * @param lon - * @param endTime in IS0 8601 format. eg. `1963-11-22T18:30:00Z` - * @param spentFuel in liters - * @param engineHours - */ -data class ReportStops ( - - val deviceId: kotlin.Int? = null, - val deviceName: kotlin.String? = null, - val duration: kotlin.Int? = null, - /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ - val startTime: java.time.LocalDateTime? = null, - val address: kotlin.String? = null, - val lat: java.math.BigDecimal? = null, - val lon: java.math.BigDecimal? = null, - /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ - val endTime: java.time.LocalDateTime? = null, - /* in liters */ - val spentFuel: java.math.BigDecimal? = null, - val engineHours: kotlin.Int? = null -) { -} \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Stop.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Stop.kt new file mode 100644 index 0000000..c06b864 --- /dev/null +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Stop.kt @@ -0,0 +1,47 @@ +/** + * Traccar + * Traccar GPS tracking server API documentation. To use the API you need to have a server instance. For testing purposes you can use one of free [demo servers](https://www.traccar.org/demo-server/). For production use you can install your own server or get a [subscription service](https://www.traccar.org/product/tracking-server/). + * + * OpenAPI spec version: 4.14 + * Contact: support@traccar.org + * + * NOTE: This class is auto generated by the swagger code generator program. + * https://github.com/swagger-api/swagger-codegen.git + * Do not edit the class manually. + */ +package mx.trackermap.TrackerMap.client.models + +import kotlinx.serialization.Serializable + + +/** + * + * @param deviceId + * @param deviceName + * @param duration + * @param startTime in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param address + * @param lat + * @param lon + * @param endTime in IS0 8601 format. eg. `1963-11-22T18:30:00Z` + * @param spentFuel in liters + * @param engineHours + */ +@Serializable +data class Stop ( + + val deviceId: kotlin.Int? = null, + val deviceName: kotlin.String? = null, + val duration: kotlin.Int? = null, + /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ + val startTime: String? = null, + val address: kotlin.String? = null, + val lat: Double? = null, + val lon: Double? = null, + /* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */ + val endTime: String? = null, + /* in liters */ + val spentFuel: Double? = null, + val engineHours: kotlin.Int? = null +) { +} \ No newline at end of file -- cgit v1.2.3