|
| 1 | +// To parse this JSON data, do |
| 2 | +// |
| 3 | +// final customerBatch = customerBatchFromJson(jsonString); |
| 4 | + |
| 5 | +import 'dart:convert'; |
| 6 | + |
| 7 | +CustomerBatch customerBatchFromJson(String str) => |
| 8 | + CustomerBatch.fromJson(json.decode(str)); |
| 9 | + |
| 10 | +String customerBatchToJson(CustomerBatch data) => json.encode(data.toJson()); |
| 11 | + |
| 12 | +class CustomerBatch { |
| 13 | + CustomerBatch({ |
| 14 | + this.create, |
| 15 | + this.update, |
| 16 | + this.delete, |
| 17 | + }); |
| 18 | + List<Customers> create; |
| 19 | + List<Customers> update; |
| 20 | + List<Customers> delete; |
| 21 | + |
| 22 | + factory CustomerBatch.fromJson(Map<String, dynamic> json) => CustomerBatch( |
| 23 | + create: List<Customers>.from( |
| 24 | + json["create"].map((x) => Customers.fromJson(x))), |
| 25 | + update: List<Customers>.from( |
| 26 | + json["update"].map((x) => Customers.fromJson(x))), |
| 27 | + delete: List<Customers>.from( |
| 28 | + json["delete"].map((x) => Customers.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 Customers { |
| 39 | + Customers({ |
| 40 | + this.id, |
| 41 | + this.dateCreated, |
| 42 | + this.dateCreatedGmt, |
| 43 | + this.dateModified, |
| 44 | + this.dateModifiedGmt, |
| 45 | + this.email, |
| 46 | + this.firstName, |
| 47 | + this.lastName, |
| 48 | + this.role, |
| 49 | + this.username, |
| 50 | + this.billing, |
| 51 | + this.shipping, |
| 52 | + this.isPayingCustomer, |
| 53 | + this.avatarUrl, |
| 54 | + this.metaData, |
| 55 | + this.links, |
| 56 | + }); |
| 57 | + |
| 58 | + int id; |
| 59 | + DateTime dateCreated; |
| 60 | + DateTime dateCreatedGmt; |
| 61 | + DateTime dateModified; |
| 62 | + DateTime dateModifiedGmt; |
| 63 | + String email; |
| 64 | + String firstName; |
| 65 | + String lastName; |
| 66 | + String role; |
| 67 | + String username; |
| 68 | + Ing billing; |
| 69 | + Ing shipping; |
| 70 | + bool isPayingCustomer; |
| 71 | + String avatarUrl; |
| 72 | + List<dynamic> metaData; |
| 73 | + Links links; |
| 74 | + |
| 75 | + factory Customers.fromJson(Map<String, dynamic> json) => Customers( |
| 76 | + id: json["id"], |
| 77 | + dateCreated: DateTime.parse(json["date_created"]), |
| 78 | + dateCreatedGmt: DateTime.parse(json["date_created_gmt"]), |
| 79 | + dateModified: DateTime.parse(json["date_modified"]), |
| 80 | + dateModifiedGmt: DateTime.parse(json["date_modified_gmt"]), |
| 81 | + email: json["email"], |
| 82 | + firstName: json["first_name"], |
| 83 | + lastName: json["last_name"], |
| 84 | + role: json["role"], |
| 85 | + username: json["username"], |
| 86 | + billing: Ing.fromJson(json["billing"]), |
| 87 | + shipping: Ing.fromJson(json["shipping"]), |
| 88 | + isPayingCustomer: json["is_paying_customer"], |
| 89 | + avatarUrl: json["avatar_url"], |
| 90 | + metaData: List<dynamic>.from(json["meta_data"].map((x) => x)), |
| 91 | + links: Links.fromJson(json["_links"]), |
| 92 | + ); |
| 93 | + |
| 94 | + Map<String, dynamic> toJson() => { |
| 95 | + "id": id, |
| 96 | + "date_created": dateCreated.toIso8601String(), |
| 97 | + "date_created_gmt": dateCreatedGmt.toIso8601String(), |
| 98 | + "date_modified": dateModified.toIso8601String(), |
| 99 | + "date_modified_gmt": dateModifiedGmt.toIso8601String(), |
| 100 | + "email": email, |
| 101 | + "first_name": firstName, |
| 102 | + "last_name": lastName, |
| 103 | + "role": role, |
| 104 | + "username": username, |
| 105 | + "billing": billing.toJson(), |
| 106 | + "shipping": shipping.toJson(), |
| 107 | + "is_paying_customer": isPayingCustomer, |
| 108 | + "avatar_url": avatarUrl, |
| 109 | + "meta_data": List<dynamic>.from(metaData.map((x) => x)), |
| 110 | + "_links": links.toJson(), |
| 111 | + }; |
| 112 | +} |
| 113 | + |
| 114 | +class Ing { |
| 115 | + Ing({ |
| 116 | + this.firstName, |
| 117 | + this.lastName, |
| 118 | + this.company, |
| 119 | + this.address1, |
| 120 | + this.address2, |
| 121 | + this.city, |
| 122 | + this.state, |
| 123 | + this.postcode, |
| 124 | + this.country, |
| 125 | + this.email, |
| 126 | + this.phone, |
| 127 | + }); |
| 128 | + |
| 129 | + String firstName; |
| 130 | + String lastName; |
| 131 | + String company; |
| 132 | + String address1; |
| 133 | + String address2; |
| 134 | + String city; |
| 135 | + String state; |
| 136 | + String postcode; |
| 137 | + String country; |
| 138 | + String email; |
| 139 | + String phone; |
| 140 | + |
| 141 | + factory Ing.fromJson(Map<String, dynamic> json) => Ing( |
| 142 | + firstName: json["first_name"], |
| 143 | + lastName: json["last_name"], |
| 144 | + company: json["company"], |
| 145 | + address1: json["address_1"], |
| 146 | + address2: json["address_2"], |
| 147 | + city: json["city"], |
| 148 | + state: json["state"], |
| 149 | + postcode: json["postcode"], |
| 150 | + country: json["country"], |
| 151 | + email: json["email"] == null ? null : json["email"], |
| 152 | + phone: json["phone"] == null ? null : json["phone"], |
| 153 | + ); |
| 154 | + |
| 155 | + Map<String, dynamic> toJson() => { |
| 156 | + "first_name": firstName, |
| 157 | + "last_name": lastName, |
| 158 | + "company": company, |
| 159 | + "address_1": address1, |
| 160 | + "address_2": address2, |
| 161 | + "city": city, |
| 162 | + "state": state, |
| 163 | + "postcode": postcode, |
| 164 | + "country": country, |
| 165 | + "email": email == null ? null : email, |
| 166 | + "phone": phone == null ? null : phone, |
| 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