Skip to content

Commit 7a3b286

Browse files
agwoosignalagordn52
authored andcommitted
Merged in feature/WFA-6-api-coupons (pull request #5)
Feature/WFA-6 api coupons Approved-by: Anthony Gordon <ants52@aol.com>
2 parents b98c15b + f704272 commit 7a3b286

File tree

4 files changed

+685
-22
lines changed

4 files changed

+685
-22
lines changed

lib/models/response/coupon.dart

Lines changed: 227 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,227 @@
1+
import 'package:woosignal/models/response/customer.dart';
2+
import 'package:woosignal/models/payload/order_wc.dart';
3+
4+
class Coupon {
5+
int id;
6+
String code;
7+
String amount;
8+
String dateCreated;
9+
String dateCreatedGmt;
10+
String dateModified;
11+
String dateModifiedGmt;
12+
String discountType;
13+
String description;
14+
String dateExpires;
15+
String dateExpiresGmt;
16+
int usageCount;
17+
bool individualUse;
18+
List<dynamic> productIds;
19+
List<dynamic> excludedProductIds;
20+
int usageLimit;
21+
int usageLimitPerUser;
22+
int limitUsageToXItems;
23+
bool freeShipping;
24+
List<dynamic> productCategories;
25+
List<dynamic> excludedProductCategories;
26+
bool excludeSaleItems;
27+
String minimumAmount;
28+
String maximumAmount;
29+
List<dynamic> emailRestrictions;
30+
List<dynamic> usedBy;
31+
List<MetaData> metaData;
32+
Links lLinks;
33+
34+
Coupon(
35+
{this.id,
36+
this.code,
37+
this.amount,
38+
this.dateCreated,
39+
this.dateCreatedGmt,
40+
this.dateModified,
41+
this.dateModifiedGmt,
42+
this.discountType,
43+
this.description,
44+
this.dateExpires,
45+
this.dateExpiresGmt,
46+
this.usageCount,
47+
this.individualUse,
48+
this.productIds,
49+
this.excludedProductIds,
50+
this.usageLimit,
51+
this.usageLimitPerUser,
52+
this.limitUsageToXItems,
53+
this.freeShipping,
54+
this.productCategories,
55+
this.excludedProductCategories,
56+
this.excludeSaleItems,
57+
this.minimumAmount,
58+
this.maximumAmount,
59+
this.emailRestrictions,
60+
this.usedBy,
61+
this.metaData,
62+
this.lLinks});
63+
64+
Coupon.fromJson(Map<String, dynamic> json) {
65+
id = json['id'];
66+
code = json['code'];
67+
amount = json['amount'];
68+
dateCreated = json['date_created'];
69+
dateCreatedGmt = json['date_created_gmt'];
70+
dateModified = json['date_modified'];
71+
dateModifiedGmt = json['date_modified_gmt'];
72+
discountType = json['discount_type'];
73+
description = json['description'];
74+
dateExpires = json['date_expires'];
75+
dateExpiresGmt = json['date_expires_gmt'];
76+
usageCount = json['usage_count'];
77+
individualUse = json['individual_use'];
78+
//Error Expected
79+
productIds = (json['product_ids'] != null) ? json['product_ids'] : null;
80+
//Error Expected
81+
// excludedProductIds = json['excluded_product_ids'];
82+
excludedProductIds = (json['excluded_product_ids'] != null)
83+
? json['excluded_product_ids']
84+
: null;
85+
usageLimit = json['usage_limit'];
86+
usageLimitPerUser = json['usage_limit_per_user'];
87+
limitUsageToXItems = json['limit_usage_to_x_items'];
88+
freeShipping = json['free_shipping'];
89+
//Error Expected
90+
// productCategories = json['product_categories'];
91+
productCategories = (json['product_categories'] != null)
92+
? json['product_categories']
93+
: null;
94+
//Error Expected
95+
// excludedProductCategories = json['excluded_product_categories'];
96+
productCategories = (json['product_categories'] != null)
97+
? json['product_categories']
98+
: null;
99+
excludeSaleItems = json['exclude_sale_items'];
100+
minimumAmount = json['minimum_amount'];
101+
maximumAmount = json['maximum_amount'];
102+
//Error Expected
103+
104+
// emailRestrictions = json['email_restrictions'].cast<String>();
105+
emailRestrictions = (json['email_restrictions'] != null)
106+
? json['email_restrictions']
107+
: null;
108+
//Error Expected
109+
// usedBy = json['used_by'].cast<String>();
110+
usedBy = (json['used_by'] != null) ? json['used_by'] : null;
111+
if (json['meta_data'] != null) {
112+
metaData = new List<MetaData>();
113+
json['meta_data'].forEach((v) {
114+
metaData.add(new MetaData.fromJson(v));
115+
});
116+
}
117+
lLinks = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
118+
}
119+
120+
Map<String, dynamic> toJson() {
121+
final Map<String, dynamic> data = new Map<String, dynamic>();
122+
data['id'] = this.id;
123+
data['code'] = this.code;
124+
data['amount'] = this.amount;
125+
data['date_created'] = this.dateCreated;
126+
data['date_created_gmt'] = this.dateCreatedGmt;
127+
data['date_modified'] = this.dateModified;
128+
data['date_modified_gmt'] = this.dateModifiedGmt;
129+
data['discount_type'] = this.discountType;
130+
data['description'] = this.description;
131+
data['date_expires'] = this.dateExpires;
132+
data['date_expires_gmt'] = this.dateExpiresGmt;
133+
data['usage_count'] = this.usageCount;
134+
data['individual_use'] = this.individualUse;
135+
data['product_ids'] = this.productIds;
136+
data['excluded_product_ids'] = this.excludedProductIds;
137+
data['usage_limit'] = this.usageLimit;
138+
data['usage_limit_per_user'] = this.usageLimitPerUser;
139+
data['limit_usage_to_x_items'] = this.limitUsageToXItems;
140+
data['free_shipping'] = this.freeShipping;
141+
data['product_categories'] = this.productCategories;
142+
data['excluded_product_categories'] = this.excludedProductCategories;
143+
data['exclude_sale_items'] = this.excludeSaleItems;
144+
data['minimum_amount'] = this.minimumAmount;
145+
data['maximum_amount'] = this.maximumAmount;
146+
data['email_restrictions'] = this.emailRestrictions;
147+
data['used_by'] = this.usedBy;
148+
if (this.metaData != null) {
149+
data['meta_data'] = this.metaData.map((v) => v.toJson()).toList();
150+
}
151+
if (this.lLinks != null) {
152+
data['_links'] = this.lLinks.toJson();
153+
}
154+
return data;
155+
}
156+
}
157+
158+
// class MetaData {
159+
// int id;
160+
// String key;
161+
// String value;
162+
163+
// MetaData({this.id, this.key, this.value});
164+
165+
// MetaData.fromJson(Map<String, dynamic> json) {
166+
// id = json['id'];
167+
// key = json['key'];
168+
// value = json['value'];
169+
// }
170+
171+
// Map<String, dynamic> toJson() {
172+
// final Map<String, dynamic> data = new Map<String, dynamic>();
173+
// data['id'] = this.id;
174+
// data['key'] = this.key;
175+
// data['value'] = this.value;
176+
// return data;
177+
// }
178+
// }
179+
180+
// class Links {
181+
// List<Self> self;
182+
// List<Collection> collection;
183+
184+
// Links({this.self, this.collection});
185+
186+
// Links.fromJson(Map<String, dynamic> json) {
187+
// if (json['self'] != null) {
188+
// self = new List<Self>();
189+
// json['self'].forEach((v) {
190+
// self.add(new Self.fromJson(v));
191+
// });
192+
// }
193+
// if (json['collection'] != null) {
194+
// collection = new List<Collection>();
195+
// json['collection'].forEach((v) {
196+
// collection.add(new Collection.fromJson(v));
197+
// });
198+
// }
199+
// }
200+
201+
// Map<String, dynamic> toJson() {
202+
// final Map<String, dynamic> data = new Map<String, dynamic>();
203+
// if (this.self != null) {
204+
// data['self'] = this.self.map((v) => v.toJson()).toList();
205+
// }
206+
// if (this.collection != null) {
207+
// data['collection'] = this.collection.map((v) => v.toJson()).toList();
208+
// }
209+
// return data;
210+
// }
211+
// }
212+
213+
class Self {
214+
String href;
215+
216+
Self({this.href});
217+
218+
Self.fromJson(Map<String, dynamic> json) {
219+
href = json['href'];
220+
}
221+
222+
Map<String, dynamic> toJson() {
223+
final Map<String, dynamic> data = new Map<String, dynamic>();
224+
data['href'] = this.href;
225+
return data;
226+
}
227+
}

0 commit comments

Comments
 (0)