blob: b710763d0ecd29cbd89f6ece34dd8f13453e4621 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package mx.trackermap.TrackerMap.controllers
import mx.trackermap.TrackerMap.client.apis.CommandsApi
import mx.trackermap.TrackerMap.client.models.Command
import mx.trackermap.TrackerMap.client.models.Device
class CommandsController(
val commandsApi: CommandsApi,
val sessionController: SessionController)
{
var commands = emptyArray<Command>()
val deviceCommands = mutableMapOf<Int, Array<Command>>()
suspend fun getAllCommands () {
sessionController.user?.id?.let {
commands = commandsApi.commandsGet(userId = it)
}
}
suspend fun getDeviceCommands (device: Device) {
device.id?.let {
deviceCommands[it] = commandsApi.commandsSendGet (deviceId = device.id)
}
}
suspend fun sendCommand (command: Command) {
commandsApi.commandsSendPost(command)
}
}
|