1 | <?php |
||
15 | abstract class Provider |
||
16 | { |
||
17 | /** |
||
18 | * List of methods that require logged status. |
||
19 | * |
||
20 | * @return array |
||
21 | */ |
||
22 | protected $loginRequiredFor = []; |
||
23 | |||
24 | /** |
||
25 | * Instance of the API Request. |
||
26 | * |
||
27 | * @var Request |
||
28 | */ |
||
29 | protected $request; |
||
30 | |||
31 | /** |
||
32 | * @var Response |
||
33 | */ |
||
34 | protected $response; |
||
35 | |||
36 | /** |
||
37 | * @var ProvidersContainer |
||
38 | */ |
||
39 | protected $container; |
||
40 | |||
41 | /** |
||
42 | * @param ProvidersContainer $container |
||
43 | * @internal param Request $request |
||
44 | * @internal param Response $response |
||
45 | */ |
||
46 | public function __construct(ProvidersContainer $container) |
||
52 | |||
53 | /** |
||
54 | * Executes a POST request to Pinterest API. |
||
55 | * |
||
56 | * @param array $requestOptions |
||
57 | * @param string $resourceUrl |
||
58 | * |
||
59 | * @return bool |
||
60 | */ |
||
61 | protected function post(array $requestOptions = [], $resourceUrl) |
||
73 | |||
74 | /** |
||
75 | * Executes a GET request to Pinterest API. |
||
76 | * |
||
77 | * @param array $requestOptions |
||
78 | * @param string $resourceUrl |
||
79 | * @return array|bool |
||
80 | */ |
||
81 | protected function get(array $requestOptions = [], $resourceUrl = '') |
||
93 | |||
94 | /** |
||
95 | * @param $url |
||
96 | * @param string $postString |
||
97 | * @return $this |
||
98 | */ |
||
99 | protected function execute($url, $postString = "") |
||
107 | |||
108 | |||
109 | /** |
||
110 | * @param string $method |
||
111 | * |
||
112 | * @return bool |
||
113 | */ |
||
114 | public function checkMethodRequiresLogin($method) |
||
120 | |||
121 | /** |
||
122 | * @return array |
||
123 | */ |
||
124 | protected function requiresLoginFor() |
||
138 | |||
139 | |||
140 | /** |
||
141 | * @return bool |
||
142 | */ |
||
143 | public function isLoggedIn() |
||
147 | |||
148 | /** |
||
149 | * @param mixed $data |
||
150 | * @param string $resourceUrl |
||
151 | * @param int $limit |
||
152 | * |
||
153 | * @return Pagination |
||
154 | */ |
||
155 | protected function paginate($data, $resourceUrl, $limit = Pagination::DEFAULT_LIMIT) |
||
163 | |||
164 | /** |
||
165 | * Accepts callback which should return PaginatedResponse object. |
||
166 | * |
||
167 | * @param callable $callback |
||
168 | * @param int $limit |
||
169 | * @return Pagination |
||
170 | */ |
||
171 | protected function paginateCustom(callable $callback, $limit = Pagination::DEFAULT_LIMIT) |
||
179 | |||
180 | /** |
||
181 | * @return Response |
||
182 | */ |
||
183 | public function getResponse() |
||
187 | |||
188 | /** |
||
189 | * @return Request |
||
190 | */ |
||
191 | public function getRequest() |
||
195 | |||
196 | protected function initTokenIfRequired() |
||
204 | } |
||
205 |