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

Commit b06ca0e

Browse files
authored
Merge pull request #3115 from wordpress-mobile/action-send_order_details-endpoint
Endpoint: Action send order details
2 parents 3d45586 + 79440d5 commit b06ca0e

File tree

6 files changed

+49
-0
lines changed

6 files changed

+49
-0
lines changed

example/src/androidTest/java/org/wordpress/android/fluxc/mocked/MockedStack_WCOrdersTest.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -568,6 +568,15 @@ class MockedStack_WCOrdersTest : MockedStack_Base() {
568568
)
569569
}
570570

571+
@Test
572+
fun testSendOrderReceipt() = runBlocking {
573+
interceptor.respondWith("wc-order-action-send-order-details-success.json")
574+
575+
val result = orderRestClient.sendOrderReceipt(siteModel, 0)
576+
577+
assertFalse(result.isError)
578+
}
579+
571580
@Suppress("unused")
572581
@Subscribe
573582
fun onAction(action: Action<*>) {
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"data": {
3+
"message": "Order details email sent to customer."
4+
}
5+
}

example/src/test/java/org/wordpress/android/fluxc/wc/order/WCOrderStoreTest.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,19 @@ class WCOrderStoreTest {
592592
}
593593
}
594594

595+
@Test
596+
fun testSendOrderReceipt() {
597+
runBlocking {
598+
val orderModel = OrderTestUtils.generateSampleOrder(42)
599+
val site = SiteModel().apply { id = orderModel.localSiteId.value }
600+
val orderId = 42L
601+
602+
orderStore.sendOrderReceipt(site, orderId)
603+
604+
verify(orderRestClient).sendOrderReceipt(site, orderId)
605+
}
606+
}
607+
595608
private fun setupMissingOrders(): MutableMap<WCOrderSummaryModel, OrderEntity?> {
596609
return mutableMapOf<WCOrderSummaryModel, OrderEntity?>().apply {
597610
(21L..30L).forEach { index ->

fluxc-processor/src/main/resources/wc-wp-api-endpoints.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
/orders/<id>/shipment-trackings/<tracking>#String/
66
/orders/<id>/shipment-trackings/providers/
77
/orders/<id>/receipt/
8+
/orders/<id>/actions/send_order_details
89

910
/products/<id>/
1011
/products/<id>/variations/

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,19 @@ class OrderRestClient @Inject constructor(
10231023
return response.toWooPayload { it }
10241024
}
10251025

1026+
suspend fun sendOrderReceipt(
1027+
site: SiteModel,
1028+
orderId: Long,
1029+
): WooPayload<Unit> {
1030+
val response = wooNetwork.executePostGsonRequest(
1031+
site = site,
1032+
path = WOOCOMMERCE.orders.id(orderId).actions.send_order_details.pathV3,
1033+
clazz = Unit::class.java,
1034+
)
1035+
1036+
return response.toWooPayload { it }
1037+
}
1038+
10261039
private suspend fun doFetchOrderCount(site: SiteModel, filterByStatus: String?): FetchOrdersCountResponsePayload {
10271040
val url = WOOCOMMERCE.reports.orders.totals.pathV3
10281041

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,6 +728,14 @@ class WCOrderStore @Inject constructor(
728728
forceNew
729729
)
730730

731+
suspend fun sendOrderReceipt(
732+
site: SiteModel,
733+
orderId: Long,
734+
) = wcOrderRestClient.sendOrderReceipt(
735+
site,
736+
orderId
737+
)
738+
731739
private suspend fun optimisticallyUpdateOrder(
732740
orderId: Long,
733741
localSiteId: LocalId,

0 commit comments

Comments
 (0)