diff options
author | Iván Ávalos <avalos@disroot.org> | 2022-01-16 18:28:14 -0600 |
---|---|---|
committer | Iván Ávalos <avalos@disroot.org> | 2022-01-16 18:28:14 -0600 |
commit | 88d35312f8718ab4379448a1b5aeac2b2db2b944 (patch) | |
tree | b4210a6abeed10b1bf6c8486462495d46e4a9566 /shared | |
parent | 61e870d01805d8eadb870b98c33eab64d9deb1af (diff) | |
download | etbsa-trackermap-mobile-88d35312f8718ab4379448a1b5aeac2b2db2b944.tar.gz etbsa-trackermap-mobile-88d35312f8718ab4379448a1b5aeac2b2db2b944.tar.bz2 etbsa-trackermap-mobile-88d35312f8718ab4379448a1b5aeac2b2db2b944.zip |
Fixed event report types on API
Diffstat (limited to 'shared')
3 files changed, 13 insertions, 13 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 3765207..d77064e 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 @@ -36,14 +36,14 @@ class ReportsApi(basePath: String = "https://demo.traccar.org/api") : ApiClient( from: String, to: String, deviceId: Int, - type: String = "%", + types: List<String> = listOf("%"), xlsx: Boolean = false ): Any { val localVariableQuery: MultiValueMap = mapOf( "deviceId" to toMultiValue(listOf(deviceId), "multi"), "from" to listOf(from), "to" to listOf(to), - "type" to listOf(type) + "type" to types ) val localVariableHeaders = mutableMapOf<String, String>() if (xlsx) { @@ -81,20 +81,20 @@ class ReportsApi(basePath: String = "https://demo.traccar.org/api") : ApiClient( suspend fun reportsEventsGet( from: String, to: String, - type: String = "%", + types: List<String> = listOf("%"), deviceId: Int, ): Array<Event> { - return reportsEventsGetBase(from, to, deviceId, type, false) as Array<Event> + return reportsEventsGetBase(from, to, deviceId, types, false) as Array<Event> } @Suppress("UNCHECKED_CAST") suspend fun reportsEventsGetXlsx( from: String, to: String, - type: String = "%", + types: List<String> = listOf("%"), deviceId: Int, ): ByteArray { - return reportsEventsGetBase(from, to, deviceId, type, true) as ByteArray + return reportsEventsGetBase(from, to, deviceId, types, true) as ByteArray } /** 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 befd8f1..5e4b2d5 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 @@ -51,11 +51,11 @@ data class EventInformation( Type.UNKNOWN -> "unknown" } - fun reportTypesToString(t: Array<Type>) = + fun reportTypesToStrings(t: List<Type>) = if (t.isEmpty() || t.contains(Type.ALL)) { - reportTypeToString(Type.ALL) + listOf(reportTypeToString(Type.ALL)) } else { - t.joinToString(",", transform = this::reportTypeToString) + t.map(this::reportTypeToString) } fun stringToReportType(s: String) = 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 8a7f527..78f0173 100644 --- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt +++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt @@ -37,7 +37,7 @@ class ReportController( reportType: ReportType?, reportPeriod: ReportDates.ReportPeriod?, xlsx: Boolean = false, - eventTypes: Array<EventInformation.Type> = arrayOf() + eventTypes: List<EventInformation.Type> = listOf() ) { if (reportType == null || reportPeriod == null) { return @@ -85,7 +85,7 @@ class ReportController( deviceId: Int, from: String, to: String, - types: Array<EventInformation.Type>, + types: List<EventInformation.Type>, xlsx: Boolean ) { Log.d("UnitReportsVM", "Fetching events") @@ -93,7 +93,7 @@ class ReportController( if (!xlsx) { val positionsResult = reportsApi.reportsRouteGet(from, to, deviceId) val eventsResult = reportsApi.reportsEventsGet( - from, to, EventInformation.reportTypesToString(types), deviceId + from, to, EventInformation.reportTypesToStrings(types), deviceId ) val geofencesResult = geofencesApi.geofencesGet(all = true) @@ -110,7 +110,7 @@ class ReportController( reportFlow.value = Report.EventsReport(result.toTypedArray()) } else { val result = reportsApi.reportsEventsGetXlsx( - from, to, EventInformation.reportTypesToString(types), deviceId + from, to, EventInformation.reportTypesToStrings(types), deviceId ) Log.d("UnitReportsVM", "Events report: $result") |