1 | <?php |
||
26 | abstract class Api |
||
27 | { |
||
28 | /** |
||
29 | * @var bool |
||
30 | */ |
||
31 | protected $isSensitive = false; |
||
32 | |||
33 | /** |
||
34 | * @var HttpClientInterface |
||
35 | */ |
||
36 | protected $httpClient; |
||
37 | |||
38 | /** |
||
39 | * @var array |
||
40 | */ |
||
41 | protected $options; |
||
42 | |||
43 | /** |
||
44 | * @var HydrationInterface |
||
45 | */ |
||
46 | private $hydration; |
||
47 | |||
48 | /** |
||
49 | * @param HttpClientInterface $httpClient |
||
50 | * @param array $options |
||
51 | * @param HydrationInterface $hydration |
||
52 | */ |
||
53 | public function __construct(HttpClientInterface $httpClient, array $options, HydrationInterface $hydration = null) |
||
64 | |||
65 | /** |
||
66 | * @param OptionsResolver $resolver |
||
67 | */ |
||
68 | protected function configureOptions(OptionsResolver $resolver) |
||
78 | |||
79 | /** |
||
80 | * @return string |
||
81 | */ |
||
82 | protected function getAuthorizationKey() |
||
86 | |||
87 | /** |
||
88 | * @return string |
||
89 | */ |
||
90 | protected function getApiServer() |
||
94 | |||
95 | /** |
||
96 | * @param string $method |
||
97 | * @param string $path |
||
98 | * @param array $data |
||
99 | * @param array $headers |
||
100 | * |
||
101 | * @return mixed|Model |
||
102 | * @throws InvalidResponseException |
||
103 | */ |
||
104 | protected function doRequest($method, $path, array $data = [], array $headers = []) |
||
118 | |||
119 | /** |
||
120 | * @param ResponseInterface $response |
||
121 | * |
||
122 | * @return mixed|Model |
||
123 | * @throws InvalidResponseException |
||
124 | */ |
||
125 | protected function hydrateResponse(ResponseInterface $response) |
||
148 | |||
149 | /** |
||
150 | * @param string $id |
||
151 | * @param string $message |
||
152 | * |
||
153 | * @throws InvalidRequestArgumentException |
||
154 | */ |
||
155 | protected static function assertNotEmpty($id, $message = 'Id can not be empty.') |
||
161 | } |
||
162 |