1 | <?php |
||
15 | class Pocket |
||
16 | { |
||
17 | /** |
||
18 | * Consumer key. |
||
19 | * |
||
20 | * @var string |
||
21 | */ |
||
22 | protected $consumerKey; |
||
23 | |||
24 | /** |
||
25 | * Access token. |
||
26 | * |
||
27 | * @var string|null |
||
28 | */ |
||
29 | protected $accessToken = null; |
||
30 | |||
31 | /** |
||
32 | * Http client. |
||
33 | * |
||
34 | * @var GuzzleClient|null |
||
35 | */ |
||
36 | protected $httpClient = null; |
||
37 | |||
38 | /** |
||
39 | * Pocket's authentication api. |
||
40 | * |
||
41 | * @var Authentication|null |
||
42 | */ |
||
43 | protected $authenticationApi = null; |
||
44 | |||
45 | /** |
||
46 | * Pocket's add api. |
||
47 | * |
||
48 | * @var Add|null |
||
49 | */ |
||
50 | protected $addApi = null; |
||
51 | |||
52 | /** |
||
53 | * Pocket's modify api. |
||
54 | * |
||
55 | * @var Modify|null |
||
56 | */ |
||
57 | protected $modifyApi = null; |
||
58 | |||
59 | /** |
||
60 | * Pocket's retrieve api. |
||
61 | * |
||
62 | * @var Retrieve|null |
||
63 | */ |
||
64 | protected $retrieveApi = null; |
||
65 | |||
66 | /** |
||
67 | * Pocket constructor. |
||
68 | * |
||
69 | * @param string $consumerKey |
||
70 | * @param string|null $accessToken |
||
71 | * @param GuzzleClient|null $httpClient |
||
72 | */ |
||
73 | public function __construct(string $consumerKey, string $accessToken = null, GuzzleClient $httpClient = null) |
||
85 | |||
86 | /** |
||
87 | * Pocket's authentication api. |
||
88 | * |
||
89 | * @return Authentication |
||
90 | */ |
||
91 | public function authenticationApi(): Authentication |
||
99 | |||
100 | /** |
||
101 | * Pocket's add api. |
||
102 | * |
||
103 | * @return Add |
||
104 | */ |
||
105 | public function addApi(): Add |
||
115 | |||
116 | /** |
||
117 | * Pocket's modify api. |
||
118 | * |
||
119 | * @return Modify |
||
120 | */ |
||
121 | public function modifyApi(): Modify |
||
131 | |||
132 | /** |
||
133 | * Pocket's retrieve api. |
||
134 | * |
||
135 | * @return Retrieve |
||
136 | */ |
||
137 | public function retrieveApi(): Retrieve |
||
147 | |||
148 | /** |
||
149 | * Get the consumer key. |
||
150 | * |
||
151 | * @return string |
||
152 | */ |
||
153 | public function getConsumerKey(): string |
||
158 | |||
159 | /** |
||
160 | * Set the consumer key. |
||
161 | * |
||
162 | * @param string $consumerKey |
||
163 | */ |
||
164 | public function setConsumerKey(string $consumerKey) |
||
169 | |||
170 | /** |
||
171 | * Get the access token. |
||
172 | * |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getAccessToken(): string |
||
180 | |||
181 | /** |
||
182 | * Set the access token. |
||
183 | * |
||
184 | * @param string $accessToken |
||
185 | */ |
||
186 | public function setAccessToken(string $accessToken) |
||
191 | |||
192 | /** |
||
193 | * Get the Guzzle http client. |
||
194 | * |
||
195 | * @return GuzzleClient |
||
196 | */ |
||
197 | public function getHttpClient(): GuzzleClient |
||
201 | |||
202 | /** |
||
203 | * Set the Guzzle http client. |
||
204 | * |
||
205 | * @param GuzzleClient|null $httpClient |
||
206 | */ |
||
207 | public function setHttpClient(GuzzleClient $httpClient = null) |
||
215 | |||
216 | /** |
||
217 | * Check a key. |
||
218 | * |
||
219 | * @param $key |
||
220 | * @param string $name |
||
221 | * |
||
222 | * @throws PocketException |
||
223 | */ |
||
224 | protected function checkKey($key, string $name) |
||
234 | |||
235 | /** |
||
236 | * Check if the access token is set. |
||
237 | * |
||
238 | * @throws PocketException |
||
239 | */ |
||
240 | protected function checkAccessToken() |
||
246 | } |
||
247 |