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( |
||
57 | OAuth\Consumer $consumer, |
||
58 | OAuth\HttpClient $httpClient, |
||
59 | Configuration $config |
||
60 | ){ |
||
61 | $this->consumer = $consumer; |
||
62 | $this->httpClient = $httpClient; |
||
63 | $this->config = $config; |
||
64 | } |
||
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 = $twitter->api('users/show.json'); |
||
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 = []) |
||
231 | |||
232 | /** |
||
233 | * Upload photo to the Twitter |
||
234 | * |
||
235 | * @param string $file |
||
236 | * @param string|null $status |
||
237 | * |
||
238 | * @return Utils\ArrayHash |
||
239 | * |
||
240 | * @throws Exceptions\FileNotFoundException |
||
241 | * @throws Exceptions\InvalidArgumentException |
||
242 | * @throws OAuth\Exceptions\ApiException|static |
||
243 | */ |
||
244 | public function uploadMedia($file, $status = NULL) |
||
284 | } |