Skip to content

Commit 2c04877

Browse files
author
WooSignal
committed
added company to billing model and new metadata model
1 parent 82c6134 commit 2c04877

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

lib/models/meta_data.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class MetaData {
2+
int id;
3+
String key;
4+
String value;
5+
6+
MetaData({this.id, this.key, this.value});
7+
8+
MetaData.fromJson(Map<String, dynamic> json) {
9+
id = json['id'];
10+
key = json['key'];
11+
value = json['value'];
12+
}
13+
14+
Map<String, dynamic> toJson() {
15+
final Map<String, dynamic> data = new Map<String, dynamic>();
16+
data['id'] = this.id;
17+
data['key'] = this.key;
18+
data['value'] = this.value.toString();
19+
return data;
20+
}
21+
}

lib/models/payload/order_wc.dart

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ class CouponLines {
211211
}
212212

213213
class Billing {
214+
String company;
214215
String firstName;
215216
String lastName;
216217
String address1;
@@ -223,7 +224,9 @@ class Billing {
223224
String phone;
224225

225226
Billing(
226-
{this.firstName,
227+
{
228+
this.company,
229+
this.firstName,
227230
this.lastName,
228231
this.address1,
229232
this.address2,
@@ -235,6 +238,7 @@ class Billing {
235238
this.phone});
236239

237240
Billing.fromJson(Map<String, dynamic> json) {
241+
company = json['company'];
238242
firstName = json['first_name'];
239243
lastName = json['last_name'];
240244
address1 = json['address_1'];
@@ -249,6 +253,7 @@ class Billing {
249253

250254
Map<String, dynamic> toJson() {
251255
final Map<String, dynamic> data = new Map<String, dynamic>();
256+
data['company'] = this.company ?? "";
252257
data['first_name'] = this.firstName ?? "";
253258
data['last_name'] = this.lastName ?? "";
254259
data['address_1'] = this.address1 ?? "";
@@ -268,6 +273,7 @@ class Billing {
268273
}
269274

270275
class Shipping {
276+
String company;
271277
String firstName;
272278
String lastName;
273279
String address1;
@@ -278,7 +284,9 @@ class Shipping {
278284
String country;
279285

280286
Shipping(
281-
{this.firstName,
287+
{
288+
this.company,
289+
this.firstName,
282290
this.lastName,
283291
this.address1,
284292
this.address2,
@@ -288,6 +296,7 @@ class Shipping {
288296
this.country});
289297

290298
Shipping.fromJson(Map<String, dynamic> json) {
299+
company = json['company'];
291300
firstName = json['first_name'];
292301
lastName = json['last_name'];
293302
address1 = json['address_1'];
@@ -300,6 +309,7 @@ class Shipping {
300309

301310
Map<String, dynamic> toJson() {
302311
final Map<String, dynamic> data = new Map<String, dynamic>();
312+
data['company'] = this.company ?? "";
303313
data['first_name'] = this.firstName ?? "";
304314
data['last_name'] = this.lastName ?? "";
305315
data['address_1'] = this.address1 ?? "";

lib/models/response/order.dart

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
1414
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1515

16+
import 'package:woosignal/models/meta_data.dart';
17+
1618
class Order {
1719
int id;
1820
int parentId;
@@ -468,28 +470,6 @@ class Shipping {
468470
}
469471
}
470472

471-
class MetaData {
472-
int id;
473-
String key;
474-
String value;
475-
476-
MetaData({this.id, this.key, this.value});
477-
478-
MetaData.fromJson(Map<String, dynamic> json) {
479-
id = json['id'];
480-
key = json['key'];
481-
value = json['value'];
482-
}
483-
484-
Map<String, dynamic> toJson() {
485-
final Map<String, dynamic> data = new Map<String, dynamic>();
486-
data['id'] = this.id;
487-
data['key'] = this.key;
488-
data['value'] = this.value;
489-
return data;
490-
}
491-
}
492-
493473
class Refunds {
494474
int id;
495475
String reason;

0 commit comments

Comments
 (0)