mirror of
https://github.com/SyncrowIOT/syncrow-app.git
synced 2025-07-16 01:56:19 +00:00
74 lines
1.6 KiB
Dart
74 lines
1.6 KiB
Dart
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<String, dynamic> json) {
|
|
return FunctionModel(
|
|
code: json['code'],
|
|
value: json['value'],
|
|
);
|
|
}
|
|
|
|
// Convert a FunctionModel instance to a JSON object
|
|
Map<String, dynamic> 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<String> 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<String, dynamic> 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<String>.from(json['days']),
|
|
);
|
|
}
|
|
|
|
// Convert a Schedule instance to a JSON object
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'category': category,
|
|
'enable': enable,
|
|
'function': function.toJson(),
|
|
'time': time,
|
|
'timerId': timerId,
|
|
'timezoneId': timezoneId,
|
|
'days': days,
|
|
};
|
|
}
|
|
} |