WooSettingOptionBatchResponse class
WooCommerce Setting Option Batch Response Model
This class represents the response from a batch setting option 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 setting options with server-assigned IDs
- Update Results: List of successfully updated setting options
- Delete Results: List of successfully deleted setting options
- Comprehensive Response: All operations results in a single response object
Usage Examples
Processing Batch Response
final response = await wooCommerce.batchUpdateSettingOptions(
'general',
batchRequest,
);
// Process created setting options
for (final option in response.create ?? []) {
print('Created setting: ${option.label} with ID: ${option.id}');
print('Value: ${option.value}');
print('Type: ${option.type}');
}
// Process updated setting options
for (final option in response.update ?? []) {
print('Updated setting: ${option.label}');
print('New value: ${option.value}');
}
// Process deleted setting options
for (final option in response.delete ?? []) {
print('Deleted setting: ${option.id}');
}
Checking Batch Results
final response = await wooCommerce.batchUpdateSettingOptions(
'general',
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');
Analyzing Settings by Type
final response = await wooCommerce.batchUpdateSettingOptions(
'general',
batchRequest,
);
// Group created settings by type
final byType = <String, List<WooSettingOption>>{};
for (final option in response.create ?? []) {
final type = option.type ?? 'Unknown';
byType.putIfAbsent(type, () => []).add(option);
}
print('Settings by type:');
byType.forEach((type, options) {
print(' $type: ${options.length} settings');
});
JSON Serialization
The class supports full JSON serialization for API communication:
// Create from JSON response
final batchResponse = WooSettingOptionBatchResponse.fromJson(jsonData);
// Convert to JSON if needed
final json = batchResponse.toJson();
Constructors
-
WooSettingOptionBatchResponse({List<
WooSettingOption> ? create, List<WooSettingOption> ? update, List<WooSettingOption> ? delete}) - Creates a new WooSettingOptionBatchResponse instance
-
WooSettingOptionBatchResponse.fromJson(Map<
String, dynamic> json) -
Creates a WooSettingOptionBatchResponse instance from JSON data
factory
Properties
-
create
→ List<
WooSettingOption> ? -
List of created setting options
final
-
delete
→ List<
WooSettingOption> ? -
List of deleted setting options
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<
WooSettingOption> ? -
List of updated setting options
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toJson(
) → Map< String, dynamic> - Converts the WooSettingOptionBatchResponse instance to JSON format
-
toString(
) → String -
Returns a string representation of the WooSettingOptionBatchResponse instance
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited