Skip to content

Commit 5832331

Browse files
authored
Merge pull request #12 from woosignal/master
v3.2.0 updates
2 parents 5200f97 + 3732500 commit 5832331

File tree

11 files changed

+101
-48
lines changed

11 files changed

+101
-48
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## [3.2.0] - 2022-11-03
2+
3+
* Add Menu Links to `WooSignalApp` class
4+
* Fix expected API return types for Dimension
5+
* Dependency updates
6+
17
## [3.1.1] - 2022-08-29
28

39
* Dependency updates

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ In your flutter project add the dependency:
1515
``` dart
1616
dependencies:
1717
...
18-
woosignal: ^3.1.1
18+
woosignal: ^3.2.0
1919
```
2020

2121
### Usage example #

lib/models/menu_link.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// Copyright (c) 2022, WooSignal Ltd.
2+
// All rights reserved.
3+
//
4+
// Redistribution and use in source and binary forms are permitted
5+
// provided that the above copyright notice and this paragraph are
6+
// duplicated in all such forms and that any documentation,
7+
// advertising materials, and other materials related to such
8+
// distribution and use acknowledge that the software was developed
9+
// by the WooSignal. The name of the
10+
// WooSignal may not be used to endorse or promote products derived
11+
// from this software without specific prior written permission.
12+
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13+
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14+
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15+
16+
class MenuLink {
17+
late String label;
18+
late String linkUrl;
19+
late String iconUrl;
20+
late int order;
21+
22+
MenuLink(
23+
{required this.label,
24+
required this.linkUrl,
25+
required this.iconUrl,
26+
required this.order});
27+
28+
MenuLink.fromJson(Map<String, dynamic> json) {
29+
label = json['label'];
30+
linkUrl = json['link_url'];
31+
iconUrl = json['icon_url'];
32+
order = json['order'];
33+
}
34+
}

lib/models/response/dimension.dart

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (c) 2022, WooSignal Ltd.
2+
// All rights reserved.
3+
//
4+
// Redistribution and use in source and binary forms are permitted
5+
// provided that the above copyright notice and this paragraph are
6+
// duplicated in all such forms and that any documentation,
7+
// advertising materials, and other materials related to such
8+
// distribution and use acknowledge that the software was developed
9+
// by the WooSignal. The name of the
10+
// WooSignal may not be used to endorse or promote products derived
11+
// from this software without specific prior written permission.
12+
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
13+
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
14+
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
15+
16+
class Dimension {
17+
final String? length;
18+
final String? width;
19+
final String? height;
20+
21+
Dimension(this.length, this.height, this.width);
22+
23+
Dimension.fromJson(Map<String, dynamic> json)
24+
: length =
25+
json['length'] is int ? json['length'].toString() : json['length'],
26+
width = json['width'] is int ? json['width'].toString() : json['width'],
27+
height =
28+
json['height'] is int ? json['height'].toString() : json['height'];
29+
30+
Map<String, dynamic> toJson() =>
31+
{'length': length, 'width': width, 'height': height};
32+
}

lib/models/response/product_tag.dart

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,18 +37,18 @@ class ProductTag {
3737
slug = json['slug'];
3838
description = json['description'];
3939
count = json['count'];
40-
links = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
40+
links = json['_links'] != null ? Links.fromJson(json['_links']) : null;
4141
}
4242

4343
Map<String, dynamic> toJson() {
44-
final Map<String, dynamic> data = new Map<String, dynamic>();
45-
data['id'] = this.id;
46-
data['name'] = this.name;
47-
data['slug'] = this.slug;
48-
data['description'] = this.description;
49-
data['count'] = this.count;
50-
if (this.links != null) {
51-
data['_links'] = this.links!.toJson();
44+
final Map<String, dynamic> data = <String, dynamic>{};
45+
data['id'] = id;
46+
data['name'] = name;
47+
data['slug'] = slug;
48+
data['description'] = description;
49+
data['count'] = count;
50+
if (links != null) {
51+
data['_links'] = links!.toJson();
5252
}
5353
return data;
5454
}

lib/models/response/product_variation.dart

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1515

1616
import 'package:woosignal/models/image.dart';
17+
import 'package:woosignal/models/response/dimension.dart';
1718

1819
import '../meta_data.dart';
1920

@@ -160,22 +161,6 @@ class Category {
160161
};
161162
}
162163

