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,
    );
  }
}
