Skip to content

Commit ab791cb

Browse files
author
WooSignal
committed
Ability to create Product reviews
1 parent d5f8647 commit ab791cb

File tree

5 files changed

+38
-4
lines changed

5 files changed

+38
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [1.0.6] - 2020-04-09
2+
3+
* Ability to create Product reviews
4+
15
## [1.0.5] - 2020-04-03
26

37
* Tweaks to ProductReviews model

example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ packages:
244244
path: ".."
245245
relative: true
246246
source: path
247-
version: "1.0.3"
247+
version: "1.0.6"
248248
xml:
249249
dependency: transitive
250250
description:

lib/models/response/product_review.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ProductReview {
2424
String review;
2525
int rating;
2626
bool verified;
27-
Map<String, String> reviewerAvatarUrls;
27+
Map<String, dynamic> reviewerAvatarUrls;
2828
Links links;
2929

3030
ProductReview(
@@ -53,7 +53,7 @@ class ProductReview {
5353
rating = json['rating'];
5454
verified = json['verified'];
5555
reviewerAvatarUrls = json['reviewer_avatar_urls'] != null
56-
? (json['reviewer_avatar_urls']).cast<Map<String, String>>()
56+
? (json['reviewer_avatar_urls'])
5757
: null;
5858
links = json['_links'] != null ? new Links.fromJson(json['_links']) : null;
5959
}

lib/woosignal.dart

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,36 @@ class WooSignal {
392392
return productReviews;
393393
}
394394

395+
/// https://woosignal.com/docs/api/1.0/product-reviews
396+
Future<ProductReview> createProductReview(
397+
{int productId,
398+
int status,
399+
String reviewer,
400+
String reviewerEmail,
401+
String review,
402+
int rating,
403+
bool verified}) async {
404+
Map<String, dynamic> payload = {};
405+
406+
if (productId != null) payload['product_id'] = productId;
407+
if (status != null) payload['status'] = status;
408+
if (reviewer != null) payload['reviewer'] = reviewer;
409+
if (reviewerEmail != null) payload['reviewer_email'] = reviewerEmail;
410+
if (review != null) payload['review'] = review;
411+
if (rating != null) payload['rating'] = rating;
412+
if (verified != null) payload['verified'] = verified;
413+
414+
_printLog(payload.toString());
415+
payload = _standardPayload("post", payload, "products/reviews");
416+
417+
ProductReview productReview;
418+
await _apiProvider.post("/request", payload).then((json) {
419+
productReview = ProductReview.fromJson(json);
420+
});
421+
_printLog(productReview.toString());
422+
return productReview;
423+
}
424+
395425
/// https://woosignal.com/docs/api/1.0/customers
396426
Future<List<Customer>> getCustomers(
397427
{int page,

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.0.5
3+
version: 1.0.6
44
homepage: https://woosignal.com
55
repository: https://github.com/woosignal/flutter-woocommerce-api
66

0 commit comments

Comments
 (0)