@@ 84-107 (lines=24) @@ | ||
81 | * |
|
82 | * @return ResponseInterface|void |
|
83 | */ |
|
84 | public function updatePaymentMethod(int $cartId, array $params = []) |
|
85 | { |
|
86 | if (empty($cartId)) { |
|
87 | throw new InvalidArgumentException('Cart id cannot be empty'); |
|
88 | } |
|
89 | ||
90 | $response = $this->httpPut('/api/v1/checkouts/select-payment/'.$cartId, $params); |
|
91 | if (!$this->hydrator) { |
|
92 | return $response; |
|
93 | } |
|
94 | ||
95 | // Use any valid status code here |
|
96 | if (204 !== $response->getStatusCode()) { |
|
97 | switch ($response->getStatusCode()) { |
|
98 | case 400: |
|
99 | throw new DomainExceptions\ValidationException(); |
|
100 | break; |
|
101 | default: |
|
102 | $this->handleErrors($response); |
|
103 | ||
104 | break; |
|
105 | } |
|
106 | } |
|
107 | } |
|
108 | ||
109 | /** |
|
110 | * @throws Exception |
|
@@ 114-137 (lines=24) @@ | ||
111 | * |
|
112 | * @return ResponseInterface|void |
|
113 | */ |
|
114 | public function complete(int $cartId) |
|
115 | { |
|
116 | if (empty($cartId)) { |
|
117 | throw new InvalidArgumentException('Cart id cannot be empty'); |
|
118 | } |
|
119 | ||
120 | $response = $this->httpPut('/api/v1/checkouts/complete/'.$cartId); |
|
121 | if (!$this->hydrator) { |
|
122 | return $response; |
|
123 | } |
|
124 | ||
125 | // Use any valid status code here |
|
126 | if (204 !== $response->getStatusCode()) { |
|
127 | switch ($response->getStatusCode()) { |
|
128 | case 400: |
|
129 | throw new DomainExceptions\ValidationException(); |
|
130 | break; |
|
131 | default: |
|
132 | $this->handleErrors($response); |
|
133 | ||
134 | break; |
|
135 | } |
|
136 | } |
|
137 | } |
|
138 | ||
139 | /** |
|
140 | * @throws Exception |
|
@@ 144-169 (lines=26) @@ | ||
141 | * |
|
142 | * @return ResponseInterface|ShipmentCollection |
|
143 | */ |
|
144 | public function getShippingMethods(int $cartId) |
|
145 | { |
|
146 | if (empty($cartId)) { |
|
147 | throw new InvalidArgumentException('Cart id cannot be empty'); |
|
148 | } |
|
149 | ||
150 | $response = $this->httpGet('/api/v1/checkouts/select-shipping/'.$cartId); |
|
151 | if (!$this->hydrator) { |
|
152 | return $response; |
|
153 | } |
|
154 | ||
155 | // Use any valid status code here |
|
156 | if (200 !== $response->getStatusCode()) { |
|
157 | switch ($response->getStatusCode()) { |
|
158 | case 400: |
|
159 | throw new DomainExceptions\ValidationException(); |
|
160 | break; |
|
161 | default: |
|
162 | $this->handleErrors($response); |
|
163 | ||
164 | break; |
|
165 | } |
|
166 | } |
|
167 | ||
168 | return $this->hydrator->hydrate($response, ShipmentCollection::class); |
|
169 | } |
|
170 | ||
171 | /** |
|
172 | * @throws Exception |
|
@@ 176-201 (lines=26) @@ | ||
173 | * |
|
174 | * @return PaymentCollection|ResponseInterface |
|
175 | */ |
|
176 | public function getPaymentMethods(int $cartId) |
|
177 | { |
|
178 | if (empty($cartId)) { |
|
179 | throw new InvalidArgumentException('Cart id cannot be empty'); |
|
180 | } |
|
181 | ||
182 | $response = $this->httpGet('/api/v1/checkouts/select-payment/'.$cartId); |
|
183 | if (!$this->hydrator) { |
|
184 | return $response; |
|
185 | } |
|
186 | ||
187 | // Use any valid status code here |
|
188 | if (200 !== $response->getStatusCode()) { |
|
189 | switch ($response->getStatusCode()) { |
|
190 | case 400: |
|
191 | throw new DomainExceptions\ValidationException(); |
|
192 | break; |
|
193 | default: |
|
194 | $this->handleErrors($response); |
|
195 | ||
196 | break; |
|
197 | } |
|
198 | } |
|
199 | ||
200 | return $this->hydrator->hydrate($response, PaymentCollection::class); |
|
201 | } |
|
202 | } |
|
203 |