aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt
diff options
context:
space:
mode:
authorIsidro Henoch <imhenoch@protonmail.com>2021-12-27 14:27:17 -0600
committerIsidro Henoch <imhenoch@protonmail.com>2021-12-27 14:27:17 -0600
commitf37c6de28b014af0cdbf278986a668030f54cc55 (patch)
tree2ddc6b332c2c63c27ae5656142f4d719bc140ae8 /shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt
parent7c8a65b8d1ae8a049bf67260acb6fafbd95adac9 (diff)
downloadetbsa-trackermap-mobile-f37c6de28b014af0cdbf278986a668030f54cc55.tar.gz
etbsa-trackermap-mobile-f37c6de28b014af0cdbf278986a668030f54cc55.tar.bz2
etbsa-trackermap-mobile-f37c6de28b014af0cdbf278986a668030f54cc55.zip
Implements the report functionality, UI is missing
Diffstat (limited to 'shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt164
1 files changed, 116 insertions, 48 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. &#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)
* @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"
+ )
}
}
}