1 | <?php |
||
32 | abstract class AbstractProvider extends BaseProvider { |
||
33 | |||
34 | use RateLimitTrait; |
||
35 | |||
36 | /** |
||
37 | * Endpoint path. |
||
38 | * |
||
39 | * @var string |
||
40 | */ |
||
41 | const ENDPOINT_PATH = "https://api.pexels.com"; |
||
42 | |||
43 | /** |
||
44 | * Authorization. |
||
45 | * |
||
46 | * @var string |
||
47 | */ |
||
48 | private $authorization; |
||
49 | |||
50 | /** |
||
51 | * Constructor. |
||
52 | * |
||
53 | * @param string $authorization The authorization. |
||
54 | * @param LoggerInterface|null $logger The logger. |
||
55 | */ |
||
56 | public function __construct($authorization = null, LoggerInterface $logger = null) { |
||
57 | parent::__construct($logger); |
||
58 | $this->setAuthorization($authorization); |
||
59 | $this->setDebug(false); |
||
60 | $this->setLogger($logger); |
||
61 | } |
||
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) { |
||
137 | |||
138 | /** |
||
139 | * Call the API. |
||
140 | * |
||
141 | * @param AbstractRequest $request The request. |
||
142 | * @param array $queryData The query data. |
||
143 | * @return string Returns the raw response. |
||
144 | * @throws ApiException Throws an API exception if an error occurs. |
||
145 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
146 | */ |
||
147 | protected function callApiWithRequest(AbstractRequest $request, array $queryData) { |
||
159 | |||
160 | /** |
||
161 | * Call the API. |
||
162 | * |
||
163 | * @param PaginateResponseInterface $response The request. |
||
164 | * @param bool $nextPage Next page ?. |
||
165 | * @return string Returns the raw response. |
||
166 | * @throws APIException Throws an API exception if an error occurs. |
||
167 | * @throws InvalidArgumentException Throws an invalid argument exception if a parameter is missing. |
||
168 | */ |
||
169 | protected function callApiWithResponse(PaginateResponseInterface $response, $nextPage) { |
||
184 | |||
185 | /** |
||
186 | * Get the authorization. |
||
187 | * |
||
188 | * @return string Returns the authorization. |
||
189 | */ |
||
190 | public function getAuthorization() { |
||
193 | |||
194 | /** |
||
195 | * Log an info. |
||
196 | * |
||
197 | * @param string $message The message. |
||
198 | * @param array $context The context. |
||
199 | * @return AbstractProvider Returns this provider. |
||
200 | */ |
||
201 | protected function logInfo($message, array $context) { |
||
207 | |||
208 | /** |
||
209 | * Set the authorization. |
||
210 | * |
||
211 | * @param string $authorization The authorization. |
||
212 | * @return AbstractProvider Returns this provider. |
||
213 | */ |
||
214 | public function setAuthorization($authorization) { |
||
218 | } |
||
219 |