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

LabourRequestEREntity $LabourRequestEREntityFromJson(Map<String, dynamic> json) {
  final LabourRequestEREntity labourRequestEREntity = LabourRequestEREntity();
  final List<LabourRequestERCountList>? countList = (json['count_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<LabourRequestERCountList>(e) as LabourRequestERCountList).toList();
  if (countList != null) {
    labourRequestEREntity.countList = countList;
  }
  final List<LabourRequestERSourceList>? sourceList = (json['source_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<LabourRequestERSourceList>(e) as LabourRequestERSourceList).toList();
  if (sourceList != null) {
    labourRequestEREntity.sourceList = sourceList;
  }
  final String? view = jsonConvert.convert<String>(json['view']);
  if (view != null) {
    labourRequestEREntity.view = view;
  }
  return labourRequestEREntity;
}

Map<String, dynamic> $LabourRequestEREntityToJson(LabourRequestEREntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['count_list'] = entity.countList.map((v) => v.toJson()).toList();
  data['source_list'] = entity.sourceList.map((v) => v.toJson()).toList();
  data['view'] = entity.view;
  return data;
}

extension LabourRequestEREntityExtension on LabourRequestEREntity {
  LabourRequestEREntity copyWith({
    List<LabourRequestERCountList>? countList,
    List<LabourRequestERSourceList>? sourceList,
    String? view,
  }) {
    return LabourRequestEREntity()
      ..countList = countList ?? this.countList
      ..sourceList = sourceList ?? this.sourceList
      ..view = view ?? this.view;
  }
}

LabourRequestERCountList $LabourRequestERCountListFromJson(Map<String, dynamic> json) {
  final LabourRequestERCountList labourRequestERCountList = LabourRequestERCountList();
  final String? date = jsonConvert.convert<String>(json['date']);
  if (date != null) {
    labourRequestERCountList.date = date;
  }
  final String? week = jsonConvert.convert<String>(json['week']);
  if (week != null) {
    labourRequestERCountList.week = week;
  }
  final String? num = jsonConvert.convert<String>(json['num']);
  if (num != null) {
    labourRequestERCountList.num = num;
  }
  return labourRequestERCountList;
}

Map<String, dynamic> $LabourRequestERCountListToJson(LabourRequestERCountList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['date'] = entity.date;
  data['week'] = entity.week;
  data['num'] = entity.num;
  return data;
}

extension LabourRequestERCountListExtension on LabourRequestERCountList {
  LabourRequestERCountList copyWith({
    String? date,
    String? week,
    String? num,
  }) {
    return LabourRequestERCountList()
      ..date = date ?? this.date
      ..week = week ?? this.week
      ..num = num ?? this.num;
  }
}

LabourRequestERSourceList $LabourRequestERSourceListFromJson(Map<String, dynamic> json) {
  final LabourRequestERSourceList labourRequestERSourceList = LabourRequestERSourceList();
  final String? agencyId = jsonConvert.convert<String>(json['agency_id']);
  if (agencyId != null) {
    labourRequestERSourceList.agencyId = agencyId;
  }
  final String? agencyName = jsonConvert.convert<String>(json['agency_name']);
  if (agencyName != null) {
    labourRequestERSourceList.agencyName = agencyName;
  }
  final List<LabourRequestERSourceListRequestList>? requestList = (json['request_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<LabourRequestERSourceListRequestList>(e) as LabourRequestERSourceListRequestList).toList();
  if (requestList != null) {
    labourRequestERSourceList.requestList = requestList;
  }
  return labourRequestERSourceList;
}

Map<String, dynamic> $LabourRequestERSourceListToJson(LabourRequestERSourceList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['agency_id'] = entity.agencyId;
  data['agency_name'] = entity.agencyName;
  data['request_list'] = entity.requestList?.map((v) => v.toJson()).toList();
  return data;
}

extension LabourRequestERSourceListExtension on LabourRequestERSourceList {
  LabourRequestERSourceList copyWith({
    String? agencyId,
    String? agencyName,
    List<LabourRequestERSourceListRequestList>? requestList,
  }) {
    return LabourRequestERSourceList()
      ..agencyId = agencyId ?? this.agencyId
      ..agencyName = agencyName ?? this.agencyName
      ..requestList = requestList ?? this.requestList;
  }
}

LabourRequestERSourceListRequestList $LabourRequestERSourceListRequestListFromJson(Map<String, dynamic> json) {
  final LabourRequestERSourceListRequestList labourRequestERSourceListRequestList = LabourRequestERSourceListRequestList();
  final String? date = jsonConvert.convert<String>(json['date']);
  if (date != null) {
    labourRequestERSourceListRequestList.date = date;
  }
  final String? num = jsonConvert.convert<String>(json['num']);
  if (num != null) {
    labourRequestERSourceListRequestList.num = num;
  }
  return labourRequestERSourceListRequestList;
}

Map<String, dynamic> $LabourRequestERSourceListRequestListToJson(LabourRequestERSourceListRequestList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['date'] = entity.date;
  data['num'] = entity.num;
  return data;
}

extension LabourRequestERSourceListRequestListExtension on LabourRequestERSourceListRequestList {
  LabourRequestERSourceListRequestList copyWith({
    String? date,
    String? num,
  }) {
    return LabourRequestERSourceListRequestList()
      ..date = date ?? this.date
      ..num = num ?? this.num;
  }
}