class DeviceReport {
  final dynamic deviceUuid;
  final dynamic startTime;
  final dynamic endTime;
  final List<DeviceEvent>? data;

  DeviceReport({
    this.deviceUuid,
    this.startTime,
    this.endTime,
    this.data,
  });

  DeviceReport.fromJson(Map<String, dynamic> json)
      : deviceUuid = json['deviceUuid'] as String?,
        startTime = json['startTime'] as String?,
        endTime = json['endTime'] as String?,
        data = (json['data'] as List<dynamic>?)
            ?.map((e) => DeviceEvent.fromJson(e as Map<String, dynamic>))
            .toList();

  Map<String, dynamic> toJson() => {
        'deviceUuid': deviceUuid,
        'startTime': startTime,
        'endTime': endTime,
        'data': data?.map((e) => e.toJson()).toList(),
      };
}

class EventDevice {
  final String? code;
  final DateTime? eventTime;
  final String? value;

  EventDevice({
    this.code,
    this.eventTime,
    this.value,
  });

  EventDevice.fromJson(Map<String, dynamic> json)
      : code = json['code'] as String?,
        eventTime = json['eventTime'] ,
        value = json['value'] as String?;

  Map<String, dynamic> toJson() => {
        'code': code,
        'eventTime': eventTime,
        'value': value,
      };
}





class DeviceEvent {
  final String? code;
  final int? eventTime;
  final String? value;

  DeviceEvent({
    this.code,
    this.eventTime,
    this.value,
  });

  DeviceEvent.fromJson(Map<String, dynamic> json)
      : code = json['code'] as String?,
        eventTime = json['eventTime'] as int?,
        value = json['value'] as String?;

  Map<String, dynamic> toJson() => {
        'code': code,
        'eventTime': eventTime,
        'value': value,
      };
}
