1 | <?php |
||
13 | abstract class Provider |
||
14 | { |
||
15 | /** |
||
16 | * List of methods that require logged status. |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $loginRequiredFor = []; |
||
21 | |||
22 | /** |
||
23 | * Instance of the API Request. |
||
24 | * |
||
25 | * @var Request |
||
26 | */ |
||
27 | protected $request; |
||
28 | |||
29 | /** |
||
30 | * @var Response |
||
31 | */ |
||
32 | protected $response; |
||
33 | |||
34 | /** |
||
35 | * @var ProvidersContainer |
||
36 | */ |
||
37 | protected $container; |
||
38 | |||
39 | /** |
||
40 | * @param ProvidersContainer $container |
||
41 | * @internal param Request $request |
||
42 | * @internal param Response $response |
||
43 | */ |
||
44 | public function __construct(ProvidersContainer $container) |
||
50 | |||
51 | /** |
||
52 | * Executes a POST request to Pinterest API. |
||
53 | * |
||
54 | * @param array $requestOptions |
||
55 | * @param string $resourceUrl |
||
56 | * |
||
57 | * @return Response|bool |
||
58 | */ |
||
59 | protected function post($requestOptions, $resourceUrl) |
||
71 | |||
72 | /** |
||
73 | * Executes a GET request to Pinterest API. |
||
74 | * |
||
75 | * @param array $requestOptions |
||
76 | * @param string $resourceUrl |
||
77 | * @return array|bool|Response |
||
78 | */ |
||
79 | protected function get(array $requestOptions = [], $resourceUrl = '') |
||
91 | |||
92 | /** |
||
93 | * @param $url |
||
94 | * @param string $postString |
||
95 | * @return $this |
||
96 | */ |
||
97 | protected function execute($url, $postString = "") |
||
105 | |||
106 | /** |
||
107 | * @param string $method |
||
108 | * |
||
109 | * @return bool |
||
110 | */ |
||
111 | public function checkMethodRequiresLogin($method) |
||
115 | |||
116 | /** |
||
117 | * @return bool |
||
118 | */ |
||
119 | public function isLoggedIn() |
||
123 | |||
124 | /** |
||
125 | * @param mixed $data |
||
126 | * @param string $resourceUrl |
||
127 | * @param int $limit |
||
128 | * |
||
129 | * @return Pagination |
||
130 | */ |
||
131 | protected function paginate($data, $resourceUrl, $limit = Pagination::DEFAULT_LIMIT) |
||
139 | |||
140 | /** |
||
141 | * Accepts callback which should return PaginatedResponse object. |
||
142 | * |
||
143 | * @param callable $callback |
||
144 | * @param int $limit |
||
145 | * @return Pagination |
||
146 | */ |
||
147 | protected function paginateCustom(callable $callback, $limit = Pagination::DEFAULT_LIMIT) |
||
155 | |||
156 | /** |
||
157 | * @return Response |
||
158 | */ |
||
159 | public function getResponse() |
||
163 | |||
164 | /** |
||
165 | * @return Request |
||
166 | */ |
||
167 | public function getRequest() |
||
171 | |||
172 | protected function initToken() |
||
180 | } |
||
181 |