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

FianceReportEntity $FianceReportEntityFromJson(Map<String, dynamic> json) {
  final FianceReportEntity fianceReportEntity = FianceReportEntity();
  final List<FianceReportRateList>? rateList = (json['rate_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<FianceReportRateList>(e) as FianceReportRateList).toList();
  if (rateList != null) {
    fianceReportEntity.rateList = rateList;
  }
  final int? requestTotal = jsonConvert.convert<int>(json['request_total']);
  if (requestTotal != null) {
    fianceReportEntity.requestTotal = requestTotal;
  }
  final int? actualTotal = jsonConvert.convert<int>(json['actual_total']);
  if (actualTotal != null) {
    fianceReportEntity.actualTotal = actualTotal;
  }
  return fianceReportEntity;
}

Map<String, dynamic> $FianceReportEntityToJson(FianceReportEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['rate_list'] = entity.rateList.map((v) => v.toJson()).toList();
  data['request_total'] = entity.requestTotal;
  data['actual_total'] = entity.actualTotal;
  return data;
}

extension FianceReportEntityExtension on FianceReportEntity {
  FianceReportEntity copyWith({
    List<FianceReportRateList>? rateList,
    int? requestTotal,
    int? actualTotal,
  }) {
    return FianceReportEntity()
      ..rateList = rateList ?? this.rateList
      ..requestTotal = requestTotal ?? this.requestTotal
      ..actualTotal = actualTotal ?? this.actualTotal;
  }
}

FianceReportRateList $FianceReportRateListFromJson(Map<String, dynamic> json) {
  final FianceReportRateList fianceReportRateList = FianceReportRateList();
  final String? day = jsonConvert.convert<String>(json['day']);
  if (day != null) {
    fianceReportRateList.day = day;
  }
  final String? weekNum = jsonConvert.convert<String>(json['week_num']);
  if (weekNum != null) {
    fianceReportRateList.weekNum = weekNum;
  }
  final String? weekStr = jsonConvert.convert<String>(json['week_str']);
  if (weekStr != null) {
    fianceReportRateList.weekStr = weekStr;
  }
  final int? request = jsonConvert.convert<int>(json['request']);
  if (request != null) {
    fianceReportRateList.request = request;
  }
  final int? actual = jsonConvert.convert<int>(json['actual']);
  if (actual != null) {
    fianceReportRateList.actual = actual;
  }
  final String? ratio = jsonConvert.convert<String>(json['ratio']);
  if (ratio != null) {
    fianceReportRateList.ratio = ratio;
  }
  return fianceReportRateList;
}

Map<String, dynamic> $FianceReportRateListToJson(FianceReportRateList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['day'] = entity.day;
  data['week_num'] = entity.weekNum;
  data['week_str'] = entity.weekStr;
  data['request'] = entity.request;
  data['actual'] = entity.actual;
  data['ratio'] = entity.ratio;
  return data;
}

extension FianceReportRateListExtension on FianceReportRateList {
  FianceReportRateList copyWith({
    String? day,
    String? weekNum,
    String? weekStr,
    int? request,
    int? actual,
    String? ratio,
  }) {
    return FianceReportRateList()
      ..day = day ?? this.day
      ..weekNum = weekNum ?? this.weekNum
      ..weekStr = weekStr ?? this.weekStr
      ..request = request ?? this.request
      ..actual = actual ?? this.actual
      ..ratio = ratio ?? this.ratio;
  }
}