mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 15:17:31 +00:00
35 lines
809 B
Dart
35 lines
809 B
Dart
import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';
|
|
|
|
class SosStatusModel {
|
|
final int batteryLevel;
|
|
final String sosStatus;
|
|
final String deviceId;
|
|
|
|
SosStatusModel({
|
|
required this.batteryLevel,
|
|
required this.sosStatus,
|
|
required this.deviceId,
|
|
});
|
|
|
|
factory SosStatusModel.fromJson(String deviceId, List<Status> statuses) {
|
|
late int batteryLevel;
|
|
late String sosStatus;
|
|
|
|
for (var status in statuses) {
|
|
switch (status.code) {
|
|
case 'battery_percentage':
|
|
batteryLevel = status.value;
|
|
break;
|
|
case 'sos':
|
|
sosStatus = status.value;
|
|
break;
|
|
}
|
|
}
|
|
return SosStatusModel(
|
|
deviceId: deviceId,
|
|
batteryLevel: batteryLevel,
|
|
sosStatus: sosStatus,
|
|
);
|
|
}
|
|
}
|