// To parse this JSON data, do // // final schedule = scheduleFromJson(jsonString); import 'dart:convert'; import 'package:mc_common_app/models/services/service_model.dart'; Schedule scheduleFromJson(String str) => Schedule.fromJson(json.decode(str)); String scheduleToJson(Schedule data) => json.encode(data.toJson()); class Schedule { final int? messageStatus; final int? totalItemsCount; final List? data; final String? message; Schedule({ this.messageStatus, this.totalItemsCount, this.data, this.message, }); factory Schedule.fromJson(Map json) => Schedule( messageStatus: json["messageStatus"], totalItemsCount: json["totalItemsCount"], data: json["data"] == null ? [] : List.from(json["data"]!.map((x) => ScheduleData.fromJson(x))), message: json["message"], ); Map toJson() => { "messageStatus": messageStatus, "totalItemsCount": totalItemsCount, "data": data == null ? [] : List.from(data!.map((x) => x.toJson())), "message": message, }; } class ScheduleData { final int? id; final String? scheduleName; final int? serviceProviderBranchId; final DateTime? fromDate; final DateTime? toDate; final String? startTime; final String? endTime; final int? slotDurationMinute; final int? perSlotAppointment; final String? branchName; final String? address; final String? latitude; final String? longitude; final List? weeklyOffDays; final List? scheduleServices; final List? selectedServices; String branchId; ScheduleData({ this.id, this.scheduleName, this.serviceProviderBranchId, this.fromDate, this.toDate, this.startTime, this.endTime, this.slotDurationMinute, this.perSlotAppointment, this.branchName, this.address, this.latitude, this.longitude, this.weeklyOffDays, this.scheduleServices, this.selectedServices, this.branchId = "", }); factory ScheduleData.fromJson(Map json) => ScheduleData( id: json["id"], scheduleName: json["scheduleName"], serviceProviderBranchId: json["serviceProviderBranchID"], fromDate: json["fromDate"] == null ? null : DateTime.parse(json["fromDate"]), toDate: json["toDate"] == null ? null : DateTime.parse(json["toDate"]), startTime: json["startTime"], endTime: json["endTime"], slotDurationMinute: json["slotDurationMinute"], perSlotAppointment: json["perSlotAppointment"], branchName: json["branchName"], address: json["address"], latitude: json["latitude"], longitude: json["longitude"], weeklyOffDays: json["weeklyOffDays"] == null ? [] : List.from(json["weeklyOffDays"]!.map((x) => WeeklyOffDay.fromJson(x))), scheduleServices: json["scheduleServices"] == null ? [] : List.from(json["scheduleServices"]!.map((x) => ServiceModel.fromJson(x))), selectedServices: [], ); Map toJson() => { "id": id, "scheduleName": scheduleName, "serviceProviderBranchID": serviceProviderBranchId, "fromDate": fromDate?.toIso8601String(), "toDate": toDate?.toIso8601String(), "startTime": startTime, "endTime": endTime, "slotDurationMinute": slotDurationMinute, "perSlotAppointment": perSlotAppointment, "branchName": branchName, "address": address, "latitude": latitude, "longitude": longitude, "scheduleServices": scheduleServices == null ? [] : List.from(scheduleServices!.map((x) => x.toJson())), }; @override String toString() { return 'ScheduleData{id: $id, scheduleName: $scheduleName, serviceProviderBranchId: $serviceProviderBranchId, fromDate: $fromDate, toDate: $toDate, startTime: $startTime, endTime: $endTime, slotDurationMinute: $slotDurationMinute, perSlotAppointment: $perSlotAppointment, branchName: $branchName, address: $address, latitude: $latitude, longitude: $longitude, weeklyOffDays: $weeklyOffDays, scheduleServices: $scheduleServices, branchId: $branchId}'; } } class WeeklyOffDay { final int? id; final int? dayNumber; WeeklyOffDay({ this.id, this.dayNumber, }); factory WeeklyOffDay.fromJson(Map json) => WeeklyOffDay( id: json["id"], dayNumber: json["dayNumber"], ); Map toJson() => { "id": id, "dayNumber": dayNumber, }; }