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 a resource path. |
||
65 | * |
||
66 | * @param AbstractRequest $request The request. |
||
67 | * @return string Returns the resource path. |
||
68 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
69 | */ |
||
70 | private function buildResourcePath(AbstractRequest $request) { |
||
82 | |||
83 | /** |
||
84 | * Call the API. |
||
85 | * |
||
86 | * @param string $uri The URI. |
||
87 | * @param array $queryData The query data. |
||
88 | * @return string Returns the raw response. |
||
89 | * @throws APIException Throws an API exception if an error occurs. |
||
90 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
91 | */ |
||
92 | private function callAPI($uri, array $queryData) { |
||
124 | |||
125 | /** |
||
126 | * Call the API. |
||
127 | * |
||
128 | * @param AbstractRequest $request The request. |
||
129 | * @param array $queryData The query data. |
||
130 | * @return string Returns the raw response. |
||
131 | * @throws APIException Throws an API exception if an error occurs. |
||
132 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
133 | */ |
||
134 | protected function callAPIWithRequest(AbstractRequest $request, array $queryData) { |
||
146 | |||
147 | /** |
||
148 | * Call the API. |
||
149 | * |
||
150 | * @param PaginateResponseInterface $response The request. |
||
151 | * @param bool $nextPage Next page ?. |
||
152 | * @return string Returns the raw response. |
||
153 | * @throws APIException Throws an API exception if an error occurs. |
||
154 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
155 | */ |
||
156 | protected function callAPIWithResponse(PaginateResponseInterface $response, $nextPage) { |
||
171 | |||
172 | /** |
||
173 | * Get the authorization. |
||
174 | * |
||
175 | * @return string Returns the authorization. |
||
176 | */ |
||
177 | public function getAuthorization() { |
||
180 | |||
181 | /** |
||
182 | * Get the debug. |
||
183 | * |
||
184 | * @return bool Returns the debug. |
||
185 | */ |
||
186 | public function getDebug() { |
||
189 | |||
190 | /** |
||
191 | * Set the authorization. |
||
192 | * |
||
193 | * @param string $authorization The authorization. |
||
194 | * @return AbstractProvider Returns this provider. |
||
195 | */ |
||
196 | public function setAuthorization($authorization) { |
||
200 | |||
201 | /** |
||
202 | * Set the debug. |
||
203 | * |
||
204 | * @param bool $debug The debug. |
||
205 | * @return AbstractProvider Returns this provider. |
||
206 | */ |
||
207 | public function setDebug($debug) { |
||
211 | } |
||
212 |