class FunctionModel { final String code; final bool value; FunctionModel({ required this.code, required this.value, }); // Convert a JSON object to a FunctionModel instance factory FunctionModel.fromJson(Map json) { return FunctionModel( code: json['code'], value: json['value'], ); } // Convert a FunctionModel instance to a JSON object Map toJson() { return { 'code': code, 'value': value, }; } } class ScheduleModel { final String id; final String category; final bool enable; final FunctionModel function; final String time; final String timerId; final String timezoneId; final List days; ScheduleModel({ required this.id, required this.category, required this.enable, required this.function, required this.time, required this.timerId, required this.timezoneId, required this.days, }); // Convert a JSON object to a Schedule instance factory ScheduleModel.fromJson(Map json) { return ScheduleModel( id: json['id'], category: json['category'], enable: json['enable'], function: FunctionModel.fromJson(json['function']), time: json['time'], timerId: json['timerId'], timezoneId: json['timezoneId'], days: List.from(json['days']), ); } // Convert a Schedule instance to a JSON object Map toJson() { return { 'category': category, 'enable': enable, 'function': function.toJson(), 'time': time, 'timerId': timerId, 'timezoneId': timezoneId, 'days': days, }; } }