Files
Vocasia-LMS-Mobile-apps--TA…/lib/models/voucher_model.dart

91 lines
2.5 KiB
Dart

class VoucherModel {
int? status;
bool? error;
List<DataVoucher>? data;
VoucherModel({this.status, this.error, this.data});
VoucherModel.fromJson(Map<String, dynamic> json) {
status =
json['status'] is String ? int.parse(json['status']) : json['status'];
error = json['error'];
if (json['data'] != null) {
data = <DataVoucher>[];
json['data'].forEach((v) {
data!.add(new DataVoucher.fromJson(v));
});
}
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['status'] = this.status;
data['error'] = this.error;
if (this.data != null) {
data['data'] = this.data!.map((v) => v.toJson()).toList();
}
return data;
}
}
class DataVoucher {
String? idCourse;
String? typeCoupon;
String? value;
String? discountFlag;
String? courseName;
String? instructor;
String? fotoProfile;
String? thubmnail;
String? originalPrice;
dynamic discountPrice;
dynamic finalPrice;
DataVoucher(
{this.idCourse,
this.typeCoupon,
this.value,
this.discountFlag,
this.courseName,
this.instructor,
this.fotoProfile,
this.thubmnail,
this.originalPrice,
this.discountPrice,
this.finalPrice});
DataVoucher.fromJson(Map<String, dynamic> json) {
idCourse = json['id_course'];
typeCoupon = json['type_coupon'];
value = json['value'];
discountFlag = json['discount_flag'];
courseName = json['course_name'];
instructor = json['instructor'];
fotoProfile = json['foto_profile'];
thubmnail = json['thubmnail'];
originalPrice = json['original_price'];
discountPrice = json['discount_price'] is String
? int.parse(json['discount_price'])
: json['discount_price'];
finalPrice = json['final_price'] is String
? int.parse(json['final_price'])
: json['final_price'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id_course'] = this.idCourse;
data['type_coupon'] = this.typeCoupon;
data['value'] = this.value;
data['discount_flag'] = this.discountFlag;
data['course_name'] = this.courseName;
data['instructor'] = this.instructor;
data['foto_profile'] = this.fotoProfile;
data['thubmnail'] = this.thubmnail;
data['original_price'] = this.originalPrice;
data['discount_price'] = this.discountPrice;
data['final_price'] = this.finalPrice;
return data;
}
}