1 | <?php |
||
24 | final class RequestService implements RequestServiceInterface |
||
25 | { |
||
26 | const RETURN_KEY = 'data'; |
||
27 | /** @var ModuleOptionsInterface */ |
||
28 | private $moduleOptions; |
||
29 | /** @var Client */ |
||
30 | private $httpClient; |
||
31 | |||
32 | /** |
||
33 | * RequestService constructor. |
||
34 | * |
||
35 | * @param ModuleOptionsInterface $moduleOptions |
||
36 | * @param Client $client |
||
37 | * |
||
38 | * @throws \Zend\Http\Exception\InvalidArgumentException |
||
39 | */ |
||
40 | 16 | public function __construct(ModuleOptionsInterface $moduleOptions, Client $client) |
|
46 | |||
47 | /** |
||
48 | * Sends the request to the server |
||
49 | * |
||
50 | * @param string $reqMethod |
||
51 | * @param string $reqRoute |
||
52 | * @param RequestOptionsInterface $requestOptions |
||
53 | * |
||
54 | * @return array |
||
55 | * @throws \InvoiceNinjaModule\Exception\ApiAuthException |
||
56 | * @throws \InvoiceNinjaModule\Exception\EmptyResponseException |
||
57 | * @throws \InvoiceNinjaModule\Exception\HttpClientException |
||
58 | * @throws \InvoiceNinjaModule\Exception\HttpClientAuthException |
||
59 | */ |
||
60 | 14 | public function dispatchRequest($reqMethod, $reqRoute, RequestOptionsInterface $requestOptions) :array |
|
94 | |||
95 | /** |
||
96 | * @param Response $response |
||
97 | * |
||
98 | * @throws \InvoiceNinjaModule\Exception\ApiAuthException |
||
99 | * @throws \InvoiceNinjaModule\Exception\HttpClientException |
||
100 | * @throws \InvoiceNinjaModule\Exception\HttpClientAuthException |
||
101 | */ |
||
102 | 12 | private function checkResponseCode(Response $response) :void |
|
115 | |||
116 | /** |
||
117 | * @param Response $response |
||
118 | * |
||
119 | * @return array |
||
120 | * @throws \InvoiceNinjaModule\Exception\EmptyResponseException |
||
121 | */ |
||
122 | 9 | private function convertResponse(Response $response) :array |
|
145 | |||
146 | /** |
||
147 | * @param array $result |
||
148 | * |
||
149 | * @return array |
||
150 | * @throws \InvoiceNinjaModule\Exception\EmptyResponseException |
||
151 | */ |
||
152 | 6 | private function checkResponseKey(array $result) :array |
|
159 | |||
160 | /** |
||
161 | * @return array |
||
162 | */ |
||
163 | 13 | private function getRequestHeaderArray() :array |
|
171 | |||
172 | /** |
||
173 | * @return void |
||
174 | * @throws \Zend\Http\Exception\InvalidArgumentException |
||
175 | */ |
||
176 | 16 | private function initHttpClient() :void |
|
194 | } |
||
195 |