
class WorkTimeDetailsModel {
  final List<Wd>? wd;
  final List<dynamic>? munkaszunet;
  final Month? month;
  final Weekend? weekend;

  WorkTimeDetailsModel({
    this.wd,
    this.munkaszunet,
    this.month,
    this.weekend,
  });

  WorkTimeDetailsModel.fromJson(Map<String, dynamic> json)
      : wd = (json['wd'] as List?)
      ?.map((dynamic e) => Wd.fromJson(e as Map<String, dynamic>))
      .toList(),
        munkaszunet = json['munkaszunet'] as List?,
        month = (json['month'] as Map<String, dynamic>?) != null
            ? Month.fromJson(json['month'] as Map<String, dynamic>)
            : null,
        weekend = (json['weekend'] as Map<String, dynamic>?) != null
            ? Weekend.fromJson(json['weekend'] as Map<String, dynamic>)
            : null;

  Map<String, dynamic> toJson() => {
    'wd': wd?.map((e) => e.toJson()).toList(),
    'munkaszunet': munkaszunet,
    'month': month?.toJson(),
    'weekend': weekend?.toJson()
  };
}

class Wd {
  final String? date;
  final bool? isMunkaszunet;
  final bool? isHoliday;
  final bool? isWeekend;
  final String? location;
  final String? notes;
  final List<StartStop>? startStop;
  final int? fullHours;
  final int? hours;
  final int? overTime;

  Wd({
    this.date,
    this.isMunkaszunet,
    this.isHoliday,
    this.isWeekend,
    this.location,
    this.notes,
    this.startStop,
    this.fullHours,
    this.hours,
    this.overTime,
  });

  Wd.fromJson(Map<String, dynamic> json)
      : date = json['date'] as String?,
        isMunkaszunet = json['isMunkaszunet'] as bool?,
        isHoliday = json['isHoliday'] as bool?,
        isWeekend = json['isWeekend'] as bool?,
        location = json['location'] as String?,
        notes = json['notes'] as String?,
        startStop = (json['startStop'] as List?)
            ?.map((dynamic e) => StartStop.fromJson(e as Map<String, dynamic>))
            .toList(),
        fullHours = json['fullHours'] as int?,
        hours = json['hours'] as int?,
        overTime = json['overTime'] as int?;

  Map<String, dynamic> toJson() => {
    'date': date,
    'isMunkaszunet': isMunkaszunet,
    'isHoliday': isHoliday,
    'isWeekend': isWeekend,
    'location': location,
    'notes': notes,
    'startStop': startStop?.map((e) => e.toJson()).toList(),
    'fullHours': fullHours,
    'hours': hours,
    'overTime': overTime
  };
}

class StartStop {
  final String? start;
  final String? stop;
  final String? arriveLoc;
  final String? getawayLoc;
  final ArriveCoords? arriveCoords;
  final GetavayCoords? getavayCoords;

  StartStop({
    this.start,
    this.stop,
    this.arriveLoc,
    this.getawayLoc,
    this.arriveCoords,
    this.getavayCoords,
  });

  StartStop.fromJson(Map<String, dynamic> json)
      : start = json['start'] as String?,
        stop = json['stop'] as String?,
        arriveLoc = json['arriveLoc'] as String?,
        getawayLoc = json['getawayLoc'] as String?,
        arriveCoords = (json['arriveCoords'] as Map<String, dynamic>?) != null
            ? ArriveCoords.fromJson(
            json['arriveCoords'] as Map<String, dynamic>)
            : null,
        getavayCoords = (json['getavayCoords'] as Map<String, dynamic>?) != null
            ? GetavayCoords.fromJson(
            json['getavayCoords'] as Map<String, dynamic>)
            : null;

  Map<String, dynamic> toJson() => {
    'start': start,
    'stop': stop,
    'arriveLoc': arriveLoc,
    'getawayLoc': getawayLoc,
    'arriveCoords': arriveCoords?.toJson(),
    'getavayCoords': getavayCoords?.toJson()
  };
}

