82 lines
2.0 KiB
Dart
82 lines
2.0 KiB
Dart
import 'dart:convert';
|
|
|
|
class SupplierResponse {
|
|
List<Supplier> data;
|
|
SupplierResponse({required this.data});
|
|
|
|
factory SupplierResponse.fromJson(Map<String, dynamic> json) =>
|
|
SupplierResponse(
|
|
data:
|
|
List<Supplier>.from(json["data"].map((x) => Supplier.fromJson(x))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"data": List<dynamic>.from(data.map((x) => x.toJson())),
|
|
};
|
|
}
|
|
|
|
class Supplier {
|
|
String namaSupplier;
|
|
int jumlahKesesuaianBahan;
|
|
List<Produk> produk;
|
|
|
|
Supplier({
|
|
required this.namaSupplier,
|
|
required this.jumlahKesesuaianBahan,
|
|
required this.produk,
|
|
});
|
|
|
|
factory Supplier.fromJson(Map<String, dynamic> json) => Supplier(
|
|
namaSupplier: json["nama_supplier"],
|
|
jumlahKesesuaianBahan: json["jumlah_kesesuaian_bahan"],
|
|
produk:
|
|
List<Produk>.from(json["produk"].map((x) => Produk.fromJson(x))),
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"nama_supplier": namaSupplier,
|
|
"jumlah_kesesuaian_bahan": jumlahKesesuaianBahan,
|
|
"produk": List<dynamic>.from(produk.map((x) => x.toJson())),
|
|
};
|
|
}
|
|
|
|
class Produk {
|
|
String namaBahan;
|
|
double harga;
|
|
String satuan;
|
|
String alamat;
|
|
int berat;
|
|
int idProduct;
|
|
String namaSupplier;
|
|
|
|
Produk({
|
|
required this.namaBahan,
|
|
required this.harga,
|
|
required this.satuan,
|
|
required this.alamat,
|
|
required this.berat,
|
|
required this.idProduct,
|
|
required this.namaSupplier,
|
|
});
|
|
|
|
factory Produk.fromJson(Map<String, dynamic> json) => Produk(
|
|
namaBahan: json["nama_bahan"],
|
|
harga: json["harga"],
|
|
satuan: json["satuan"],
|
|
alamat: json["alamat"],
|
|
berat: json["berat"],
|
|
idProduct: json["id_product"],
|
|
namaSupplier: json["nama_supplier"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"nama_bahan": namaBahan,
|
|
"harga": harga,
|
|
"satuan": satuan,
|
|
"alamat": alamat,
|
|
"berat": berat,
|
|
"id_product": idProduct,
|
|
"nama_supplier": namaSupplier,
|
|
};
|
|
}
|