1 | <?php |
||
34 | abstract class ApiCall extends Nette\Object |
||
35 | { |
||
36 | /** |
||
37 | * @var OAuth\Consumer |
||
38 | */ |
||
39 | protected $consumer; |
||
40 | |||
41 | /** |
||
42 | * @var OAuth\HttpClient |
||
43 | */ |
||
44 | protected $httpClient; |
||
45 | |||
46 | /** |
||
47 | * @var Configuration |
||
48 | */ |
||
49 | protected $config; |
||
50 | |||
51 | /** |
||
52 | * @param OAuth\Consumer $consumer |
||
53 | * @param OAuth\HttpClient $httpClient |
||
54 | * @param Configuration $config |
||
55 | */ |
||
56 | public function __construct( |
||
65 | |||
66 | /** |
||
67 | * @internal |
||
68 | * |
||
69 | * @return OAuth\HttpClient |
||
70 | */ |
||
71 | public function getHttpClient() |
||
75 | |||
76 | /** |
||
77 | * @return Configuration |
||
78 | */ |
||
79 | public function getConfig() |
||
83 | |||
84 | /** |
||
85 | * @return OAuth\Consumer |
||
86 | */ |
||
87 | public function getConsumer() |
||
91 | |||
92 | /** |
||
93 | * Determines the access token that should be used for API calls. |
||
94 | * The first time this is called, $this->accessToken is set equal |
||
95 | * to either a valid user access token, or it's set to the application |
||
96 | * access token if a valid user access token wasn't available. Subsequent |
||
97 | * calls return whatever the first call returned. |
||
98 | * |
||
99 | * @return OAuth\Token The access token |
||
100 | */ |
||
101 | abstract public function getAccessToken(); |
||
102 | |||
103 | /** |
||
104 | * @param string $path |
||
105 | * @param array $params |
||
106 | * @param array $headers |
||
107 | * |
||
108 | * @return Utils\ArrayHash|string|Paginator|Utils\ArrayHash[] |
||
109 | * |
||
110 | * @throws OAuth\Exceptions\ApiException |
||
111 | */ |
||
112 | public function get($path, array $params = [], array $headers = []) |
||
116 | |||
117 | /** |
||
118 | * @param string $path |
||
119 | * @param array $params |
||
120 | * @param array $headers |
||
121 | * |
||
122 | * @return Utils\ArrayHash|string|Paginator|Utils\ArrayHash[] |
||
123 | * |
||
124 | * @throws OAuth\Exceptions\ApiException |
||
125 | */ |
||
126 | public function head($path, array $params = [], array $headers = []) |
||
130 | |||
131 | /** |
||
132 | * @param string $path |
||
133 | * @param array $params |
||
134 | * @param array $post |
||
135 | * @param array $headers |
||
136 | * |
||
137 | * @return Utils\ArrayHash|string|Paginator|Utils\ArrayHash[] |
||
138 | * |
||
139 | * @throws OAuth\Exceptions\ApiException |
||
140 | */ |
||
141 | public function post($path, array $params = [], array $post = [], array $headers = []) |
||
145 | |||
146 | /** |
||
147 | * @param string $path |
||
148 | * @param array $params |
||
149 | * @param array $post |
||
150 | * @param array $headers |
||
151 | * |
||
152 | * @return Utils\ArrayHash|string|Paginator|Utils\ArrayHash[] |
||
153 | * |
||
154 | * @throws OAuth\Exceptions\ApiException |
||
155 | */ |
||
156 | public function patch($path, array $params = [], array $post = [], array $headers = []) |
||
160 | |||
161 | /** |
||
162 | * @param string $path |
||
163 | * @param array $params |
||
164 | * @param array $post |
||
165 | * @param array $headers |
||
166 | * |
||
167 | * @return Utils\ArrayHash|string|Paginator|Utils\ArrayHash[] |
||
168 | * |
||
169 | * @throws OAuth\Exceptions\ApiException |
||
170 | */ |
||
171 | public function put($path, array $params = [], array $post = [], array $headers = []) |
||
175 | |||
176 | /** |
||
177 | * @param string $path |
||
178 | * @param array $params |
||
179 | * @param array $headers |
||
180 | * |
||
181 | * @return Utils\ArrayHash|string|Paginator|Utils\ArrayHash[] |
||
182 | * |
||
183 | * @throws OAuth\Exceptions\ApiException |
||
184 | */ |
||
185 | public function delete($path, array $params = [], array $headers = []) |
||
189 | |||
190 | /** |
||
191 | * Simply pass anything starting with a slash and it will call the Api, for example |
||
192 | * <code> |
||
193 | * $details = $flickr->api('flick.people.info'); |
||
194 | * </code> |
||
195 | * |
||
196 | * @param string $path |
||
197 | * @param string $method The argument is optional |
||
198 | * @param array $params Query parameters |
||
199 | * @param array $post Post request parameters or body to send |
||
200 | * @param array $headers Http request headers |
||
201 | * |
||
202 | * @return Utils\ArrayHash|string|Paginator|Utils\ArrayHash[] |
||
203 | * |
||
204 | * @throws OAuth\Exceptions\ApiException |
||
205 | */ |
||
206 | public function api($path, $method = Api\Request::GET, array $params = [], array $post = [], array $headers = []) |
||
237 | |||
238 | /** |
||
239 | * Upload photo to the Flickr |
||
240 | * |
||
241 | * @param string $photo |
||
242 | * @param array $params |
||
243 | * |
||
244 | * @return int |
||
245 | * |
||
246 | * @throws Exceptions\InvalidArgumentException |
||
247 | * @throws OAuth\Exceptions\ApiException|static |
||
248 | */ |
||
249 | public function uploadPhoto($photo, array $params = []) |
||
255 | |||
256 | /** |
||
257 | * Replace photo in Flickr |
||
258 | * |
||
259 | * @param string $photo |
||
260 | * @param int $photoId |
||
261 | * @param bool $async |
||
262 | * |
||
263 | * @return int |
||
264 | * |
||
265 | * @throws Exceptions\InvalidArgumentException |
||
266 | * @throws OAuth\Exceptions\ApiException|static |
||
267 | */ |
||
268 | public function replacePhoto($photo, $photoId, $async = FALSE) |
||
280 | |||
281 | /** |
||
282 | * @param string $method |
||
283 | * @param string $photo Path to image |
||
284 | * @param array $params |
||
285 | * |
||
286 | * @return Utils\ArrayHash |
||
287 | * |
||
288 | * @throws Exceptions\FileNotFoundException |
||
289 | * @throws OAuth\Exceptions\ApiException|static |
||
290 | */ |
||
291 | private function processImage($method, $photo, array $params = []) |
||
317 | } |