Skip to content

Commit

Permalink
Merge pull request #1 from CarloDotlog/ordernote-classes
Browse files Browse the repository at this point in the history
Fix duplicated classes
  • Loading branch information
CarloDotLog committed Dec 22, 2020
2 parents f036079 + 2b95c9c commit 2b58165
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 268 deletions.
56 changes: 56 additions & 0 deletions lib/models/billing.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
class Billing {
String firstName;
String lastName;
String company;
String address1;
String address2;
String city;
String state;
String postcode;
String country;
String email;
String phone;

Billing(
{this.firstName,
this.lastName,
this.company,
this.address1,
this.address2,
this.city,
this.state,
this.postcode,
this.country,
this.email,
this.phone});

Billing.fromJson(Map<String, dynamic> json) {
firstName = json['first_name'];
lastName = json['last_name'];
company = json['company'];
address1 = json['address_1'];
address2 = json['address_2'];
city = json['city'];
state = json['state'];
postcode = json['postcode'];
country = json['country'];
email = json['email'];
phone = json['phone'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['first_name'] = this.firstName;
data['last_name'] = this.lastName;
data['company'] = this.company;
data['address_1'] = this.address1;
data['address_2'] = this.address2;
data['city'] = this.city;
data['state'] = this.state;
data['postcode'] = this.postcode;
data['country'] = this.country;
data['email'] = this.email;
data['phone'] = this.phone;
return data;
}
}
129 changes: 6 additions & 123 deletions lib/models/customer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
*/

import 'billing.dart';
import 'shipping.dart';
import 'meta_data.dart';

class WooCustomer {
int id;
String dateCreated;
Expand All @@ -47,7 +51,7 @@ class WooCustomer {
Shipping shipping;
bool isPayingCustomer;
String avatarUrl;
List<WooCustomerMetaData> metaData;
List<MetaData> metaData;
Links links;

WooCustomer(
Expand Down Expand Up @@ -88,7 +92,7 @@ class WooCustomer {
isPayingCustomer = json['is_paying_customer'];
avatarUrl = json['avatar_url'];
metaData =
(json['meta_data'] as List).map((i) => WooCustomerMetaData.fromJson(i)).toList();
(json['meta_data'] as List).map((i) => MetaData.fromJson(i)).toList();
links = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
}

Expand Down Expand Up @@ -129,127 +133,6 @@ class WooCustomer {
@override toString() => this.toJson().toString();
}

class WooCustomerMetaData {
final int id;
final String key;
final dynamic value;

WooCustomerMetaData(this.id, this.key, this.value);

WooCustomerMetaData.fromJson(Map<String, dynamic> json)
: id = json['id'],
key = json['key'],
value = json['value'];

Map<String, dynamic> toJson() => {'id': id, 'key': key, 'value': value};
}

class Billing {
String firstName;
String lastName;
String company;
String address1;
String address2;
String city;
String state;
String postcode;
String country;
String email;
String phone;

Billing(
{this.firstName,
this.lastName,
this.company,
this.address1,
this.address2,
this.city,
this.state,
this.postcode,
this.country,
this.email,
this.phone});

Billing.fromJson(Map<String, dynamic> json) {
firstName = json['first_name'];
lastName = json['last_name'];
company = json['company'];
address1 = json['address_1'];
address2 = json['address_2'];
city = json['city'];
state = json['state'];
postcode = json['postcode'];
country = json['country'];
email = json['email'];
phone = json['phone'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['first_name'] = this.firstName;
data['last_name'] = this.lastName;
data['company'] = this.company;
data['address_1'] = this.address1;
data['address_2'] = this.address2;
data['city'] = this.city;
data['state'] = this.state;
data['postcode'] = this.postcode;
data['country'] = this.country;
data['email'] = this.email;
data['phone'] = this.phone;
return data;
}
}

class Shipping {
String firstName;
String lastName;
String company;
String address1;
String address2;
String city;
String state;
String postcode;
String country;

Shipping(
{this.firstName,
this.lastName,
this.company,
this.address1,
this.address2,
this.city,
this.state,
this.postcode,
this.country});

Shipping.fromJson(Map<String, dynamic> json) {
firstName = json['first_name'];
lastName = json['last_name'];
company = json['company'];
address1 = json['address_1'];
address2 = json['address_2'];
city = json['city'];
state = json['state'];
postcode = json['postcode'];
country = json['country'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['first_name'] = this.firstName;
data['last_name'] = this.lastName;
data['company'] = this.company;
data['address_1'] = this.address1;
data['address_2'] = this.address2;
data['city'] = this.city;
data['state'] = this.state;
data['postcode'] = this.postcode;
data['country'] = this.country;
return data;
}
}

class Links {
List<Self> self;
List<Collection> collection;
Expand Down
21 changes: 21 additions & 0 deletions lib/models/meta_data.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class MetaData {
int id;
String key;
String value;

MetaData({this.id, this.key, this.value});

MetaData.fromJson(Map<String, dynamic> json) {
id = json['id'];
key = json['key'];
value = json['value'].toString();
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['key'] = this.key;
data['value'] = this.value;
return data;
}
}
137 changes: 7 additions & 130 deletions lib/models/order.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
*/

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'meta_data.dart';
import 'billing.dart';
import 'shipping.dart';

class WooOrder {
int id;
int parentId;
Expand Down Expand Up @@ -77,7 +81,8 @@ class WooOrder {
Links links;

WooOrder(
{@required this.id,
{@required
this.id,
this.parentId,
this.number,
this.orderKey,
Expand Down Expand Up @@ -382,134 +387,6 @@ class FeeLineTax {
}
}

class Billing {
String firstName;
String lastName;
String company;
String address1;
String address2;
String city;
String state;
String postcode;
String country;
String email;
String phone;

Billing(
{this.firstName,
this.lastName,
this.company,
this.address1,
this.address2,
this.city,
this.state,
this.postcode,
this.country,
this.email,
this.phone});

Billing.fromJson(Map<String, dynamic> json) {
firstName = json['first_name'];
lastName = json['last_name'];
company = json['company'];
address1 = json['address_1'];
address2 = json['address_2'];
city = json['city'];
state = json['state'];
postcode = json['postcode'];
country = json['country'];
email = json['email'];
phone = json['phone'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['first_name'] = this.firstName;
data['last_name'] = this.lastName;
data['company'] = this.company;
data['address_1'] = this.address1;
data['address_2'] = this.address2;
data['city'] = this.city;
data['state'] = this.state;
data['postcode'] = this.postcode;
data['country'] = this.country;
data['email'] = this.email;
data['phone'] = this.phone;
return data;
}
}

class Shipping {
String firstName;
String lastName;
String company;
String address1;
String address2;
String city;
String state;
String postcode;
String country;

Shipping(
{this.firstName,
this.lastName,
this.company,
this.address1,
this.address2,
this.city,
this.state,
this.postcode,
this.country});

Shipping.fromJson(Map<String, dynamic> json) {
firstName = json['first_name'];
lastName = json['last_name'];
company = json['company'];
address1 = json['address_1'];
address2 = json['address_2'];
city = json['city'];
state = json['state'];
postcode = json['postcode'];
country = json['country'];
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['first_name'] = this.firstName;
data['last_name'] = this.lastName;
data['company'] = this.company;
data['address_1'] = this.address1;
data['address_2'] = this.address2;
data['city'] = this.city;
data['state'] = this.state;
data['postcode'] = this.postcode;
data['country'] = this.country;
return data;
}
}

class MetaData {
int id;
String key;
String value;

MetaData({this.id, this.key, this.value});

MetaData.fromJson(Map<String, dynamic> json) {
id = json['id'];
key = json['key'];
value = json['value'].toString();
}

Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['id'] = this.id;
data['key'] = this.key;
data['value'] = this.value;
return data;
}
}

class Refunds {
int id;
String reason;
Expand Down
Loading

0 comments on commit 2b58165

Please sign in to comment.