class ArriveCoords {
  late final double? lat;
  late final double? lon;

  ArriveCoords({
    this.lat,
    this.lon,
  });

  ArriveCoords.fromJson(Map<String, dynamic> json) {
    if (json.isNotEmpty &&
        json['lat'] != null &&
        json['lon'] != null &&
        json['lat'] != 0 &&
        json['lon'] != 0) {
      lat = (json['lat'] as double).toDouble();
      lon = (json['lon'] as double).toDouble();
    } else {
      lat = 0.0;
      lon = 0.0;
    }
  }
  Map<String, dynamic> toJson() => {'lat': lat, 'lon': lon};
}

class GetavayCoords {
  late final double? lat;
  late final double? lon;

  GetavayCoords({
    this.lat,
    this.lon,
  });

  GetavayCoords.fromJson(Map<String, dynamic> json) {
    if (json.isNotEmpty &&
        json['lat'] != null &&
        json['lon'] != null &&
        json['lat'] != 0 &&
        json['lon'] != 0) {
      lat = (json['lat'] as double).toDouble();
      lon = (json['lon'] as double).toDouble();
    } else {
      lat = 0.0;
      lon = 0.0;
    }
  }
  Map<String, dynamic> toJson() => {'lat': lat, 'lon': lon};
}

class Month {
  final int? overTime;
  final int? workHours;
  final int? fullWorkHours;

  Month({
    this.overTime,
    this.workHours,
    this.fullWorkHours,
  });

  Month.fromJson(Map<String, dynamic> json)
      : overTime = json['overTime'] as int?,
        workHours = json['workHours'] as int?,
        fullWorkHours = json['fullWorkHours'] as int?;

  Map<String, dynamic> toJson() => {
    'overTime': overTime,
    'workHours': workHours,
    'fullWorkHours': fullWorkHours
  };
}

class Weekend {
  final Saturday? saturday;
  final Sunday? sunday;

  Weekend({
    this.saturday,
    this.sunday,
  });

  Weekend.fromJson(Map<String, dynamic> json)
      : saturday = (json['Saturday'] as Map<String, dynamic>?) != null
      ? Saturday.fromJson(json['Saturday'] as Map<String, dynamic>)
      : null,
        sunday = (json['Sunday'] as Map<String, dynamic>?) != null
            ? Sunday.fromJson(json['Sunday'] as Map<String, dynamic>)
            : null;

  Map<String, dynamic> toJson() =>
      {'Saturday': saturday?.toJson(), 'Sunday': sunday?.toJson()};
}

class Saturday {
  final int? overTime;
  final int? workHours;
  final int? fullWorkHours;
  final int? days;

  Saturday({
    this.overTime,
    this.workHours,
    this.fullWorkHours,
    this.days,
  });

  Saturday.fromJson(Map<String, dynamic> json)
      : overTime = json['overTime'] as int?,
        workHours = json['workHours'] as int?,
        fullWorkHours = json['fullWorkHours'] as int?,
        days = json['days'] as int?;

  Map<String, dynamic> toJson() => {
    'overTime': overTime,
    'workHours': workHours,
    'fullWorkHours': fullWorkHours,
    'days': days
  };
}

class Sunday {
  final int? overTime;
  final int? workHours;
  final int? fullWorkHours;
  final int? days;

  Sunday({
    this.overTime,
    this.workHours,
    this.fullWorkHours,
    this.days,
  });

  Sunday.fromJson(Map<String, dynamic> json)
      : overTime = json['overTime'] as int?,
        workHours = json['workHours'] as int?,
        fullWorkHours = json['fullWorkHours'] as int?,
        days = json['days'] as int?;

  Map<String, dynamic> toJson() => {
    'overTime': overTime,
    'workHours': workHours,
    'fullWorkHours': fullWorkHours,
    'days': days
  };
}
