createProductReview method
Returns a WooProductReview object.
Related endpoint: https://woocommerce.github.io/woocommerce-rest-api-docs/#product-reviews
Implementation
Future<WooProductReview> createProductReview(
{required int productId,
int? status,
required String reviewer,
required String reviewerEmail,
required String review,
int? rating,
bool? verified}) async {
Map<String, dynamic> payload = {};
({
'product_id': productId,
'status': status,
'reviewer': reviewer,
'reviewer_email': reviewerEmail,
'review': review,
'rating': rating,
'verified': verified,
}).forEach((k, v) {
if (v != null) payload[k] = v.toString();
});
WooProductReview productReview;
_setApiResourceUrl(
path: 'products/reviews',
);
final response = await post(queryUri.toString(), payload);
_printToLog('response gotten : ' + response.toString());
productReview = WooProductReview.fromJson(response);
return productReview;
}