WooProductReviewBatchResponse class
WooCommerce Product Review Batch Response Model
This class represents the response from a batch product review operation. It contains the results of create, update, and delete operations performed in a single batch request.
Key Features
- Create Results: List of successfully created reviews with server-assigned IDs
- Update Results: List of successfully updated reviews
- Delete Results: List of successfully deleted reviews
- Comprehensive Response: All operations results in a single response object
Usage Examples
Processing Batch Response
final response = await wooCommerce.batchUpdateProductReviews(batchRequest);
// Process created reviews
for (final review in response.create ?? []) {
print('Created review: ${review.reviewer} with ID: ${review.id}');
print('Status: ${review.status}');
}
// Process updated reviews
for (final review in response.update ?? []) {
print('Updated review: ${review.reviewer}');
print('New status: ${review.status}');
}
// Process deleted reviews
for (final review in response.delete ?? []) {
print('Deleted review: ${review.reviewer}');
}
Checking Batch Results
final response = await wooCommerce.batchUpdateProductReviews(batchRequest);
final createdCount = response.create?.length ?? 0;
final updatedCount = response.update?.length ?? 0;
final deletedCount = response.delete?.length ?? 0;
print('Batch operation completed:');
print(' Created: $createdCount');
print(' Updated: $updatedCount');
print(' Deleted: $deletedCount');
Handling Review Status Changes
final response = await wooCommerce.batchUpdateProductReviews(batchRequest);
// Check which reviews were approved
final approvedReviews = response.update
?.where((review) => review.status == WooProductReviewStatus.approved)
.toList() ?? [];
print('Approved ${approvedReviews.length} reviews');
JSON Serialization
The class supports full JSON serialization for API communication:
// Create from JSON response
final batchResponse = WooProductReviewBatchResponse.fromJson(jsonData);
// Convert to JSON if needed
final json = batchResponse.toJson();
Constructors
-
WooProductReviewBatchResponse({List<
WooProductReview> ? create, List<WooProductReview> ? update, List<WooProductReview> ? delete}) - Creates a new WooProductReviewBatchResponse instance
-
WooProductReviewBatchResponse.fromJson(Map<
String, dynamic> json) -
Creates a WooProductReviewBatchResponse instance from JSON data
factory
Properties
-
create
→ List<
WooProductReview> ? -
List of created reviews
final
-
delete
→ List<
WooProductReview> ? -
List of deleted reviews
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
update
→ List<
WooProductReview> ? -
List of updated reviews
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts the WooProductReviewBatchResponse instance to JSON format
-
toString(
) → String -
Returns a string representation of the WooProductReviewBatchResponse instance
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited