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

Commit 46e87b4

Browse files
committed
feat: add customer totals information api endpoint
1 parent 3ac754b commit 46e87b4

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/Api/Carts.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,20 @@ public function mine()
2525
public function estimateShippingMethods($body = [])
2626
{
2727
$this->validateSingleStoreCode();
28-
28+
2929
return $this->post('/carts/mine/estimate-shipping-methods', $body);
3030
}
31+
32+
/**
33+
* Calculate quote totals based on address and shipping method.
34+
*
35+
* @param array $body
36+
* @return array
37+
*/
38+
public function totalsInformation($body = [])
39+
{
40+
$this->validateSingleStoreCode();
41+
42+
return $this->post('/carts/mine/totals-information', $body);
43+
}
3144
}

tests/Api/CartsTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,18 @@ public function test_must_pass_a_single_store_code_to_estimate_shipping_methods(
5656
$magento = new Magento();
5757
$magento->api('carts')->estimateShippingMethods([]);
5858
}
59+
60+
public function test_can_call_carts_totals_information()
61+
{
62+
Http::fake([
63+
'*rest/default/V1/carts/mine/totals-information' => Http::response([], 200),
64+
]);
65+
66+
$magento = new Magento();
67+
$magento->storeCode = 'default';
68+
69+
$api = $magento->api('carts')->totalsInformation([]);
70+
71+
$this->assertTrue($api->ok());
72+
}
5973
}

tests/Api/GuestCartsTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,12 @@ public function test_can_call_guest_carts_totals_information()
9595

9696
$this->assertTrue($api->ok());
9797
}
98+
99+
public function test_must_pass_a_single_store_code_to_totals_information()
100+
{
101+
$this->expectException('exception');
102+
103+
$magento = new Magento();
104+
$magento->api('carts')->totalsInformation([]);
105+
}
98106
}

0 commit comments

Comments
 (0)