AppCoupon.fromJSON constructor

AppCoupon.fromJSON(
  1. dynamic data
)

Implementation

AppCoupon.fromJSON(data) :
  id = data["id"] ?? "",
  code = data["code"] ?? "",
  amount = data["amount"] ?? 0,
  ownerEmail = data["ownerEmail"] ?? "",
  ownerAmount = data["ownerAmount"] ?? 0,
  description = data["description"] ?? "",
  type = EnumToString.fromString(CouponType.values, data["type"]) ?? CouponType.oneMonthFree,
  usageLimit = data["usageLimit"] ?? 25,
  usedBy = data["usedBy"]?.cast<String>() ?? [],
  productIds = data["productIds"]?.cast<String>() ?? [],
  excludedProductIds = data["excludedProductIds"]?.cast<String>() ?? [],
  allowedEmails = data["allowedEmails"]?.cast<String>() ?? [],
  excludedEmails = data["excludedEmails"]?.cast<String>() ?? [];