import 'dart:convert';

class OwnIngredientResponse {
  List<BahanDimiliki> bahanDimiliki;

  OwnIngredientResponse({
    required this.bahanDimiliki,
  });

  factory OwnIngredientResponse.fromJson(Map<String, dynamic> json) =>
      OwnIngredientResponse(
        bahanDimiliki: List<BahanDimiliki>.from(
            json["Bahan dimiliki"].map((x) => BahanDimiliki.fromJson(x))),
      );

  Map<String, dynamic> toJson() => {
        "Bahan dimiliki":
            List<dynamic>.from(bahanDimiliki.map((x) => x.toJson())),
      };
}

class BahanDimiliki {
  int id;
  int recipeId;
  String name;
  double amount;
  String unitId;
  String state;

  BahanDimiliki({
    required this.id,
    required this.recipeId,
    required this.name,
    required this.amount,
    required this.unitId,
    required this.state,
  });

  factory BahanDimiliki.fromJson(Map<String, dynamic> json) => BahanDimiliki(
        id: json["id"],
        recipeId: json["recipe_id"],
        name: json["name"],
        amount: json["amount"]?.toDouble(),
        unitId: json["unit_id"],
        state: json["state"],
      );

  Map<String, dynamic> toJson() => {
        "id": id,
        "recipe_id": recipeId,
        "name": name,
        "amount": amount,
        "unit_id": unitId,
        "state": state,
      };
}
