Total Complexity | 7 |
Total Lines | 73 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
16 | class ConfirmOrderMethod extends AbstractMethod |
||
17 | { |
||
18 | /** |
||
19 | * Get Order Endpoint |
||
20 | */ |
||
21 | const ENDPOINT = '/orders'; |
||
22 | |||
23 | const CONFIRM_ENDPOINT = 'confirm'; |
||
24 | |||
25 | /** |
||
26 | * @var string $orderId |
||
27 | */ |
||
28 | protected $orderId; |
||
29 | |||
30 | /** |
||
31 | * @param string $orderId |
||
32 | * |
||
33 | * @return $this |
||
34 | */ |
||
35 | public function setOrderId($orderId) |
||
36 | { |
||
37 | $this->orderId = $orderId; |
||
38 | |||
39 | return $this; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * call |
||
44 | * |
||
45 | * @return $this|AbstractMethod |
||
46 | * @throws \Httpful\Exception\ConnectionErrorException |
||
47 | * @throws \Pagantis\OrdersApiClient\Exception\HttpException |
||
48 | * @throws ClientException |
||
49 | */ |
||
50 | public function call() |
||
51 | { |
||
52 | if (is_string($this->orderId)) { |
||
|
|||
53 | $this->prepareRequest(); |
||
54 | return $this->setResponse($this->request->send()); |
||
55 | } |
||
56 | throw new ClientException('Please set OrderId'); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * @return bool|Order |
||
61 | */ |
||
62 | public function getOrder() |
||
63 | { |
||
64 | $response = $this->getResponse(); |
||
65 | if ($response instanceof Response) { |
||
66 | $order = new Order(); |
||
67 | $order->import($this->getResponse()->body); |
||
68 | return $order; |
||
69 | } |
||
70 | |||
71 | return false; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * prepareRequest |
||
76 | */ |
||
77 | protected function prepareRequest() |
||
89 | ) |
||
90 | ; |
||
91 | } |
||
92 | } |
||
94 |