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

Commit da7b075

Browse files
author
Alejo
committed
fetch single order sync
1 parent 6b6ef2d commit da7b075

File tree

1 file changed

+13
-0
lines changed
  • plugins/woocommerce/src/main/kotlin/org/wordpress/android/fluxc/store

1 file changed

+13
-0
lines changed

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,19 @@ class WCOrderStore @Inject constructor(
603603
}
604604
}
605605

606+
suspend fun fetchSingleOrderSync(site: SiteModel, remoteOrderId: Long): WooResult<OrderEntity> {
607+
return coroutineEngine.withDefaultContext(API, this, "fetchSingleOrderSync") {
608+
val result = wcOrderRestClient.fetchSingleOrder(site, remoteOrderId)
609+
610+
return@withDefaultContext if (result.isError) {
611+
WooResult(WooError(API_ERROR, SERVER_ERROR, result.error.message))
612+
} else {
613+
insertOrder(site.localId(), result.orderWithMeta)
614+
WooResult(result.order)
615+
}
616+
}
617+
}
618+
606619
@Suppress("SpreadOperator")
607620
suspend fun fetchOrders(
608621
site: SiteModel,

0 commit comments

Comments
 (0)