aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain/kotlin
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-16 18:28:14 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-16 18:28:14 -0600
commitf133dc96d4072c3bf4f9794b000b1e0ab946f96b (patch)
treeb4210a6abeed10b1bf6c8486462495d46e4a9566 /shared/src/commonMain/kotlin
parent21e16e27f047053582d8b0c722feedf3c8badebe (diff)
downloadetbsa-trackermap-mobile-f133dc96d4072c3bf4f9794b000b1e0ab946f96b.tar.gz
etbsa-trackermap-mobile-f133dc96d4072c3bf4f9794b000b1e0ab946f96b.tar.bz2
etbsa-trackermap-mobile-f133dc96d4072c3bf4f9794b000b1e0ab946f96b.zip
Fixed event report types on API
Diffstat (limited to 'shared/src/commonMain/kotlin')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/apis/ReportsApi.kt12
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/client/models/EventInformation.kt6
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/controllers/ReportController.kt8
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")