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

Commit 3ac754b

Browse files
committed
feat: add customer cart estimate shipping methods endpoint
1 parent 21f3d65 commit 3ac754b

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/Api/Carts.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,17 @@ public function mine()
1515

1616
return $this->get('/carts/mine');
1717
}
18+
19+
/**
20+
* Estimate shipping by address and return list of available shipping methods.
21+
*
22+
* @param array $body
23+
* @return array
24+
*/
25+
public function estimateShippingMethods($body = [])
26+
{
27+
$this->validateSingleStoreCode();
28+
29+
return $this->post('/carts/mine/estimate-shipping-methods', $body);
30+
}
1831
}

tests/Api/CartsTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,26 @@ public function test_must_pass_a_single_store_code_to_carts_mine()
3434
$magento = new Magento();
3535
$magento->api('carts')->mine();
3636
}
37+
38+
public function test_can_call_carts_estimate_shipping_methods()
39+
{
40+
Http::fake([
41+
'*rest/default/V1/carts/mine/estimate-shipping-methods' => Http::response([], 200),
42+
]);
43+
44+
$magento = new Magento();
45+
$magento->storeCode = 'default';
46+
47+
$api = $magento->api('carts')->estimateShippingMethods([]);
48+
49+
$this->assertTrue($api->ok());
50+
}
51+
52+
public function test_must_pass_a_single_store_code_to_estimate_shipping_methods()
53+
{
54+
$this->expectException('exception');
55+
56+
$magento = new Magento();
57+
$magento->api('carts')->estimateShippingMethods([]);
58+
}
3759
}

0 commit comments

Comments
 (0)