import 'dart:convert';

class NotOwnIngredientResponse {
  List<BahanYangTidakDimiliki> bahanYangTidakDimiliki;

  NotOwnIngredientResponse({
    required this.bahanYangTidakDimiliki,
  });

  factory NotOwnIngredientResponse.fromJson(Map<String, dynamic> json) =>
      NotOwnIngredientResponse(
        bahanYangTidakDimiliki: List<BahanYangTidakDimiliki>.from(
            json["Bahan yang tidak dimiliki: "]
                .map((x) => BahanYangTidakDimiliki.fromJson(x))),
      );

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

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

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

  factory BahanYangTidakDimiliki.fromJson(Map<String, dynamic> json) =>
      BahanYangTidakDimiliki(
        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,
      };
}
