1 | <?php |
||
18 | class Client |
||
19 | { |
||
20 | const DEFAULT_OPTIONS = [ |
||
21 | 'schema' => 'https', |
||
22 | 'path' => '/', |
||
23 | 'user_agent' => 'WyriHaximus/php-api-client', |
||
24 | 'headers' => [], |
||
25 | ]; |
||
26 | |||
27 | /** |
||
28 | * @var GuzzleClient |
||
29 | */ |
||
30 | protected $handler; |
||
31 | |||
32 | /** |
||
33 | * @var LoopInterface |
||
34 | */ |
||
35 | protected $loop; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | protected $options = []; |
||
41 | |||
42 | /** |
||
43 | * @var Hydrator |
||
44 | */ |
||
45 | protected $hydrator; |
||
46 | |||
47 | /** |
||
48 | * @var CacheInterface |
||
49 | */ |
||
50 | protected $cache; |
||
51 | |||
52 | public function __construct(LoopInterface $loop, GuzzleClient $handler, $options = []) |
||
62 | |||
63 | public function request(string $path, bool $refresh = false): PromiseInterface |
||
73 | |||
74 | protected function checkCache(string $path) |
||
84 | |||
85 | protected function sendRequest(string $path, string $method = 'GET'): PromiseInterface |
||
101 | |||
102 | protected function createRequest(string $method, string $path) |
||
111 | |||
112 | protected function jsonDecode($json): PromiseInterface |
||
118 | |||
119 | public function getHydrator(): Hydrator |
||
123 | |||
124 | public function getLoop(): LoopInterface |
||
128 | } |
||
129 |