createProductReview method

Future<WooProductReview> createProductReview({
  1. required int productId,
  2. int? status,
  3. required String reviewer,
  4. required String reviewerEmail,
  5. required String review,
  6. int? rating,
  7. bool? verified,
})

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;
}