import 'package:freezed_annotation/freezed_annotation.dart'; part 'diary_day_model.freezed.dart'; part 'diary_day_model.g.dart'; enum PortionState { active, filled_diet, eaten_from_diet, eaten, eaten_deleted, eaten_edited, commented, reviewed_by_user, } @freezed class DiaryDayWrapperModel with _$DiaryDayWrapperModel { const factory DiaryDayWrapperModel({ @JsonKey(name: "diary") required DiaryDayModel diary, }) = _DiaryDayWrapperModel; factory DiaryDayWrapperModel.fromJson(Map json) => _$DiaryDayWrapperModelFromJson(json); } @freezed class DiaryDayModel with _$DiaryDayModel { const factory DiaryDayModel({ @JsonKey(name: "id") required int id, @JsonKey(name: "date") required String date, @JsonKey(name: "wakeup") String? wakeup, @JsonKey(name: "retire") String? retire, @JsonKey(name: "closed") required int closed, @JsonKey(name: "comment") required String comment, @JsonKey(name: "state") required TypeOfDiaryModel typeOfDiary, @JsonKey(name: "meals") required List meals, }) = _DiaryDayModel; factory DiaryDayModel.fromJson(Map json) => _$DiaryDayModelFromJson(json); } @freezed class MealModel with _$MealModel { const factory MealModel({ @JsonKey(name: "id") required int id, @JsonKey(name: "time") required String time, @JsonKey(name: "type_no") required int typeNumber, @JsonKey(name: "satiety") required int satiety, @JsonKey(name: "mood") required int mood, @JsonKey(name: "portions") required List portions, @JsonKey(name: "photos") required List photos, }) = _MealModel; factory MealModel.fromJson(Map json) => _$MealModelFromJson(json); } @freezed class DiaryPhotoModel with _$DiaryPhotoModel { const factory DiaryPhotoModel({ @JsonKey(name: "id") required int id, @JsonKey(name: "original_name") required String originalName, @JsonKey(name: "path") required String path, @JsonKey(name: "size") required int size, }) = _DiaryPhotoModel; factory DiaryPhotoModel.fromJson(Map json) => _$DiaryPhotoModelFromJson(json); } @freezed class PortionModel with _$PortionModel { const factory PortionModel({ @JsonKey(name: "id") required int id, @JsonKey(name: "product_nutritional_value_id") int? productNutritionalValueId, @JsonKey(name: "product_name") required String productName, @JsonKey(name: "quantity") required int quantity, @JsonKey(name: "portion") required String portion, @JsonKey(name: "from_diet") required bool fromDiet, @JsonKey(name: "state") required PortionState portionState, }) = _PortionModel; factory PortionModel.fromJson(Map json) => _$PortionModelFromJson(json); } @freezed class TypeOfDiaryModel with _$TypeOfDiaryModel { const factory TypeOfDiaryModel({ @JsonKey(name: "has_chosen_diet") required bool hasChosenDiet, @JsonKey(name: "has_chosen_plan") required bool hasChosenPlan, }) = _TypeOfDiaryModel; factory TypeOfDiaryModel.fromJson(Map json) => _$TypeOfDiaryModelFromJson(json); } @freezed class ProductInMeal with _$ProductInMeal { const factory ProductInMeal({ @JsonKey(name: 'product_name') required String productName, @JsonKey(name: 'portion') required String portion, @JsonKey(name: 'quantity') required int quantity, }) = _ProductInMeal; factory ProductInMeal.fromJson(Map json) => _$ProductInMealFromJson(json); }