166 lines
4.2 KiB
Dart
166 lines
4.2 KiB
Dart
import 'package:equatable/equatable.dart';
|
|
|
|
class CartsModel extends Equatable {
|
|
CartsModel({
|
|
this.status,
|
|
this.error,
|
|
required this.data,
|
|
this.totalPayment,
|
|
this.potonganKupon,
|
|
});
|
|
|
|
final int? status;
|
|
final bool? error;
|
|
final List<DataCartsModel> data;
|
|
final int? potonganKupon;
|
|
final String? totalPayment;
|
|
|
|
factory CartsModel.fromJson(Map<String, dynamic> json) => CartsModel(
|
|
status: json["status"],
|
|
error: json["error"],
|
|
data: List<DataCartsModel>.from(
|
|
json["data"].map((x) => DataCartsModel.fromJson(x))),
|
|
potonganKupon: json["potongan_kupon"],
|
|
totalPayment: json["total_payment"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"status": status,
|
|
"error": error,
|
|
"data": List<dynamic>.from(data.map((x) => x.toJson())),
|
|
"total_payment": totalPayment,
|
|
};
|
|
|
|
@override
|
|
// TODO: implement props
|
|
List<Object?> get props => [];
|
|
}
|
|
|
|
class DataCartsModel extends Equatable {
|
|
DataCartsModel({
|
|
this.cartId,
|
|
this.courseId,
|
|
this.title,
|
|
this.price,
|
|
this.instructor,
|
|
this.thumbnail,
|
|
this.discountPrice,
|
|
this.discountFlag,
|
|
this.totalDiscount,
|
|
this.student,
|
|
required this.review,
|
|
this.fotoProfile,
|
|
this.coupon,
|
|
this.finalPrice,
|
|
this.potonganKupon,
|
|
});
|
|
|
|
final String? cartId;
|
|
final String? courseId;
|
|
final String? title;
|
|
final String? price;
|
|
final String? instructor;
|
|
final String? thumbnail;
|
|
final String? discountPrice;
|
|
final String? discountFlag;
|
|
final int? totalDiscount;
|
|
final String? student;
|
|
final List<Review> review;
|
|
final dynamic fotoProfile;
|
|
final Coupon? coupon;
|
|
final String? finalPrice;
|
|
final String? potonganKupon;
|
|
|
|
factory DataCartsModel.fromJson(Map<String, dynamic> json) => DataCartsModel(
|
|
cartId: json["cart_id"],
|
|
courseId: json["course_id"],
|
|
title: json["title"],
|
|
price: json["price"],
|
|
instructor: json["instructor"],
|
|
thumbnail: json["thumbnail"],
|
|
discountPrice: json["discount_price"],
|
|
discountFlag: json["discount_flag"],
|
|
totalDiscount: json["total_discount"],
|
|
student: json["student"],
|
|
review:
|
|
List<Review>.from(json["review"].map((x) => Review.fromJson(x))),
|
|
fotoProfile: json["foto_profile"],
|
|
coupon: json["coupon"] == null ? null : Coupon.fromJson(json["coupon"]),
|
|
potonganKupon: json["potongan_kupon"],
|
|
finalPrice: json["final_price"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"cart_id": cartId,
|
|
"course_id": courseId,
|
|
"title": title,
|
|
"price": price,
|
|
"instructor": instructor,
|
|
"thumbnail": thumbnail,
|
|
"discount_price": discountPrice,
|
|
"discount_flag": discountFlag,
|
|
"total_discount": totalDiscount,
|
|
"student": student,
|
|
"review": List<dynamic>.from(review.map((x) => x.toJson())),
|
|
"foto_profile": fotoProfile,
|
|
"coupon": coupon,
|
|
"final_price": finalPrice
|
|
};
|
|
|
|
@override
|
|
// TODO: implement props
|
|
List<Object?> get props => [finalPrice];
|
|
}
|
|
|
|
class Coupon {
|
|
Coupon({
|
|
this.id,
|
|
this.typeCoupon,
|
|
this.codeCoupon,
|
|
this.value,
|
|
this.finalPrice,
|
|
});
|
|
|
|
final String? id;
|
|
final String? typeCoupon;
|
|
final String? codeCoupon;
|
|
final String? value;
|
|
final int? finalPrice;
|
|
|
|
factory Coupon.fromJson(Map<String, dynamic> json) => Coupon(
|
|
id: json["id"],
|
|
typeCoupon: json["type_coupon"],
|
|
codeCoupon: json["code_coupon"],
|
|
value: json["value"],
|
|
finalPrice: json["final_price"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"id": id,
|
|
"type_coupon": typeCoupon,
|
|
"code_coupon": codeCoupon,
|
|
"value": value,
|
|
"final_price": finalPrice,
|
|
};
|
|
}
|
|
|
|
class Review {
|
|
Review({
|
|
this.totalReview,
|
|
this.avgRating,
|
|
});
|
|
|
|
final String? totalReview;
|
|
final int? avgRating;
|
|
|
|
factory Review.fromJson(Map<String, dynamic> json) => Review(
|
|
totalReview: json["total_review"],
|
|
avgRating: json["avg_rating"] == null ? null : json["avg_rating"],
|
|
);
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
"total_review": totalReview,
|
|
"avg_rating": avgRating == null ? null : avgRating,
|
|
};
|
|
}
|