1 | <?php |
||
31 | abstract class AbstractProvider { |
||
32 | |||
33 | use RateLimitTrait; |
||
34 | |||
35 | /** |
||
36 | * Endpoint path. |
||
37 | * |
||
38 | * @var string |
||
39 | */ |
||
40 | const ENDPOINT_PATH = "https://api.pexels.com"; |
||
41 | |||
42 | /** |
||
43 | * Authorization. |
||
44 | * |
||
45 | * @var string |
||
46 | */ |
||
47 | private $authorization; |
||
48 | |||
49 | /** |
||
50 | * Debug. |
||
51 | * |
||
52 | * @var bool |
||
53 | */ |
||
54 | private $debug; |
||
55 | |||
56 | /** |
||
57 | * Constructor. |
||
58 | */ |
||
59 | public function __construct() { |
||
62 | |||
63 | /** |
||
64 | * Build the configuration. |
||
65 | * |
||
66 | * @return array Returns the configuration. |
||
67 | */ |
||
68 | private function buildConfiguration() { |
||
79 | |||
80 | /** |
||
81 | * Build a resource path. |
||
82 | * |
||
83 | * @param AbstractRequest $request The request. |
||
84 | * @return string Returns the resource path. |
||
85 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
86 | */ |
||
87 | private function buildResourcePath(AbstractRequest $request) { |
||
99 | |||
100 | /** |
||
101 | * Call the API. |
||
102 | * |
||
103 | * @param string $uri The URI. |
||
104 | * @param array $queryData The query data. |
||
105 | * @return string Returns the raw response. |
||
106 | * @throws APIException Throws an API exception if an error occurs. |
||
107 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
108 | */ |
||
109 | private function callAPI($uri, array $queryData) { |
||
133 | |||
134 | /** |
||
135 | * Call the API. |
||
136 | * |
||
137 | * @param AbstractRequest $request The request. |
||
138 | * @param array $queryData The query data. |
||
139 | * @return string Returns the raw response. |
||
140 | * @throws APIException Throws an API exception if an error occurs. |
||
141 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
142 | */ |
||
143 | protected function callAPIWithRequest(AbstractRequest $request, array $queryData) { |
||
155 | |||
156 | /** |
||
157 | * Call the API. |
||
158 | * |
||
159 | * @param PaginateResponseInterface $response The request. |
||
160 | * @param bool $nextPage Next page ?. |
||
161 | * @return string Returns the raw response. |
||
162 | * @throws APIException Throws an API exception if an error occurs. |
||
163 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
164 | */ |
||
165 | protected function callAPIWithResponse(PaginateResponseInterface $response, $nextPage) { |
||
180 | |||
181 | /** |
||
182 | * Get the authorization. |
||
183 | * |
||
184 | * @return string Returns the authorization. |
||
185 | */ |
||
186 | public function getAuthorization() { |
||
189 | |||
190 | /** |
||
191 | * Get the debug. |
||
192 | * |
||
193 | * @return bool Returns the debug. |
||
194 | */ |
||
195 | public function getDebug() { |
||
198 | |||
199 | /** |
||
200 | * Set the authorization. |
||
201 | * |
||
202 | * @param string $authorization The authorization. |
||
203 | * @return AbstractProvider Returns this provider. |
||
204 | */ |
||
205 | public function setAuthorization($authorization) { |
||
209 | |||
210 | /** |
||
211 | * Set the debug. |
||
212 | * |
||
213 | * @param bool $debug The debug. |
||
214 | * @return AbstractProvider Returns this provider. |
||
215 | */ |
||
216 | public function setDebug($debug) { |
||
220 | } |
||
221 |