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

SGDashboardEntity $SGDashboardEntityFromJson(Map<String, dynamic> json) {
  final SGDashboardEntity sGDashboardEntity = SGDashboardEntity();
  final String? day = jsonConvert.convert<String>(json['day']);
  if (day != null) {
    sGDashboardEntity.day = day;
  }
  final List<SGDashboardAgencyList>? agencyList = (json['agency_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<SGDashboardAgencyList>(e) as SGDashboardAgencyList).toList();
  if (agencyList != null) {
    sGDashboardEntity.agencyList = agencyList;
  }
  return sGDashboardEntity;
}

Map<String, dynamic> $SGDashboardEntityToJson(SGDashboardEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['day'] = entity.day;
  data['agency_list'] = entity.agencyList.map((v) => v.toJson()).toList();
  return data;
}

extension SGDashboardEntityExtension on SGDashboardEntity {
  SGDashboardEntity copyWith({
    String? day,
    List<SGDashboardAgencyList>? agencyList,
  }) {
    return SGDashboardEntity()
      ..day = day ?? this.day
      ..agencyList = agencyList ?? this.agencyList;
  }
}

SGDashboardAgencyList $SGDashboardAgencyListFromJson(Map<String, dynamic> json) {
  final SGDashboardAgencyList sGDashboardAgencyList = SGDashboardAgencyList();
  final String? agencyId = jsonConvert.convert<String>(json['agency_id']);
  if (agencyId != null) {
    sGDashboardAgencyList.agencyId = agencyId;
  }
  final String? agencyName = jsonConvert.convert<String>(json['agency_name']);
  if (agencyName != null) {
    sGDashboardAgencyList.agencyName = agencyName;
  }
  final String? outletId = jsonConvert.convert<String>(json['outlet_id']);
  if (outletId != null) {
    sGDashboardAgencyList.outletId = outletId;
  }
  final String? outletName = jsonConvert.convert<String>(json['outlet_name']);
  if (outletName != null) {
    sGDashboardAgencyList.outletName = outletName;
  }
  final List<SGDashboardAgencyListDays>? days = (json['days'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<SGDashboardAgencyListDays>(e) as SGDashboardAgencyListDays).toList();
  if (days != null) {
    sGDashboardAgencyList.days = days;
  }
  return sGDashboardAgencyList;
}

Map<String, dynamic> $SGDashboardAgencyListToJson(SGDashboardAgencyList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['agency_id'] = entity.agencyId;
  data['agency_name'] = entity.agencyName;
  data['outlet_id'] = entity.outletId;
  data['outlet_name'] = entity.outletName;
  data['days'] = entity.days.map((v) => v.toJson()).toList();
  return data;
}

extension SGDashboardAgencyListExtension on SGDashboardAgencyList {
  SGDashboardAgencyList copyWith({
    String? agencyId,
    String? agencyName,
    String? outletId,
    String? outletName,
    List<SGDashboardAgencyListDays>? days,
  }) {
    return SGDashboardAgencyList()
      ..agencyId = agencyId ?? this.agencyId
      ..agencyName = agencyName ?? this.agencyName
      ..outletId = outletId ?? this.outletId
      ..outletName = outletName ?? this.outletName
      ..days = days ?? this.days;
  }
}

SGDashboardAgencyListDays $SGDashboardAgencyListDaysFromJson(Map<String, dynamic> json) {
  final SGDashboardAgencyListDays sGDashboardAgencyListDays = SGDashboardAgencyListDays();
  final String? day = jsonConvert.convert<String>(json['day']);
  if (day != null) {
    sGDashboardAgencyListDays.day = day;
  }
  final String? week = jsonConvert.convert<String>(json['week']);
  if (week != null) {
    sGDashboardAgencyListDays.week = week;
  }
  final String? num = jsonConvert.convert<String>(json['num']);
  if (num != null) {
    sGDashboardAgencyListDays.num = num;
  }
  return sGDashboardAgencyListDays;
}

Map<String, dynamic> $SGDashboardAgencyListDaysToJson(SGDashboardAgencyListDays entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['day'] = entity.day;
  data['week'] = entity.week;
  data['num'] = entity.num;
  return data;
}

extension SGDashboardAgencyListDaysExtension on SGDashboardAgencyListDays {
  SGDashboardAgencyListDays copyWith({
    String? day,
    String? week,
    String? num,
  }) {
    return SGDashboardAgencyListDays()
      ..day = day ?? this.day
      ..week = week ?? this.week
      ..num = num ?? this.num;
  }
}