Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 73b5739

Browse files
authored
Merge pull request #73 from zkimffm/edit-orders
Added post endpoint for updating an order.
2 parents d3f6394 + e086ed4 commit 73b5739

File tree

4 files changed

+236
-4
lines changed

4 files changed

+236
-4
lines changed

.idea/workspace.xml

Lines changed: 201 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,13 @@ List a specified order:
355355
Magento::api('orders')->show($orderId);
356356
```
357357

358+
`/V1/orders`
359+
https://magento.redoc.ly/2.4.3-admin/tag/orders#operation/salesOrderRepositoryV1SavePost
360+
Performs persist operations for a specified order.
361+
```php
362+
Magento::api('orders')->edit($entity = []);
363+
```
364+
358365

359366

360367

src/Api/Orders.php

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ class Orders extends AbstractApi
1010
* @param int $pageSize
1111
* @param int $currentPage
1212
* @param array $filters
13-
*
14-
* @return array
13+
* @return array
1514
*/
1615
public function all($pageSize = 50, $currentPage = 1, $filters = [])
1716
{
@@ -25,11 +24,25 @@ public function all($pageSize = 50, $currentPage = 1, $filters = [])
2524
* Loads a specified order.
2625
*
2726
* @param int $orderId
28-
*
29-
* @return array
27+
* @return array
3028
*/
3129
public function show($orderId)
3230
{
3331
return $this->get('/orders/'.$orderId);
3432
}
33+
34+
/**
35+
* Performs persist operations for a specified order.
36+
*
37+
* @see https://magento.redoc.ly/2.4.3-admin/tag/orders/#operation/salesOrderRepositoryV1SavePost
38+
*
39+
* @param array $entity
40+
* @return array
41+
*/
42+
public function edit($entity = [])
43+
{
44+
return $this->post('/orders', [
45+
'entity' => $entity,
46+
]);
47+
}
3548
}

tests/Api/OrdersTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,15 @@ public function test_can_call_magento_show()
4848

4949
$this->assertTrue($api->ok());
5050
}
51+
52+
public function test_can_edit_and_save_order()
53+
{
54+
Http::fake([
55+
'*rest/all/V1/orders' => Http::response([], 200),
56+
]);
57+
58+
$api = MagentoFacade::api('orders')->edit([]);
59+
60+
$this->assertTrue($api->ok());
61+
}
5162
}

0 commit comments

Comments
 (0)