Coupon.fromJson constructor
Implementation
Coupon.fromJson(Map<String, dynamic> json) {
id = json['id'];
code = json['code'];
amount = json['amount'];
dateCreated = json['date_created'];
dateCreatedGmt = json['date_created_gmt'];
dateModified = json['date_modified'];
dateModifiedGmt = json['date_modified_gmt'];
discountType = json['discount_type'];
description = json['description'];
dateExpires = json['date_expires'];
dateExpiresGmt = json['date_expires_gmt'];
usageCount = json['usage_count'];
individualUse = json['individual_use'];
productIds =
(json['product_ids'] != null) ? json['product_ids'].cast<int>() : null;
excludedProductIds = (json['excluded_product_ids'] != null)
? json['excluded_product_ids'].cast<int>()
: null;
usageLimit = json['usage_limit'];
usageLimitPerUser = json['usage_limit_per_user'];
limitUsageToXItems = json['limit_usage_to_x_items'];
freeShipping = json['free_shipping'];
productCategories = (json['product_categories'] != null)
? json['product_categories'].cast<int>()
: null;
excludedProductCategories = (json['excluded_product_categories'] != null)
? json['excluded_product_categories'].cast<int>()
: null;
excludeSaleItems = json['exclude_sale_items'];
minimumAmount = json['minimum_amount'];
maximumAmount = json['maximum_amount'];
emailRestrictions = (json['email_restrictions'] != null)
? json['email_restrictions'].cast<String>()
: null;
usedBy = (json['used_by'] != null) ? json['used_by'].cast<String>() : null;
if (json['meta_data'] != null) {
metaData = [];
json['meta_data'].forEach((v) {
metaData!.add(MetaData.fromJson(v));
});
}
links = json['_links'] != null ? Links.fromJson(json['_links']) : null;
}