1 | <?php |
||
23 | final class HTTPlugConnection extends AbstractConnection |
||
24 | { |
||
25 | /** |
||
26 | * @var HttpClient |
||
27 | */ |
||
28 | private $client; |
||
29 | |||
30 | /** |
||
31 | * @var RequestFactory |
||
32 | */ |
||
33 | private $requestFactory; |
||
34 | |||
35 | /** |
||
36 | * Initialize client. |
||
37 | * |
||
38 | * @param HttpClient $client |
||
39 | * @param RequestFactory $requestFactory |
||
40 | * @param string $apiKey |
||
41 | * @param string $uri |
||
42 | */ |
||
43 | public function __construct(HttpClient $client, RequestFactory $requestFactory, string $apiKey, string $uri = null) |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function call(string $method, array $params = [], string $requestMethod = 'GET'): array |
||
70 | |||
71 | /** |
||
72 | * @param ResponseInterface $response |
||
73 | * |
||
74 | * @throws ApiException |
||
75 | * @throws NotFoundException |
||
76 | * |
||
77 | * @return array |
||
78 | */ |
||
79 | private function parseResponse(ResponseInterface $response): array |
||
98 | |||
99 | /** |
||
100 | * Builds request parameter. |
||
101 | * |
||
102 | * @param array $parameter |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | private static function buildParameter(array $parameter): string |
||
110 | |||
111 | /** |
||
112 | * @param string $method |
||
113 | * @param array $params |
||
114 | * @param string $requestMethod |
||
115 | * |
||
116 | * @return RequestInterface |
||
117 | */ |
||
118 | private function buildRequest(string $method, array $params, string $requestMethod): RequestInterface |
||
133 | } |
||
134 |