1 | <?php |
||
27 | class ComradeReader |
||
28 | { |
||
29 | /** @var ClientInterface $client */ |
||
30 | protected $client; |
||
31 | |||
32 | /** @var string $url */ |
||
33 | protected $url; |
||
34 | |||
35 | /** @var string $secretToken */ |
||
36 | protected $secretToken; |
||
37 | |||
38 | /** @var string $tokenFieldName */ |
||
39 | protected $tokenFieldName = 'token'; |
||
40 | |||
41 | /** @var Serializer $serializer */ |
||
42 | protected $serializer; |
||
43 | |||
44 | /** @var CacheProvider $cache */ |
||
45 | protected $cache; |
||
46 | |||
47 | /** |
||
48 | * @param string $apiUrl |
||
49 | * @param string $apiKey |
||
50 | * @param Serializer $serializer |
||
51 | * @param CacheProvider $cache |
||
52 | */ |
||
53 | public function __construct( |
||
64 | |||
65 | /** |
||
66 | * @return ClientInterface |
||
67 | */ |
||
68 | protected function getClient() |
||
80 | |||
81 | /** |
||
82 | * @param string $tokenFieldName |
||
83 | * @return ComradeReader |
||
84 | */ |
||
85 | public function setTokenFieldName($tokenFieldName) |
||
90 | |||
91 | /** |
||
92 | * @return string |
||
93 | */ |
||
94 | public function getTokenFieldName() |
||
98 | |||
99 | /** |
||
100 | * @return array |
||
101 | */ |
||
102 | protected function getConnectionOptions() |
||
110 | |||
111 | /** |
||
112 | * Make a request to the server |
||
113 | * and return a decoded response |
||
114 | * |
||
115 | * @param string $method |
||
116 | * @param string $url |
||
117 | * @param array $parameters |
||
118 | * @param int $cacheLifeTime |
||
119 | * |
||
120 | * @throws InvalidArgumentException |
||
121 | * @throws ResourceNotFoundException |
||
122 | * |
||
123 | * @return ComradeDeserializer |
||
124 | */ |
||
125 | public function request( |
||
171 | |||
172 | /** |
||
173 | * Alias to request() |
||
174 | * |
||
175 | * @param string $url |
||
176 | * @param array $parameters |
||
177 | * @param int $cacheLifeTime |
||
178 | * |
||
179 | * @throws ResourceNotFoundException |
||
180 | * @return ComradeDeserializer |
||
181 | */ |
||
182 | public function get( |
||
190 | |||
191 | /** |
||
192 | * Alias to request(), with "POST" preselected as a HTTP method |
||
193 | * |
||
194 | * @param string $url |
||
195 | * @param array $parameters |
||
196 | * @param int $cacheLifeTime |
||
197 | * |
||
198 | * @throws ResourceNotFoundException |
||
199 | * @return ComradeDeserializer |
||
200 | */ |
||
201 | public function post( |
||
209 | |||
210 | /** |
||
211 | * Alias to request(), with "PUT" preselected as a HTTP method |
||
212 | * |
||
213 | * @param string $url |
||
214 | * @param array $parameters |
||
215 | * @param int $cacheLifeTime |
||
216 | * |
||
217 | * @throws ResourceNotFoundException |
||
218 | * @return ComradeDeserializer |
||
219 | */ |
||
220 | public function put( |
||
228 | |||
229 | /** |
||
230 | * Alias to request(), with "DELETE" preselected as a HTTP method |
||
231 | * |
||
232 | * @param string $url |
||
233 | * @param array $parameters |
||
234 | * @param int $cacheLifeTime |
||
235 | * |
||
236 | * @throws ResourceNotFoundException |
||
237 | * @return ComradeDeserializer |
||
238 | */ |
||
239 | public function delete( |
||
247 | |||
248 | /** |
||
249 | * @param string $path |
||
250 | * @return string |
||
251 | */ |
||
252 | protected function getPreparedRequestUrl($path) |
||
256 | |||
257 | /** |
||
258 | * @param string $method |
||
259 | * @param string $url |
||
260 | * @param array $parameters |
||
261 | * @return string |
||
262 | */ |
||
263 | protected function getCacheId($method, $url, $parameters) |
||
267 | |||
268 | /** |
||
269 | * @param string $url |
||
270 | * @param string $method |
||
271 | * @param array $parameters |
||
272 | * |
||
273 | * @throws \InvalidArgumentException |
||
274 | * @return string |
||
275 | */ |
||
276 | protected function buildParameters($url, $method, $parameters) |
||
306 | } |