OrderDTO.fromJson constructor
OrderDTO.fromJson(
- Map<String, dynamic> json
)
Implementation
OrderDTO.fromJson(Map<String, dynamic> json) : super.fromJson(json) {
status = json['status'] != null
? OrderStatus.values.firstWhere(
(element) => element.toString().split('.').last == json['status'])
: null;
type = json['type'] != null
? OrderType.values.firstWhere(
(element) => element.toString().split('.').last == json['type'])
: null;
customerNote = json['customerNote'];
storeNote = json['storeNote'];
if (json['items'] != null) {
items = <OrderItemDTO>[];
json['items'].forEach((v) {
items!.add(OrderItemDTO.fromJson(v));
});
}
customer =
json['customer'] != null ? UserDTO.fromJson(json['customer']) : null;
if (json['invoices'] != null) {
invoices = <Invoices>[];
json['invoices'].forEach((v) {
invoices!.add(Invoices.fromJson(v));
});
}
billingAddress = json['billingAddress'] != null
? AddressDTO.fromJson(json['billingAddress'])
: null;
shippingAddress = json['shippingAddress'] != null
? AddressDTO.fromJson(json['shippingAddress'])
: null;
if (json['campaigns'] != null) {
campaigns = <CampaignDTO>[];
json['campaigns'].forEach((v) {
campaigns!.add(CampaignDTO.fromJson(v));
});
}
note = json['note'];
billingAddressId = json['billingAddressId'];
shippingAddressId = json['shippingAddressId'];
isPaid = json['isPaid'];
store = json['store'] != null ? StoreDTO.fromJson(json['store']) : null;
paymentMethod = json['paymentMethod'] != null
? PaymentType.values.firstWhere((element) =>
element.toString().split('.').last == json['paymentMethod'])
: null;
isTest = json['isTest'];
deletedAt = json['deletedAt'];
deliveryDate = json['deliveryDate'];
}