163-
class Dimension {
164-
final String? length;
165-
final String? width;
166-
final String? height;
167-
168-
Dimension(this.length, this.height, this.width);
169-
170-
Dimension.fromJson(Map<String, dynamic> json)
171-
: length = json['length'],
172-
width = json['width'],
173-
height = json['height'];
174-
175-
Map<String, dynamic> toJson() =>
176-
{'length': length, 'width': width, 'height': height};
177-
}
178-
179164
class Attribute {
180165
final int? id;
181166
final String? name;

lib/models/response/products.dart

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

1616
import 'package:woosignal/models/image.dart';
17+
import 'package:woosignal/models/response/dimension.dart';
1718

1819
import '../meta_data.dart';
1920

@@ -174,7 +175,9 @@ class Product {
174175
backordersAllowed = json['backorders_allowed'],
175176
backordered = json['backordered'],
176177
soldIndividually = json['sold_individually'],
177-
weight = json['weight'],
178+
weight = (json['weight'] is double
179+
? json['weight'].toString()
180+
: json['weight']),
178181
dimensions = Dimension.fromJson(json['dimensions']),
179182
shippingRequired = json['shipping_required'],
180183
shippingTaxable = json['shipping_taxable'],
@@ -257,22 +260,6 @@ class Category {
257260
};
258261
}
259262

260-
class Dimension {
261-
final String? length;
262-
final String? width;
263-
final String? height;
264-
265-
Dimension(this.length, this.height, this.width);
266-
267-
Dimension.fromJson(Map<String, dynamic> json)
268-
: length = json['length'],
269-
width = json['width'],
270-
height = json['height'];
271-
272-
Map<String, dynamic> toJson() =>
273-
{'length': length, 'width': width, 'height': height};
274-
}
275-
276263
class Attribute {
277264
final int? id;
278265
final String? name;

lib/models/response/woosignal_app.dart

Lines changed: 9 additions & 0 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/menu_link.dart';
17+
1618
class WooSignalApp {
1719
String? appName;
1820
String? appLogo;
@@ -46,6 +48,7 @@ class WooSignalApp {
4648
String? stripeCountryCode;
4749
String? themeFont;
4850
Map<String, dynamic>? socialLinks;
51+
List<MenuLink> menuLinks = [];
4952
Map<String, dynamic>? themeColors;
5053

5154
WooSignalApp(
@@ -78,6 +81,7 @@ class WooSignalApp {
7881
this.wishlistEnabled,
7982
this.themeFont,
8083
this.socialLinks,
84+
this.menuLinks = const [],
8185
this.themeColors});
8286

8387
WooSignalApp.fromJson(Map<String, dynamic> json) {
@@ -147,6 +151,11 @@ class WooSignalApp {
147151
json['theme_colors'] is Map<String, dynamic>?) {
148152
themeColors = json['theme_colors'];
149153
}
154+
if (json.containsKey('menu_links')) {
155+
menuLinks = List.from(json['menu_links'])
156+
.map((bet) => MenuLink.fromJson(bet))
157+
.toList();
158+
}
150159
}
151160

152161
Map<String, dynamic> toJson() {

lib/networking/api_provider.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ class ApiProvider {
3636
AndroidDeviceInfo androidDeviceInfo = await deviceInfo.androidInfo;
3737
_deviceMeta = {
3838
"model": androidDeviceInfo.device,
39-
"brand": androidDeviceInfo.brand
40-
?.replaceAll(RegExp('[^\u0001-\u007F]'), '_'),
39+
"brand":
40+
androidDeviceInfo.brand.replaceAll(RegExp('[^\u0001-\u007F]'), '_'),
4141
"manufacturer": androidDeviceInfo.manufacturer,
4242
"version": androidDeviceInfo.version.sdkInt.toString(),
4343
"uuid": uuid,

lib/woosignal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import 'package:woosignal/models/response/setting_option_batch.dart';
5353
import 'package:woosignal/models/response/product_batch.dart';
5454

5555
/// WooSignal Package version
56-
const String wooSignalVersion = "3.1.1";
56+
const String wooSignalVersion = "3.2.0";
5757

5858
class WooSignal {
5959
WooSignal._privateConstructor();

pubspec.yaml

Lines changed: 2 additions & 2 deletions
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: 3.1.1
3+
version: 3.2.0
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
@@ -11,7 +11,7 @@ environment:
1111

1212
dependencies:
1313
dio: ^4.0.6
14-
device_info_plus: ^4.1.2
14+
device_info_plus: ^8.0.0
1515
shared_preferences: ^2.0.15
1616
uuid: ^3.0.6
1717

0 commit comments

Comments
 (0)