aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap
diff options
context:
space:
mode:
Diffstat (limited to 'shared/src/commonMain/kotlin/mx/trackermap/TrackerMap')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt164
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Event.kt4
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Position.kt6
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Stop.kt (renamed from shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportStops.kt)15
4 files changed, 131 insertions, 58 deletions
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<Event>
*/
@Suppress("UNCHECKED_CAST")
- suspend fun reportsEventsGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array<kotlin.Int>? = null, groupId: kotlin.Array<kotlin.Int>? = null, type: kotlin.Array<kotlin.String>? = null): kotlin.Array<Event> {
- 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<Event> {
+ 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<kotlin.Array<Event>>(
- localVariableConfig
+ localVariableConfig
)
return when (response.responseType) {
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Event>
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. &#x60;1963-11-22T18:30:00Z&#x60;
- * @param to in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
+ * @param from in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
+ * @param to in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
* @param deviceId (optional)
* @param groupId (optional)
* @return kotlin.Array<Position>
*/
@Suppress("UNCHECKED_CAST")
- suspend fun reportsRouteGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array<kotlin.Int>? = null, groupId: kotlin.Array<kotlin.Int>? = null): kotlin.Array<Position> {
- 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<Position> {
+ 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<kotlin.Array<Position>>(
- localVariableConfig
+ localVariableConfig
)
return when (response.responseType) {
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Position>
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. &#x60;1963-11-22T18:30:00Z&#x60;
- * @param to in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
+ * @param from in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
+ * @param to in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
* @param deviceId (optional)
* @param groupId (optional)
* @return kotlin.Array<ReportStops>
*/
@Suppress("UNCHECKED_CAST")
- suspend fun reportsStopsGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array<kotlin.Int>? = null, groupId: kotlin.Array<kotlin.Int>? = null): kotlin.Array<ReportStops> {
- 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<Stop> {
+ 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<kotlin.Array<ReportStops>>(
- localVariableConfig
+ val response = request<kotlin.Array<Stop>>(
+ localVariableConfig
)
return when (response.responseType) {
- ResponseType.Success -> (response as Success<*>).data as kotlin.Array<ReportStops>
+ ResponseType.Success -> (response as Success<*>).data as kotlin.Array<Stop>
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. &#x60;1963-11-22T18:30:00Z&#x60;
- * @param to in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
+ * @param from in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
+ * @param to in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
* @param deviceId (optional)
* @param groupId (optional)
* @return kotlin.Array<ReportSummary>
*/
@Suppress("UNCHECKED_CAST")
- suspend fun reportsSummaryGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array<kotlin.Int>? = null, groupId: kotlin.Array<kotlin.Int>? = null): kotlin.Array<ReportSummary> {
- 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<kotlin.Int>? = null,
+ groupId: kotlin.Array<kotlin.Int>? = null
+ ): kotlin.Array<ReportSummary> {
+ 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<kotlin.Array<ReportSummary>>(
- localVariableConfig
+ localVariableConfig
)
return when (response.responseType) {
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<ReportSummary>
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. &#x60;1963-11-22T18:30:00Z&#x60;
- * @param to in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
+ * @param from in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
+ * @param to in IS0 8601 format. eg. &#x60;1963-11-22T18:30:00Z&#x60;
* @param deviceId (optional)
* @param groupId (optional)
* @return kotlin.Array<ReportTrips>
*/
@Suppress("UNCHECKED_CAST")
- suspend fun reportsTripsGet(from: java.time.LocalDateTime, to: java.time.LocalDateTime, deviceId: kotlin.Array<kotlin.Int>? = null, groupId: kotlin.Array<kotlin.Int>? = null): kotlin.Array<ReportTrips> {
- 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<kotlin.Int>? = null,
+ groupId: kotlin.Array<kotlin.Int>? = null
+ ): kotlin.Array<ReportTrips> {
+ 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<kotlin.Array<ReportTrips>>(
- localVariableConfig
+ localVariableConfig
)
return when (response.responseType) {
ResponseType.Success -> (response as Success<*>).data as kotlin.Array<ReportTrips>
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/Stop.kt
index bdd4cbe..c06b864 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/ReportStops.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/Stop.kt
@@ -11,6 +11,8 @@
*/
package mx.trackermap.TrackerMap.client.models
+import kotlinx.serialization.Serializable
+
/**
*
@@ -25,20 +27,21 @@ package mx.trackermap.TrackerMap.client.models
* @param spentFuel in liters
* @param engineHours
*/
-data class ReportStops (
+@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: java.time.LocalDateTime? = null,
+ val startTime: String? = null,
val address: kotlin.String? = null,
- val lat: java.math.BigDecimal? = null,
- val lon: java.math.BigDecimal? = null,
+ val lat: Double? = null,
+ val lon: Double? = null,
/* in IS0 8601 format. eg. `1963-11-22T18:30:00Z` */
- val endTime: java.time.LocalDateTime? = null,
+ val endTime: String? = null,
/* in liters */
- val spentFuel: java.math.BigDecimal? = null,
+ val spentFuel: Double? = null,
val engineHours: kotlin.Int? = null
) {
} \ No newline at end of file