1 | <?php |
||
21 | final class Cart extends HttpApi |
||
22 | { |
||
23 | /** |
||
24 | * @throws Exception |
||
25 | * |
||
26 | * @return Model|ResponseInterface |
||
27 | */ |
||
28 | public function get(int $id) |
||
29 | { |
||
30 | if (empty($id)) { |
||
31 | throw new InvalidArgumentException('Id cannot be empty'); |
||
32 | } |
||
33 | |||
34 | $response = $this->httpGet('/api/v1/carts/'.$id); |
||
35 | if (!$this->hydrator) { |
||
36 | return $response; |
||
37 | } |
||
38 | |||
39 | // Use any valid status code here |
||
40 | if (200 !== $response->getStatusCode()) { |
||
41 | $this->handleErrors($response); |
||
42 | } |
||
43 | |||
44 | return $this->hydrator->hydrate($response, Model::class); |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * @throws Exception |
||
49 | * |
||
50 | * @return Model|ResponseInterface |
||
51 | */ |
||
52 | public function create(string $customer, string $channel, string $localeCode, array $params = []) |
||
82 | |||
83 | /** |
||
84 | * @throws Exception |
||
85 | * |
||
86 | * @return CartItem|ResponseInterface |
||
87 | */ |
||
88 | public function addItem(int $cartId, string $variant, int $quantity) |
||
119 | } |
||
120 |