import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/response/device_list_entity.dart';

DeviceListEntity $DeviceListEntityFromJson(Map<String, dynamic> json) {
  final DeviceListEntity deviceListEntity = DeviceListEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    deviceListEntity.total = total;
  }
  final List<DeviceListRows>? rows = (json['rows'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<DeviceListRows>(e) as DeviceListRows).toList();
  if (rows != null) {
    deviceListEntity.rows = rows;
  }
  return deviceListEntity;
}

Map<String, dynamic> $DeviceListEntityToJson(DeviceListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['rows'] = entity.rows.map((v) => v.toJson()).toList();
  return data;
}

extension DeviceListEntityExtension on DeviceListEntity {
  DeviceListEntity copyWith({
    int? total,
    List<DeviceListRows>? rows,
  }) {
    return DeviceListEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

DeviceListRows $DeviceListRowsFromJson(Map<String, dynamic> json) {
  final DeviceListRows deviceListRows = DeviceListRows();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    deviceListRows.id = id;
  }
  final String? deviceKey = jsonConvert.convert<String>(json['device_key']);
  if (deviceKey != null) {
    deviceListRows.deviceKey = deviceKey;
  }
  final String? deviceMac = jsonConvert.convert<String>(json['device_mac']);
  if (deviceMac != null) {
    deviceListRows.deviceMac = deviceMac;
  }
  final String? deviceAlias = jsonConvert.convert<String>(json['device_alias']);
  if (deviceAlias != null) {
    deviceListRows.deviceAlias = deviceAlias;
  }
  final int? siteType = jsonConvert.convert<int>(json['site_type']);
  if (siteType != null) {
    deviceListRows.siteType = siteType;
  }
  final int? originType = jsonConvert.convert<int>(json['origin_type']);
  if (originType != null) {
    deviceListRows.originType = originType;
  }
  final int? aliveState = jsonConvert.convert<int>(json['alive_state']);
  if (aliveState != null) {
    deviceListRows.aliveState = aliveState;
  }
  final String? lastOnline = jsonConvert.convert<String>(json['last_online']);
  if (lastOnline != null) {
    deviceListRows.lastOnline = lastOnline;
  }
  final String? siteTypeShow = jsonConvert.convert<String>(json['site_type_show']);
  if (siteTypeShow != null) {
    deviceListRows.siteTypeShow = siteTypeShow;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    deviceListRows.createdAt = createdAt;
  }
  final String? deviceName = jsonConvert.convert<String>(json['device_name']);
  if (deviceName != null) {
    deviceListRows.deviceName = deviceName;
  }
  final String? deviceNo = jsonConvert.convert<String>(json['device_no']);
  if (deviceNo != null) {
    deviceListRows.deviceNo = deviceNo;
  }
  final String? isOnline = jsonConvert.convert<String>(json['is_online']);
  if (isOnline != null) {
    deviceListRows.isOnline = isOnline;
  }
  final String? siteShow = jsonConvert.convert<String>(json['site_show']);
  if (siteShow != null) {
    deviceListRows.siteShow = siteShow;
  }
  return deviceListRows;
}

Map<String, dynamic> $DeviceListRowsToJson(DeviceListRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['device_key'] = entity.deviceKey;
  data['device_mac'] = entity.deviceMac;
  data['device_alias'] = entity.deviceAlias;
  data['site_type'] = entity.siteType;
  data['origin_type'] = entity.originType;
  data['alive_state'] = entity.aliveState;
  data['last_online'] = entity.lastOnline;
  data['site_type_show'] = entity.siteTypeShow;
  data['created_at'] = entity.createdAt;
  data['device_name'] = entity.deviceName;
  data['device_no'] = entity.deviceNo;
  data['is_online'] = entity.isOnline;
  data['site_show'] = entity.siteShow;
  return data;
}

extension DeviceListRowsExtension on DeviceListRows {
  DeviceListRows copyWith({
    int? id,
    String? deviceKey,
    String? deviceMac,
    String? deviceAlias,
    int? siteType,
    int? originType,
    int? aliveState,
    String? lastOnline,
    String? siteTypeShow,
    String? createdAt,
    String? deviceName,
    String? deviceNo,
    String? isOnline,
    String? siteShow,
  }) {
    return DeviceListRows()
      ..id = id ?? this.id
      ..deviceKey = deviceKey ?? this.deviceKey
      ..deviceMac = deviceMac ?? this.deviceMac
      ..deviceAlias = deviceAlias ?? this.deviceAlias
      ..siteType = siteType ?? this.siteType
      ..originType = originType ?? this.originType
      ..aliveState = aliveState ?? this.aliveState
      ..lastOnline = lastOnline ?? this.lastOnline
      ..siteTypeShow = siteTypeShow ?? this.siteTypeShow
      ..createdAt = createdAt ?? this.createdAt
      ..deviceName = deviceName ?? this.deviceName
      ..deviceNo = deviceNo ?? this.deviceNo
      ..isOnline = isOnline ?? this.isOnline
      ..siteShow = siteShow ?? this.siteShow;
  }
}