// To parse this JSON data, do
//
//     final couponData = couponDataFromJson(jsondynamic);

import 'dart:convert';

CouponDataModel couponDataFromJson(dynamic str) =>
    CouponDataModel.fromJson(json.decode(str));

dynamic couponDataToJson(CouponDataModel data) => json.encode(data.toJson());

class CouponDataModel {
  List<CouponDatum>? data;
  int? total;
  int? page;
  int? limit;

  CouponDataModel({
    this.data,
    this.total,
    this.page,
    this.limit,
  });

  factory CouponDataModel.fromJson(Map<dynamic, dynamic> json) =>
      CouponDataModel(
        data: List<CouponDatum>.from(
            json["data"].map((x) => CouponDatum.fromJson(x))),
        total: json["total"],
        page: json["page"],
        limit: json["limit"],
      );

  Map<dynamic, dynamic> toJson() => {
        "data": List<dynamic>.from(data!.map((x) => x.toJson())),
        "total": total,
        "page": page,
        "limit": limit,
      };
}

class CouponDatum {
  dynamic id;
  dynamic code;
  dynamic type;
  dynamic discountValue;
  dynamic maxDiscountAmount;
  dynamic minPurchaseAmount;
  DateTime? startDate;
  DateTime? endDate;
  int? totalUsageLimit;
  int? perUserUsageLimit;
  dynamic applicability;
  dynamic status;
  dynamic description;
  dynamic terms;
  int? buyQuantity;
  int? getQuantity;
  List<dynamic>? applicableUserRoles;
  int? totalUsageCount;
  bool? isActive;
  dynamic createdBy;
  DateTime? createdAt;
  DateTime? updatedAt;
  List<dynamic>? applicableStores;
  List<dynamic>? applicableCategories;
  List<dynamic>? applicableProducts;
  List<dynamic>? usages;
  List<dynamic>? applicableStoreIds;
  List<dynamic>? applicableCategoryIds;
  List<dynamic>? applicableProductIds;
  dynamic imageUrl;

  CouponDatum(
      {this.id,
      this.code,
      this.type,
      this.discountValue,
      this.maxDiscountAmount,
      this.minPurchaseAmount,
      this.startDate,
      this.endDate,
      this.totalUsageLimit,
      this.perUserUsageLimit,
      this.applicability,
      this.status,
      this.description,
      this.terms,
      this.buyQuantity,
      this.getQuantity,
      this.applicableUserRoles,
      this.totalUsageCount,
      this.isActive,
      this.createdBy,
      this.createdAt,
      this.updatedAt,
      this.applicableStores,
      this.applicableCategories,
      this.applicableProducts,
      this.usages,
      this.applicableStoreIds,
      this.applicableCategoryIds,
      this.applicableProductIds,
      this.imageUrl});

  factory CouponDatum.fromJson(Map<dynamic, dynamic> json) => CouponDatum(
        id: json["id"],
        code: json["code"],
        type: json["type"],
        discountValue: json["discountValue"],
        maxDiscountAmount: json["maxDiscountAmount"],
        minPurchaseAmount: json["minPurchaseAmount"],
        startDate: DateTime.parse(json["startDate"]),
        endDate: DateTime.parse(json["endDate"]),
        totalUsageLimit: json["totalUsageLimit"],
        perUserUsageLimit: json["perUserUsageLimit"],
        applicability: json["applicability"],
        status: json["status"],
        description: json["description"],
        terms: json["terms"],
        buyQuantity: json["buyQuantity"],
        getQuantity: json["getQuantity"],
        applicableUserRoles:
            List<dynamic>.from(json["applicableUserRoles"].map((x) => x)),
        totalUsageCount: json["totalUsageCount"],
        isActive: json["isActive"],
        createdBy: json["createdBy"],
        createdAt: DateTime.parse(json["createdAt"]),
        updatedAt: DateTime.parse(json["updatedAt"]),
        applicableStores:
            List<dynamic>.from(json["applicableStores"].map((x) => x)),
        applicableCategories:
            List<dynamic>.from(json["applicableCategories"].map((x) => x)),
        applicableProducts:
            List<dynamic>.from(json["applicableProducts"].map((x) => x)),
        usages: List<dynamic>.from(json["usages"].map((x) => x)),
        applicableStoreIds:
            List<dynamic>.from(json["applicableStoreIds"].map((x) => x)),
        applicableCategoryIds:
            List<dynamic>.from(json["applicableCategoryIds"].map((x) => x)),
        applicableProductIds:
            List<dynamic>.from(json["applicableProductIds"].map((x) => x)),
        imageUrl: json["imageUrl"],
      );

  Map<dynamic, dynamic> toJson() => {
        "id": id,
        "code": code,
        "type": type,
        "discountValue": discountValue,
        "maxDiscountAmount": maxDiscountAmount,
        "minPurchaseAmount": minPurchaseAmount,
        "startDate": startDate,
        "endDate": endDate,
        "totalUsageLimit": totalUsageLimit,
        "perUserUsageLimit": perUserUsageLimit,
        "applicability": applicability,
        "status": status,
        "description": description,
        "terms": terms,
        "buyQuantity": buyQuantity,
        "getQuantity": getQuantity,
        "applicableUserRoles":
            List<dynamic>.from(applicableUserRoles!.map((x) => x)),
        "totalUsageCount": totalUsageCount,
        "isActive": isActive,
        "createdBy": createdBy,
        "createdAt": createdAt,
        "updatedAt": updatedAt,
        "applicableStores": List<dynamic>.from(applicableStores!.map((x) => x)),
        "applicableCategories":
            List<dynamic>.from(applicableCategories!.map((x) => x)),
        "applicableProducts":
            List<dynamic>.from(applicableProducts!.map((x) => x)),
        "usages": List<dynamic>.from(usages!.map((x) => x)),
        "applicableStoreIds":
            List<dynamic>.from(applicableStoreIds!.map((x) => x)),
        "applicableCategoryIds":
            List<dynamic>.from(applicableCategoryIds!.map((x) => x)),
        "applicableProductIds":
            List<dynamic>.from(applicableProductIds!.map((x) => x)),
        "imageUrl": imageUrl,
      };
}
