forked from eatvio/eatvio_app
33 lines
1.2 KiB
Dart
33 lines
1.2 KiB
Dart
import 'package:eatvio_app/features/feed/models/feed_blog_post_model.dart';
|
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
|
|
|
part 'chosen_diets_pagination_model.freezed.dart';
|
|
part 'chosen_diets_pagination_model.g.dart';
|
|
|
|
@freezed
|
|
class ChosenDietsPaginationModel with _$ChosenDietsPaginationModel {
|
|
factory ChosenDietsPaginationModel({
|
|
@JsonKey(name: 'data') required List<ChosenDietModel> diets,
|
|
}) = _ChosenDietsPaginationModel;
|
|
|
|
factory ChosenDietsPaginationModel.fromJson(Map<String, dynamic> json) => _$ChosenDietsPaginationModelFromJson(json);
|
|
}
|
|
|
|
@freezed
|
|
class ChosenDietModel with _$ChosenDietModel {
|
|
factory ChosenDietModel({
|
|
@JsonKey(name: 'id') required int chosenDietID,
|
|
@JsonKey(name: 'chosen_plan_id') required int chosenPlanId,
|
|
@JsonKey() required String state,
|
|
@JsonKey(name: 'start_date', fromJson: parseDate) required DateTime startDate,
|
|
@JsonKey(name: 'diet', fromJson: _parseDietId) required int? dietId,
|
|
}) = _ChosenDietModel;
|
|
|
|
factory ChosenDietModel.fromJson(Map<String, dynamic> json) => _$ChosenDietModelFromJson(json);
|
|
}
|
|
|
|
int? _parseDietId(json) {
|
|
if (json == null) return null;
|
|
return json['id'] as int?;
|
|
}
|