OrderModel.fromJson constructor
OrderModel.fromJson(
- Map<String, dynamic> json
)
Implementation
factory OrderModel.fromJson(Map<String, dynamic> json) {
return OrderModel(
id: json['id'],
parentId: json['parent_id'],
number: json['number'],
orderKey: json['order_key'],
createdVia: json['created_via'],
version: json['version'],
status: json['status'] ?? 'pending',
currency: json['currency'] ?? 'USD',
dateCreated: json['date_created'] != null
? DateTime.parse(json['date_created'])
: null,
dateCreatedGmt: json['date_created_gmt'] != null
? DateTime.parse(json['date_created_gmt'])
: null,
dateModified: json['date_modified'] != null
? DateTime.parse(json['date_modified'])
: null,
dateModifiedGmt: json['date_modified_gmt'] != null
? DateTime.parse(json['date_modified_gmt'])
: null,
discountTotal: json['discount_total'],
discountTax: json['discount_tax'],
shippingTotal: json['shipping_total'],
shippingTax: json['shipping_tax'],
cartTax: json['cart_tax'],
total: json['total'],
totalTax: json['total_tax'],
pricesIncludeTax: json['prices_include_tax'] ?? false,
customerId: json['customer_id'] ?? 0,
customerIpAddress: json['customer_ip_address'],
customerUserAgent: json['customer_user_agent'],
customerNote: json['customer_note'],
billing: json['billing'],
shipping: json['shipping'],
paymentMethod: json['payment_method'],
paymentMethodTitle: json['payment_method_title'],
transactionId: json['transaction_id'],
datePaid:
json['date_paid'] != null ? DateTime.parse(json['date_paid']) : null,
datePaidGmt: json['date_paid_gmt'] != null
? DateTime.parse(json['date_paid_gmt'])
: null,
dateCompleted: json['date_completed'] != null
? DateTime.parse(json['date_completed'])
: null,
dateCompletedGmt: json['date_completed_gmt'] != null
? DateTime.parse(json['date_completed_gmt'])
: null,
cartHash: json['cart_hash'],
metaData: json['meta_data'],
lineItems: json['line_items'],
taxLines: json['tax_lines'],
shippingLines: json['shipping_lines'],
feeLines: json['fee_lines'],
couponLines: json['coupon_lines'],
refunds: json['refunds'],
setPaid: json['set_paid'] ?? false,
);
}