getProductReviews method
Returns a list of all WooProductReview, with filter options.
Related endpoint: https://woocommerce.github.io/woocommerce-rest-api-docs/#product-reviews
Implementation
Future<List<WooProductReview>> getProductReviews(
{int? page,
int? perPage,
String? search,
String? after,
String? before,
//List<int> exclude,
//List<int> include,
int? offset,
String? order,
String? orderBy,
List<int>? reviewer,
//List<int> reviewerExclude,
//List<String> reviewerEmail,
List<int>? product,
String? status}) async {
Map<String, dynamic> payload = {};
({
'page': page, 'per_page': perPage, 'search': search,
'after': after, 'before': before,
//'exclude': exclude, 'include': include,
'offset': offset,
'order': order, 'orderby': orderBy,
'reviewer': reviewer,
//'reviewer_exclude': reviewerExclude, 'reviewer_email': reviewerEmail,
'product': product,
'status': status,
}).forEach((k, v) {
if (v != null) payload[k] = v;
});
String meQueryPath = 'products/reviews' + getQueryString(payload);
List<WooProductReview> productReviews = [];
//_setApiResourceUrl(path: 'products/reviews', queryParameters: payload);
final response = await get(meQueryPath);
_printToLog('response gotten : ' + response.toString());
for (var r in response) {
var rev = WooProductReview.fromJson(r);
_printToLog('reviews gotten here : ' + rev.toString());
productReviews.add(rev);
}
return productReviews;
}