khoirul_romadhon/easycook_mobile/lib/models/recommedation.dart
2024-12-31 09:26:36 +07:00

126 lines
2.8 KiB
Dart

class RawMaterialResponse {
RawMaterialResponse({
required this.data,
});
List<RawMaterial> data;
factory RawMaterialResponse.fromJson(Map<String, dynamic> json) =>
RawMaterialResponse(
data: List<RawMaterial>.from(
json["data"].map((x) => RawMaterial.fromJson(x))));
}
class RawMaterial {
int id;
String name;
dynamic category;
RawMaterial({
required this.id,
required this.name,
this.category,
});
factory RawMaterial.fromJson(Map<String, dynamic> json) => RawMaterial(
id: json["id"],
name: json["name"],
category: json["category"],
);
}
class RekomendasiResepResponse {
List<RekomendasiResep> rekomendasiResep;
RekomendasiResepResponse({
required this.rekomendasiResep,
});
factory RekomendasiResepResponse.fromJson(Map<String, dynamic> json) =>
RekomendasiResepResponse(
rekomendasiResep: List<RekomendasiResep>.from(
json["data"].map((x) => RekomendasiResep.fromJson(x))),
);
}
class RekomendasiResep {
int id;
String title;
String imageUrl;
String difficulty;
String sourceUrl;
int calories;
double completenessPercentage;
bool isFavorited;
Rating rating;
RekomendasiResep({
required this.id,
required this.title,
required this.imageUrl,
required this.difficulty,
required this.sourceUrl,
required this.calories,
required this.completenessPercentage,
required this.isFavorited,
required this.rating,
});
factory RekomendasiResep.fromJson(Map<String, dynamic> json) =>
RekomendasiResep(
id: json["id"],
title: json["title"],
imageUrl: json["image_url"],
difficulty: json["difficulty"],
sourceUrl: json["source_url"],
calories: json["calories"],
completenessPercentage: json["completeness_percentage"],
isFavorited: json["is_favorited"],
rating: Rating.fromJson(json["rating"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"title": title,
"image_url": imageUrl,
"difficulty": difficulty,
"source_url": sourceUrl,
"calories": calories,
"completeness_percentage": completenessPercentage,
"is_favorited": isFavorited,
"rating": rating.toJson(),
};
}
class Rating {
double score;
int amount;
Rating({
required this.score,
required this.amount,
});
factory Rating.fromJson(Map<String, dynamic> json) => Rating(
score: json["score"],
amount: json["amount"],
);
Map<String, dynamic> toJson() => {
"score": score,
"amount": amount,
};
}
class EnumValues<T> {
Map<String, T> map;
late Map<T, String> reverseMap;
EnumValues(this.map);
Map<T, String> get reverse {
reverseMap = map.map((k, v) => MapEntry(v, k));
return reverseMap;
}
}