Skip to content

Commit 55015a2

Browse files
authored
Merge pull request #7 from woosignal/master
v3.0.4 - updates
2 parents d5b6aca + 48497c2 commit 55015a2

File tree

9 files changed

+90
-50
lines changed

9 files changed

+90
-50
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## [3.0.5] - 2022-01-29
2+
3+
* Version added to woosignal.dart
4+
* Flutter format
5+
* Improvements as per Dart analysis
6+
7+
## [3.0.4] - 2022-01-28
8+
9+
* Add new variables to woosignal_app
10+
* Update arguments for product review
11+
* Dependency updates
12+
113
## [3.0.3] - 2022-01-03
214

315
* Update coupon property types

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.0.3
18+
woosignal: ^3.0.5
1919
```
2020

2121
### Usage example #

example/lib/main.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
22
import 'package:woosignal/woosignal.dart';
33
import 'package:woosignal/models/response/products.dart';
44

5-
void woosignal_woocommerce_example() => runApp(MyApp());
5+
void woosignalWoocommerceExample() => runApp(MyApp());
66

77
class MyApp extends StatelessWidget {
88
@override

lib/models/response/continent.dart

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,23 +113,23 @@ class Country {
113113
};
114114
}
115115

116-
enum CurrencyPos { LEFT, LEFT_SPACE, RIGHT, RIGHT_SPACE }
116+
enum CurrencyPos { left, leftSpace, right, rightSpace }
117117

118118
final currencyPosValues = EnumValues({
119-
"left": CurrencyPos.LEFT,
120-
"left_space": CurrencyPos.LEFT_SPACE,
121-
"right": CurrencyPos.RIGHT,
122-
"right_space": CurrencyPos.RIGHT_SPACE
119+
"left": CurrencyPos.left,
120+
"left_space": CurrencyPos.leftSpace,
121+
"right": CurrencyPos.right,
122+
"right_space": CurrencyPos.rightSpace
123123
});
124124

125-
enum Sep { EMPTY, SEP, PURPLE }
125+
enum Sep { empty, sep, purple }
126126

127-
final sepValues = EnumValues({".": Sep.EMPTY, " ": Sep.PURPLE, ",": Sep.SEP});
127+
final sepValues = EnumValues({".": Sep.empty, " ": Sep.purple, ",": Sep.sep});
128128

129-
enum DimensionUnit { CM, IN }
129+
enum DimensionUnit { cm, inch }
130130

131131
final dimensionUnitValues =
132-
EnumValues({"cm": DimensionUnit.CM, "in": DimensionUnit.IN});
132+
EnumValues({"cm": DimensionUnit.cm, "in": DimensionUnit.inch});
133133

134134
class State {
135135
State({
@@ -151,9 +151,9 @@ class State {
151151
};
152152
}
153153

154-
enum WeightUnit { KG, OZ }
154+
enum WeightUnit { kg, oz }
155155

156-
final weightUnitValues = EnumValues({"kg": WeightUnit.KG, "oz": WeightUnit.OZ});
156+
final weightUnitValues = EnumValues({"kg": WeightUnit.kg, "oz": WeightUnit.oz});
157157

158158
class EnumValues<T> {
159159
Map<String, T> map;

lib/models/response/payment_gateway.dart

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -862,44 +862,44 @@ class TitleOptions {
862862
}
863863

864864
enum Placeholder {
865-
EMPTY,
866-
OPTIONAL,
867-
OPTIONAL_IF_YOU_PROVIDE_A_CERTIFICATE_BELOW,
868-
YOU_YOUREMAIL_COM
865+
empty,
866+
optional,
867+
optionalIfYouProvideACertificateBelow,
868+
youYourEmailCom
869869
}
870870

871871
final placeholderValues = EnumValues({
872-
"": Placeholder.EMPTY,
873-
"Optional": Placeholder.OPTIONAL,
872+
"": Placeholder.empty,
873+
"Optional": Placeholder.optional,
874874
"Optional if you provide a certificate below":
875-
Placeholder.OPTIONAL_IF_YOU_PROVIDE_A_CERTIFICATE_BELOW,
876-
"you@youremail.com": Placeholder.YOU_YOUREMAIL_COM
875+
Placeholder.optionalIfYouProvideACertificateBelow,
876+
"you@youremail.com": Placeholder.youYourEmailCom
877877
});
878878

879879
enum Type {
880-
TITLE,
881-
CHECKBOX,
882-
FILE,
883-
PASSWORD,
884-
TEXT,
885-
SELECT,
886-
EMAIL,
887-
MULTISELECT,
888-
IMAGE,
889-
TEXTAREA
880+
title,
881+
checkbox,
882+
file,
883+
password,
884+
text,
885+
select,
886+
email,
887+
multiselect,
888+
image,
889+
textarea
890890
}
891891

892892
final typeValues = EnumValues({
893-
"checkbox": Type.CHECKBOX,
894-
"email": Type.EMAIL,
895-
"file": Type.FILE,
896-
"image": Type.IMAGE,
897-
"multiselect": Type.MULTISELECT,
898-
"password": Type.PASSWORD,
899-
"select": Type.SELECT,
900-
"text": Type.TEXT,
901-
"textarea": Type.TEXTAREA,
902-
"title": Type.TITLE
893+
"checkbox": Type.checkbox,
894+
"email": Type.email,
895+
"file": Type.file,
896+
"image": Type.image,
897+
"multiselect": Type.multiselect,
898+
"password": Type.password,
899+
"select": Type.select,
900+
"text": Type.text,
901+
"textarea": Type.textarea,
902+
"title": Type.title
903903
});
904904

905905
class HideFundingMethods {

lib/models/response/woosignal_app.dart

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class WooSignalApp {
2626
String? stripeAccount;
2727
int? wpLoginEnabled;
2828
bool? couponEnabled;
29+
bool? showProductReviews;
30+
bool? showRelatedProducts;
31+
bool? showUpsellProducts;
2932
String? wpLoginBaseUrl;
3033
String? wpLoginForgotPasswordUrl;
3134
String? wpLoginWpApiPath;
@@ -101,6 +104,24 @@ class WooSignalApp {
101104
} else {
102105
couponEnabled = false;
103106
}
107+
if (json['show_product_reviews'] is int &&
108+
json['show_product_reviews'] == 1) {
109+
showProductReviews = true;
110+
} else {
111+
showProductReviews = false;
112+
}
113+
if (json['show_related_products'] is int &&
114+
json['show_related_products'] == 1) {
115+
showRelatedProducts = true;
116+
} else {
117+
showRelatedProducts = false;
118+
}
119+
if (json['show_upsell_products'] is int &&
120+
json['show_upsell_products'] == 1) {
121+
showUpsellProducts = true;
122+
} else {
123+
showUpsellProducts = false;
124+
}
104125
wpLoginBaseUrl = json['wp_login_base_url'];
105126
wpLoginForgotPasswordUrl = json['wp_login_forgot_password_url'];
106127
wpLoginWpApiPath = json['wp_login_wp_api_path'];

lib/networking/api_provider.dart

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ApiProvider {
2323
late Dio _dio;
2424
bool _debugMode;
2525
late final String _apiKey;
26+
late final String _version;
2627
Map<String, dynamic> _deviceMeta = {};
2728

2829
/// Set the device meta
@@ -41,7 +42,7 @@ class ApiProvider {
4142
"version": androidDeviceInfo.version.sdkInt.toString(),
4243
"uuid": uuid,
4344
"platform_type": "android",
44-
"api_version": "3.0.0/v3"
45+
"api_version": "$_version/v3"
4546
};
4647
} else if (Platform.isIOS) {
4748
IosDeviceInfo iosDeviceInfo = await deviceInfo.iosInfo;
@@ -52,7 +53,7 @@ class ApiProvider {
5253
"version": iosDeviceInfo.systemVersion,
5354
"uuid": uuid,
5455
"platform_type": "ios",
55-
"api_version": "3.0.0/v3"
56+
"api_version": "$_version/v3"
5657
};
5758
}
5859
}
@@ -88,9 +89,11 @@ class ApiProvider {
8889
}
8990

9091
/// Constructor requires a [appKey] from WooSignal
91-
ApiProvider({required String appKey, bool debugMode = true})
92+
ApiProvider(
93+
{required String appKey, required String version, bool debugMode = true})
9294
: _apiKey = appKey,
93-
_debugMode = debugMode;
95+
_debugMode = debugMode,
96+
_version = version;
9497

9598
/// Initialize class
9699
Future init() async {

lib/woosignal.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ import 'package:woosignal/models/response/setting_option.dart';
5151
import 'package:woosignal/models/response/setting_option_batch.dart';
5252
import 'package:woosignal/models/response/product_batch.dart';
5353

54+
/// WooSignal Package version
55+
const String wooSignalVersion = "3.0.5";
56+
5457
class WooSignal {
5558
WooSignal._privateConstructor();
5659
static final WooSignal instance = WooSignal._privateConstructor();
@@ -62,7 +65,8 @@ class WooSignal {
6265
Future<void> init({required String? appKey, bool debugMode = false}) async {
6366
assert(appKey != null && appKey != "",
6467
"Provide a valid app key. Visit https://woosignal.com");
65-
_apiProvider = ApiProvider(appKey: appKey!, debugMode: debugMode);
68+
_apiProvider = ApiProvider(
69+
appKey: appKey!, debugMode: debugMode, version: wooSignalVersion);
6670
setDebugMode(debugMode);
6771
await _apiProvider.init();
6872
}
@@ -428,11 +432,11 @@ class WooSignal {
428432
/// https://woosignal.com/docs/api/1.0/product-reviews
429433
Future<ProductReview?> createProductReview(
430434
{int? productId,
431-
int? status,
435+
String? status,
432436
String? reviewer,
433437
String? reviewerEmail,
434438
String? review,
435-
int? rating,
439+
int? rating, // Review rating (0 to 5)
436440
bool? verified}) async {
437441
Map<String, dynamic> payload = {};
438442

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.0.3
3+
version: 3.0.5
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
@@ -12,7 +12,7 @@ environment:
1212
dependencies:
1313
dio: ^4.0.4
1414
device_info: ^2.0.3
15-
shared_preferences: ^2.0.11
15+
shared_preferences: ^2.0.12
1616
uuid: ^3.0.5
1717

1818
flutter:

0 commit comments

Comments
 (0)