Skip to content

Commit 022cc09

Browse files
committed
v1.5.1 - tweaks and changes
1 parent 37d3605 commit 022cc09

File tree

4 files changed

+32
-19
lines changed

4 files changed

+32
-19
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.5.1] - 2021-03-27
2+
3+
* Fixed small issue with the image and product model
4+
15
## [1.5.0] - 2021-03-17
26

37
* Refactor classes

lib/models/image.dart

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,36 @@
1414
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1515

1616
class Image {
17-
final int id;
18-
final DateTime dateCreated;
19-
final DateTime dateCreatedGMT;
20-
final DateTime dateModified;
21-
final DateTime dateModifiedGMT;
22-
final String src;
23-
final String name;
24-
final String alt;
17+
int id;
18+
DateTime dateCreated;
19+
DateTime dateCreatedGMT;
20+
DateTime dateModified;
21+
DateTime dateModifiedGMT;
22+
String src;
23+
String name;
24+
String alt;
2525

2626
Image(this.id, this.src, this.name, this.alt, this.dateCreated,
2727
this.dateCreatedGMT, this.dateModified, this.dateModifiedGMT);
2828

29-
Image.fromJson(Map<String, dynamic> json)
30-
: id = json['id'],
31-
src = json['src'],
32-
name = json['name'],
33-
alt = json['alt'],
34-
dateCreated = DateTime.parse(json['date_created']),
35-
dateModifiedGMT = DateTime.parse(json['date_modified_gmt']),
36-
dateModified = DateTime.parse(json['date_modified']),
37-
dateCreatedGMT = DateTime.parse(json['date_created_gmt']);
29+
Image.fromJson(Map<String, dynamic> json) {
30+
id = json['id'];
31+
src = (json['src'] is String ? json['src'] : json['src'].toString());
32+
name = json['name'];
33+
alt = json['alt'];
34+
if (json['date_created'] != null) {
35+
dateCreated = DateTime.parse(json['date_created']);
36+
}
37+
if (json['date_modified_gmt'] != null) {
38+
dateModifiedGMT = DateTime.parse(json['date_modified_gmt']);
39+
}
40+
if (json['date_modified'] != null) {
41+
dateModified = DateTime.parse(json['date_modified']);
42+
}
43+
if (json['date_created_gmt'] != null) {
44+
dateCreatedGMT = DateTime.parse(json['date_created_gmt']);
45+
}
46+
}
3847

3948
Map<String, dynamic> toJson() => {
4049
'id': this.id,

lib/models/response/products.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ class Product {
149149
sku = json['sku'],
150150
price = json['price'],
151151
regularPrice = json['regular_price'],
152-
salePrice = json['sale_price'],
152+
salePrice = (json['sale_price'] is String ? json['sale_price'] : json['sale_price'].toString()),
153153
priceHtml = json['price_html'],
154154
onSale = json['on_sale'],
155155
purchasable = json['purchasable'],

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: woosignal
22
description: WooCommerce REST API for dart, connect a WooCommerce store and start developing with our interface for their API endpoints.
3-
version: 1.5.0
3+
version: 1.5.1
44
homepage: https://woosignal.com
55
repository: https://github.com/woosignal/flutter-woocommerce-api
66
issue_tracker: https://github.com/woosignal/flutter-woocommerce-api/issues

0 commit comments

Comments
 (0)