toJson method

Map<String, dynamic> toJson()

Implementation

Map<String, dynamic> toJson() {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = id;
  data['code'] = code;
  data['amount'] = amount;
  data['date_created'] = dateCreated;
  data['date_created_gmt'] = dateCreatedGmt;
  data['date_modified'] = dateModified;
  data['date_modified_gmt'] = dateModifiedGmt;
  data['discount_type'] = discountType;
  data['description'] = description;
  data['date_expires'] = dateExpires;
  data['date_expires_gmt'] = dateExpiresGmt;
  data['usage_count'] = usageCount;
  data['individual_use'] = individualUse;
  data['product_ids'] = productIds;
  data['excluded_product_ids'] = excludedProductIds;
  data['usage_limit'] = usageLimit;
  data['usage_limit_per_user'] = usageLimitPerUser;
  data['limit_usage_to_x_items'] = limitUsageToXItems;
  data['free_shipping'] = freeShipping;
  data['product_categories'] = productCategories;
  data['excluded_product_categories'] = excludedProductCategories;
  data['exclude_sale_items'] = excludeSaleItems;
  data['minimum_amount'] = minimumAmount;
  data['maximum_amount'] = maximumAmount;
  data['email_restrictions'] = emailRestrictions;
  data['used_by'] = usedBy;
  if (metaData != null) {
    data['meta_data'] = metaData!.map((v) => v.toJson()).toList();
  }
  if (links != null) {
    data['_links'] = links!.toJson();
  }
  return data;
}