1 | <?php |
||
7 | abstract class BaseClientRemote |
||
8 | { |
||
9 | /** |
||
10 | * Directus Server base endpoint |
||
11 | * |
||
12 | * @var string |
||
13 | */ |
||
14 | protected $baseEndpoint; |
||
15 | |||
16 | /** |
||
17 | * API Version |
||
18 | * |
||
19 | * @var string |
||
20 | */ |
||
21 | protected $apiVersion; |
||
22 | |||
23 | /** |
||
24 | * Directus Hosted endpoint format. |
||
25 | * |
||
26 | * @var string |
||
27 | */ |
||
28 | protected $hostedBaseEndpointFormat; |
||
29 | |||
30 | /** |
||
31 | * Directus Hosted Instance Key |
||
32 | * |
||
33 | * @var int|string |
||
34 | */ |
||
35 | protected $instanceKey; |
||
36 | |||
37 | /** |
||
38 | * Authentication Token |
||
39 | * |
||
40 | * @var string |
||
41 | */ |
||
42 | protected $accessToken; |
||
43 | |||
44 | /** |
||
45 | * HTTP Client |
||
46 | * |
||
47 | * @var \GuzzleHttp\Client |
||
48 | */ |
||
49 | protected $httpClient; |
||
50 | |||
51 | /** |
||
52 | * HTTP Client request timeout |
||
53 | * |
||
54 | * @var int |
||
55 | */ |
||
56 | protected $timeout = 60; |
||
57 | |||
58 | const TABLE_ENTRIES_ENDPOINT = 'tables/%s/rows'; |
||
59 | const TABLE_ENTRY_ENDPOINT = 'tables/%s/rows/%s'; |
||
60 | const TABLE_LIST_ENDPOINT = 'tables'; |
||
61 | const TABLE_INFORMATION_ENDPOINT = 'tables/%s'; |
||
62 | const TABLE_PREFERENCES_ENDPOINT = 'tables/%s/preferences'; |
||
63 | |||
64 | const COLUMN_LIST_ENDPOINT = 'tables/%s/columns'; |
||
65 | const COLUMN_INFORMATION_ENDPOINT = 'tables/%s/columns/%s'; |
||
66 | |||
67 | const GROUP_LIST_ENDPOINT = 'groups'; |
||
68 | const GROUP_INFORMATION_ENDPOINT = 'groups/%s'; |
||
69 | const GROUP_PRIVILEGES_ENDPOINT = 'privileges/%s'; |
||
70 | |||
71 | const FILE_LIST_ENDPOINT = 'files'; |
||
72 | const FILE_INFORMATION_ENDPOINT = 'files/%s'; |
||
73 | |||
74 | const SETTING_LIST_ENDPOINT = 'settings'; |
||
75 | const SETTING_COLLECTION_ENDPOINT = 'settings/%s'; |
||
76 | |||
77 | public function __construct($accessToken, $options = []) |
||
96 | |||
97 | /** |
||
98 | * Get the base endpoint url |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | public function getBaseEndpoint() |
||
106 | |||
107 | /** |
||
108 | * Get API Version |
||
109 | * |
||
110 | * @return int|string |
||
111 | */ |
||
112 | public function getAPIVersion() |
||
116 | |||
117 | /** |
||
118 | * Get the authentication access token |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | public function getAccessToken() |
||
126 | |||
127 | /** |
||
128 | * Set a new authentication access token |
||
129 | * |
||
130 | * @param $newAccessToken |
||
131 | */ |
||
132 | public function setAccessToken($newAccessToken) |
||
136 | |||
137 | /** |
||
138 | * Get the Directus hosted instance key |
||
139 | * |
||
140 | * @return null|string |
||
141 | */ |
||
142 | public function getInstanceKey() |
||
146 | |||
147 | /** |
||
148 | * Set the HTTP Client |
||
149 | * |
||
150 | * @param HTTPClient $httpClient |
||
151 | */ |
||
152 | public function setHTTPClient(HTTPClient $httpClient) |
||
156 | |||
157 | /** |
||
158 | * Get the HTTP Client |
||
159 | * |
||
160 | * @return HTTPClient|null |
||
161 | */ |
||
162 | public function getHTTPClient() |
||
166 | |||
167 | /** |
||
168 | * Get the default HTTP Client |
||
169 | * |
||
170 | * @return HTTPClient |
||
171 | */ |
||
172 | public function getDefaultHTTPClient() |
||
176 | |||
177 | public function performRequest($method, $pathFormat, $variables = []) |
||
184 | |||
185 | /** |
||
186 | * Build a request object |
||
187 | * |
||
188 | * @param $method |
||
189 | * @param $pathFormat |
||
190 | * @param $variables |
||
191 | * |
||
192 | * @return \GuzzleHttp\Message\Request |
||
193 | */ |
||
194 | public function buildRequest($method, $pathFormat, $variables = []) |
||
202 | |||
203 | /** |
||
204 | * Build a endpoint path based on a format |
||
205 | * |
||
206 | * @param string $pathFormat |
||
207 | * @param array $variables |
||
208 | * |
||
209 | * @return string |
||
210 | */ |
||
211 | public function buildPath($pathFormat, $variables = []) |
||
215 | } |
||
216 |