Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit fe0b98e

Browse files
committed
Rename payload and add function comment
1 parent 724a0fd commit fe0b98e

File tree

2 files changed

+18
-7
lines changed

2 files changed

+18
-7
lines changed

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/network/rest/wpcom/wc/order/OrderRestClient.kt

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import org.wordpress.android.fluxc.network.rest.wpcom.wc.toWooError
3030
import org.wordpress.android.fluxc.persistence.entity.OrderNoteEntity
3131
import org.wordpress.android.fluxc.store.WCOrderStore
3232
import org.wordpress.android.fluxc.store.WCOrderStore.AddOrderShipmentTrackingResponsePayload
33-
import org.wordpress.android.fluxc.store.WCOrderStore.BulkUpdateOrderStatusPayload
33+
import org.wordpress.android.fluxc.store.WCOrderStore.BulkUpdateOrderStatusResponsePayload
3434
import org.wordpress.android.fluxc.store.WCOrderStore.DeleteOrderShipmentTrackingResponsePayload
3535
import org.wordpress.android.fluxc.store.WCOrderStore.FetchHasOrdersResponsePayload
3636
import org.wordpress.android.fluxc.store.WCOrderStore.FetchOrderListResponsePayload
@@ -1074,14 +1074,25 @@ class OrderRestClient @Inject constructor(
10741074
}
10751075
}
10761076

1077+
/**
1078+
* Performs a batch update of order statuses via the WooCommerce REST API.
1079+
*
1080+
* This endpoint enables updating multiple orders to the same status in a single network request.
1081+
* The WooCommerce API has a limit of 100 orders per batch update.
1082+
*
1083+
* @param site The site to perform the update on
1084+
* @param orderIds List of order IDs to update. Error if exceeds [BATCH_UPDATE_LIMIT]
1085+
* @param newStatus The new status to set for all specified orders
1086+
* @return [BulkUpdateOrderStatusResponsePayload] containing either the update results or an error
1087+
*/
10771088
suspend fun batchUpdateOrdersStatus(
10781089
site: SiteModel,
10791090
orderIds: List<Long>,
10801091
newStatus: String
1081-
): BulkUpdateOrderStatusPayload {
1092+
): BulkUpdateOrderStatusResponsePayload {
10821093
// Check batch update limit
10831094
if (orderIds.size > BATCH_UPDATE_LIMIT) {
1084-
return BulkUpdateOrderStatusPayload(
1095+
return BulkUpdateOrderStatusResponsePayload(
10851096
error = OrderError(
10861097
type = OrderErrorType.BULK_UPDATE_LIMIT_EXCEEDED,
10871098
message = "Cannot update more than 100 orders at once"
@@ -1107,15 +1118,15 @@ class OrderRestClient @Inject constructor(
11071118
return when (response) {
11081119
is WPAPIResponse.Success -> {
11091120
response.data?.let {
1110-
BulkUpdateOrderStatusPayload(it.update)
1111-
} ?: BulkUpdateOrderStatusPayload(
1121+
BulkUpdateOrderStatusResponsePayload(it.update)
1122+
} ?: BulkUpdateOrderStatusResponsePayload(
11121123
OrderError(GENERIC_ERROR, "Success response with empty data")
11131124
)
11141125
}
11151126

11161127
is WPAPIResponse.Error -> {
11171128
val orderError = wpAPINetworkErrorToOrderError(response.error)
1118-
BulkUpdateOrderStatusPayload(orderError)
1129+
BulkUpdateOrderStatusResponsePayload(orderError)
11191130
}
11201131
}
11211132
}

plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/store/WCOrderStore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ class WCOrderStore @Inject constructor(
298298
}
299299
}
300300

301-
class BulkUpdateOrderStatusPayload(
301+
class BulkUpdateOrderStatusResponsePayload(
302302
val response: List<BatchOrderApiResponse.OrderResponse>
303303
) : Payload<OrderError>() {
304304
constructor(error: OrderError) : this(emptyList()) {

0 commit comments

Comments
 (0)