import 'package:syncrow_web/pages/device_managment/all_devices/models/device_status.dart';

class OneGangGlassStatusModel {
  final String uuid;
  final bool switch1;
  final int countDown;

  OneGangGlassStatusModel({
    required this.uuid,
    required this.switch1,
    required this.countDown,
  });

  factory OneGangGlassStatusModel.fromJson(String id, List<Status> jsonList) {
    late bool switch1;
    late int countDown;

    for (var status in jsonList) {
      switch (status.code) {
        case 'switch_1':
          switch1 = status.value ?? false;
          break;
        case 'countdown_1':
          countDown = status.value ?? 0;
          break;
      }
    }

    return OneGangGlassStatusModel(
      uuid: id,
      switch1: switch1,
      countDown: countDown,
    );
  }

  OneGangGlassStatusModel copyWith({
    String? uuid,
    bool? switch1,
    int? countDown,
  }) {
    return OneGangGlassStatusModel(
      uuid: uuid ?? this.uuid,
      switch1: switch1 ?? this.switch1,
      countDown: countDown ?? this.countDown,
    );
  }

  @override
  String toString() => 'OneGangGlassStatusModel(uuid: $uuid, switch1: $switch1, countDown: $countDown)';
}
