|
| 1 | +// To parse this JSON data, do |
| 2 | +// |
| 3 | +// final couponBatch = couponBatchFromJson(jsonString); |
| 4 | +import 'dart:convert'; |
| 5 | + |
| 6 | +CouponBatch couponBatchFromJson(String str) => |
| 7 | + CouponBatch.fromJson(json.decode(str)); |
| 8 | + |
| 9 | +String couponBatchToJson(CouponBatch data) => json.encode(data.toJson()); |
| 10 | + |
| 11 | +class CouponBatch { |
| 12 | + CouponBatch({ |
| 13 | + this.create, |
| 14 | + this.update, |
| 15 | + this.delete, |
| 16 | + }); |
| 17 | + |
| 18 | + List<Create> create; |
| 19 | + List<Create> update; |
| 20 | + List<Create> delete; |
| 21 | + |
| 22 | + factory CouponBatch.fromJson(Map<String, dynamic> json) => CouponBatch( |
| 23 | + create: |
| 24 | + List<Create>.from(json["create"].map((x) => Create.fromJson(x))), |
| 25 | + update: |
| 26 | + List<Create>.from(json["update"].map((x) => Create.fromJson(x))), |
| 27 | + delete: |
| 28 | + List<Create>.from(json["delete"].map((x) => Create.fromJson(x))), |
| 29 | + ); |
| 30 | + |
| 31 | + Map<String, dynamic> toJson() => { |
| 32 | + "create": List<dynamic>.from(create.map((x) => x.toJson())), |
| 33 | + "update": List<dynamic>.from(update.map((x) => x.toJson())), |
| 34 | + "delete": List<dynamic>.from(delete.map((x) => x.toJson())), |
| 35 | + }; |
| 36 | +} |
| 37 | + |
| 38 | +class Create { |
| 39 | + Create({ |
| 40 | + this.id, |
| 41 | + this.code, |
| 42 | + this.amount, |
| 43 | + this.dateCreated, |
| 44 | + this.dateCreatedGmt, |
| 45 | + this.dateModified, |
| 46 | + this.dateModifiedGmt, |
| 47 | + this.discountType, |
| 48 | + this.description, |
| 49 | + this.dateExpires, |
| 50 | + this.dateExpiresGmt, |
| 51 | + this.usageCount, |
| 52 | + this.individualUse, |
| 53 | + this.productIds, |
| 54 | + this.excludedProductIds, |
| 55 | + this.usageLimit, |
| 56 | + this.usageLimitPerUser, |
| 57 | + this.limitUsageToXItems, |
| 58 | + this.freeShipping, |
| 59 | + this.productCategories, |
| 60 | + this.excludedProductCategories, |
| 61 | + this.excludeSaleItems, |
| 62 | + this.minimumAmount, |
| 63 | + this.maximumAmount, |
| 64 | + this.emailRestrictions, |
| 65 | + this.usedBy, |
| 66 | + this.metaData, |
| 67 | + this.links, |
| 68 | + }); |
| 69 | + |
| 70 | + int id; |
| 71 | + String code; |
| 72 | + String amount; |
| 73 | + DateTime dateCreated; |
| 74 | + DateTime dateCreatedGmt; |
| 75 | + DateTime dateModified; |
| 76 | + DateTime dateModifiedGmt; |
| 77 | + String discountType; |
| 78 | + String description; |
| 79 | + dynamic dateExpires; |
| 80 | + dynamic dateExpiresGmt; |
| 81 | + int usageCount; |
| 82 | + bool individualUse; |
| 83 | + List<dynamic> productIds; |
| 84 | + List<dynamic> excludedProductIds; |
| 85 | + dynamic usageLimit; |
| 86 | + dynamic usageLimitPerUser; |
| 87 | + dynamic limitUsageToXItems; |
| 88 | + bool freeShipping; |
| 89 | + List<dynamic> productCategories; |
| 90 | + List<dynamic> excludedProductCategories; |
| 91 | + bool excludeSaleItems; |
| 92 | + String minimumAmount; |
| 93 | + String maximumAmount; |
| 94 | + List<dynamic> emailRestrictions; |
| 95 | + List<dynamic> usedBy; |
| 96 | + List<dynamic> metaData; |
| 97 | + Links links; |
| 98 | + |
| 99 | + factory Create.fromJson(Map<String, dynamic> json) => Create( |
| 100 | + id: json["id"], |
| 101 | + code: json["code"], |
| 102 | + amount: json["amount"], |
| 103 | + dateCreated: DateTime.parse(json["date_created"]), |
| 104 | + dateCreatedGmt: DateTime.parse(json["date_created_gmt"]), |
| 105 | + dateModified: DateTime.parse(json["date_modified"]), |
| 106 | + dateModifiedGmt: DateTime.parse(json["date_modified_gmt"]), |
| 107 | + discountType: json["discount_type"], |
| 108 | + description: json["description"], |
| 109 | + dateExpires: json["date_expires"], |
| 110 | + dateExpiresGmt: json["date_expires_gmt"], |
| 111 | + usageCount: json["usage_count"], |
| 112 | + individualUse: json["individual_use"], |
| 113 | + productIds: List<dynamic>.from(json["product_ids"].map((x) => x)), |
| 114 | + excludedProductIds: |
| 115 | + List<dynamic>.from(json["excluded_product_ids"].map((x) => x)), |
| 116 | + usageLimit: json["usage_limit"], |
| 117 | + usageLimitPerUser: json["usage_limit_per_user"], |
| 118 | + limitUsageToXItems: json["limit_usage_to_x_items"], |
| 119 | + freeShipping: json["free_shipping"], |
| 120 | + productCategories: |
| 121 | + List<dynamic>.from(json["product_categories"].map((x) => x)), |
| 122 | + excludedProductCategories: List<dynamic>.from( |
| 123 | + json["excluded_product_categories"].map((x) => x)), |
| 124 | + excludeSaleItems: json["exclude_sale_items"], |
| 125 | + minimumAmount: json["minimum_amount"], |
| 126 | + maximumAmount: json["maximum_amount"], |
| 127 | + emailRestrictions: |
| 128 | + List<dynamic>.from(json["email_restrictions"].map((x) => x)), |
| 129 | + usedBy: List<dynamic>.from(json["used_by"].map((x) => x)), |
| 130 | + metaData: List<dynamic>.from(json["meta_data"].map((x) => x)), |
| 131 | + links: Links.fromJson(json["_links"]), |
| 132 | + ); |
| 133 | + |
| 134 | + Map<String, dynamic> toJson() => { |
| 135 | + "id": id, |
| 136 | + "code": code, |
| 137 | + "amount": amount, |
| 138 | + "date_created": dateCreated.toIso8601String(), |
| 139 | + "date_created_gmt": dateCreatedGmt.toIso8601String(), |
| 140 | + "date_modified": dateModified.toIso8601String(), |
| 141 | + "date_modified_gmt": dateModifiedGmt.toIso8601String(), |
| 142 | + "discount_type": discountType, |
| 143 | + "description": description, |
| 144 | + "date_expires": dateExpires, |
| 145 | + "date_expires_gmt": dateExpiresGmt, |
| 146 | + "usage_count": usageCount, |
| 147 | + "individual_use": individualUse, |
| 148 | + "product_ids": List<dynamic>.from(productIds.map((x) => x)), |
| 149 | + "excluded_product_ids": |
| 150 | + List<dynamic>.from(excludedProductIds.map((x) => x)), |
| 151 | + "usage_limit": usageLimit, |
| 152 | + "usage_limit_per_user": usageLimitPerUser, |
| 153 | + "limit_usage_to_x_items": limitUsageToXItems, |
| 154 | + "free_shipping": freeShipping, |
| 155 | + "product_categories": |
| 156 | + List<dynamic>.from(productCategories.map((x) => x)), |
| 157 | + "excluded_product_categories": |
| 158 | + List<dynamic>.from(excludedProductCategories.map((x) => x)), |
| 159 | + "exclude_sale_items": excludeSaleItems, |
| 160 | + "minimum_amount": minimumAmount, |
| 161 | + "maximum_amount": maximumAmount, |
| 162 | + "email_restrictions": |
| 163 | + List<dynamic>.from(emailRestrictions.map((x) => x)), |
| 164 | + "used_by": List<dynamic>.from(usedBy.map((x) => x)), |
| 165 | + "meta_data": List<dynamic>.from(metaData.map((x) => x)), |
| 166 | + "_links": links.toJson(), |
| 167 | + }; |
| 168 | +} |
| 169 | + |
| 170 | +class Links { |
| 171 | + Links({ |
| 172 | + this.self, |
| 173 | + this.collection, |
| 174 | + }); |
| 175 | + |
| 176 | + List<Collection> self; |
| 177 | + List<Collection> collection; |
| 178 | + |
| 179 | + factory Links.fromJson(Map<String, dynamic> json) => Links( |
| 180 | + self: List<Collection>.from( |
| 181 | + json["self"].map((x) => Collection.fromJson(x))), |
| 182 | + collection: List<Collection>.from( |
| 183 | + json["collection"].map((x) => Collection.fromJson(x))), |
| 184 | + ); |
| 185 | + |
| 186 | + Map<String, dynamic> toJson() => { |
| 187 | + "self": List<dynamic>.from(self.map((x) => x.toJson())), |
| 188 | + "collection": List<dynamic>.from(collection.map((x) => x.toJson())), |
| 189 | + }; |
| 190 | +} |
| 191 | + |
| 192 | +class Collection { |
| 193 | + Collection({ |
| 194 | + this.href, |
| 195 | + }); |
| 196 | + |
| 197 | + String href; |
| 198 | + |
| 199 | + factory Collection.fromJson(Map<String, dynamic> json) => Collection( |
| 200 | + href: json["href"], |
| 201 | + ); |
| 202 | + |
| 203 | + Map<String, dynamic> toJson() => { |
| 204 | + "href": href, |
| 205 | + }; |
| 206 | +} |
0 commit comments