import 'package:equatable/equatable.dart';

class InspectionRoomBO extends Equatable {
  final int roomId;
  final String roomNumber;
  final InspectionRoomRunStatusBO runStatus;

  const InspectionRoomBO({
    required this.roomId,
    required this.roomNumber,
    required this.runStatus,
  });

  factory InspectionRoomBO.fromJson(Map<String, dynamic> json) {
    return InspectionRoomBO(
      roomId: int.tryParse(json['roomId']?.toString() ?? '') ?? 0,
      roomNumber: json['roomNumber'] as String? ?? '',
      runStatus: InspectionRoomRunStatusBO.fromJson(
        json['runStatus'] as Map<String, dynamic>? ?? {},
      ),
    );
  }

  @override
  List<Object?> get props => [roomId, roomNumber, runStatus];
}

class InspectionRoomRunStatusBO extends Equatable {
  final int normal;
  final int warning;
  final int offline;
  final int fault;

  const InspectionRoomRunStatusBO({
    required this.normal,
    required this.warning,
    required this.offline,
    required this.fault,
  });

  factory InspectionRoomRunStatusBO.fromJson(Map<String, dynamic> json) {
    return InspectionRoomRunStatusBO(
      normal: int.tryParse(json['normal']?.toString() ?? '') ?? 0,
      warning: int.tryParse(json['warning']?.toString() ?? '') ?? 0,
      offline: int.tryParse(json['offline']?.toString() ?? '') ?? 0,
      fault: int.tryParse(json['fault']?.toString() ?? '') ?? 0,
    );
  }

  @override
  List<Object?> get props => [normal, warning, offline, fault];
}