diff options
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.kt | 164 |
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. `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. `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<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. `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<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. `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<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. `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<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" + ) } } } |