1 | <?php namespace Atog\Api; |
||
10 | abstract class Client |
||
11 | { |
||
12 | /** |
||
13 | * Endpoints |
||
14 | * @var string |
||
15 | */ |
||
16 | protected $endpoints = []; |
||
17 | |||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $domain; |
||
22 | |||
23 | /** |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $config; |
||
27 | |||
28 | /** |
||
29 | * A array containing the cached endpoints |
||
30 | * @var array |
||
31 | */ |
||
32 | private $cachedEndpoints = []; |
||
33 | |||
34 | /** |
||
35 | * Create a new client instance. |
||
36 | * @param array $endpoints |
||
37 | * @param array $config |
||
38 | */ |
||
39 | 12 | public function __construct(array $endpoints, array $config = []) |
|
44 | |||
45 | /** |
||
46 | * @param array $endpoints |
||
47 | * @throws \Atog\Api\Exceptions\InvalidEndpointException |
||
48 | */ |
||
49 | 12 | protected function setEndpoints(array $endpoints) |
|
67 | |||
68 | /** |
||
69 | * @return array |
||
70 | */ |
||
71 | 1 | public function getConfig() |
|
75 | |||
76 | /** |
||
77 | * Make a GET Request to an endpoint |
||
78 | * @param $endpoint |
||
79 | * @param array $params |
||
80 | * @return \Jyggen\Curl\Response |
||
81 | * @throws \Jyggen\Curl\Exception\CurlErrorException |
||
82 | * @throws \Jyggen\Curl\Exception\ProtectedOptionException |
||
83 | */ |
||
84 | 2 | public function get($endpoint, $params = []) |
|
111 | |||
112 | /** |
||
113 | * Get an API endpoint |
||
114 | * @param string $endpoint |
||
115 | * @return \Atog\Api\Endpoint |
||
116 | * @throws \Atog\Api\Exceptions\InvalidEndpointException |
||
117 | */ |
||
118 | 4 | public function __get($endpoint) |
|
122 | |||
123 | /** |
||
124 | * Get an API endpoint. |
||
125 | * @param string $endpoint |
||
126 | * @return \Atog\Api\Endpoint |
||
127 | * @throws \Atog\Api\Exceptions\InvalidEndpointException |
||
128 | */ |
||
129 | 8 | public function getEndpoint($endpoint) |
|
161 | } |
||
162 |