50 lines
909 B
Dart
50 lines
909 B
Dart
class WorkingHours {
|
|
final String day;
|
|
final List<Shift> shifts;
|
|
|
|
WorkingHours({
|
|
required this.day,
|
|
required this.shifts,
|
|
});
|
|
|
|
factory WorkingHours.fromJson(Map<String, dynamic> json) {
|
|
return WorkingHours(
|
|
day: json['day'],
|
|
shifts: (json['shifts'] as List)
|
|
.map((shift) => Shift.fromJson(shift))
|
|
.toList(),
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'day': day,
|
|
'shifts': shifts.map((shift) => shift.toJson()).toList(),
|
|
};
|
|
}
|
|
}
|
|
|
|
class Shift {
|
|
final String openAt;
|
|
final String closeAt;
|
|
|
|
Shift({
|
|
required this.openAt,
|
|
required this.closeAt,
|
|
});
|
|
|
|
factory Shift.fromJson(Map<String, dynamic> json) {
|
|
return Shift(
|
|
openAt: json['open_at'],
|
|
closeAt: json['close_at'],
|
|
);
|
|
}
|
|
|
|
Map<String, dynamic> toJson() {
|
|
return {
|
|
'open_at': openAt,
|
|
'close_at': closeAt,
|
|
};
|
|
}
|
|
}
|