-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathAccount.php
419 lines (387 loc) · 12.8 KB
/
Account.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
<?php
namespace Imgur\Api;
/**
* CRUD for Accounts.
*
* @see https://api.imgur.com/endpoints/account
*
* @author Adrian Ghiuta <adrian.ghiuta@gmail.com>
*/
class Account extends AbstractApi
{
/**
* Request standard user information.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#account
*
* @return array Account (@see https://api.imgur.com/models/account)
*/
public function base($username = 'me')
{
return $this->get('account/' . $username);
}
/**
* UNDOCUMENTED
* Delete a user account, you can only access this if you're logged in as the user.
*
* @param string $username
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function deleteAccount($username)
{
return $this->delete('account/' . $username);
}
/**
* Return the images the user has favorited in the gallery.
*
* @param string $username
* @param int $page
* @param string $sort 'oldest', or 'newest'. Defaults to 'newest'
*
* @see https://api.imgur.com/endpoints/account#account-gallery-favorites
*
* @return array Gallery Image (@see https://api.imgur.com/models/gallery_image) OR Gallery Album (@see https://api.imgur.com/models/gallery_album)
*/
public function galleryFavorites($username = 'me', $page = 0, $sort = 'newest')
{
$this->validateSortArgument($sort, ['oldest', 'newest']);
return $this->get('account/' . $username . '/gallery_favorites/' . (int) $page . '/' . $sort);
}
/**
* Returns the users favorited images, only accessible if you're logged in as the user.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#account-favorites
*
* @return array Gallery Image (@see https://api.imgur.com/models/gallery_image) OR Gallery Album (@see https://api.imgur.com/models/gallery_album)
*/
public function favorites($username = 'me')
{
return $this->get('account/' . $username . '/favorites');
}
/**
* Return the images a user has submitted to the gallery.
*
* @param string $username
* @param int $page
*
* @see https://api.imgur.com/endpoints/account#account-submissions
*
* @return array Gallery Image (@see https://api.imgur.com/models/gallery_image) OR Gallery Album (@see https://api.imgur.com/models/gallery_album)
*/
public function submissions($username = 'me', $page = 0)
{
return $this->get('account/' . $username . '/submissions/' . (int) $page);
}
/**
* Returns the account settings, only accessible if you're logged in as the user.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#account-settings
*
* @return array Account Settings (@see https://api.imgur.com/models/account_settings)
*/
public function settings($username = 'me')
{
return $this->get('account/' . $username . '/settings');
}
/**
* Updates the account settings for a given user, the user must be logged in.
*
* @param array $parameters
*
* @see https://api.imgur.com/endpoints/account#update-settings
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function changeAccountSettings($parameters)
{
return $this->post('account/me/settings', $parameters);
}
/**
* UNDOCUMENTED
* Return the statistics about the account.
*
* @param string $username
*
* @return array
*/
public function accountStats($username = 'me')
{
return $this->get('account/' . $username . '/stats');
}
/**
* Returns the totals for the gallery profile.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#account-profile
*
* @return array Gallery Profile (@see https://api.imgur.com/models/gallery_profile)
*/
public function accountGalleryProfile($username = 'me')
{
return $this->get('account/' . $username . '/gallery_profile');
}
/**
* Checks to see if user has verified their email address.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#verify-email
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function verifyUsersEmail($username = 'me')
{
return $this->get('account/' . $username . '/verifyemail');
}
/**
* Sends an email to the user to verify that their email is valid to upload to gallery. Must be logged in as the user to send.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#send-verify-email
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function sendVerificationEmail($username = 'me')
{
return $this->post('account/' . $username . '/verifyemail');
}
/**
* Get all the albums associated with the account. Must be logged in as the user to see secret and hidden albums.
*
* @param string $username
* @param int $page
*
* @see https://api.imgur.com/endpoints/account#albums
*
* @return array Array of Album (@see https://api.imgur.com/models/album)
*/
public function albums($username = 'me', $page = 0)
{
return $this->get('account/' . $username . '/albums/' . (int) $page);
}
/**
* Get additional information about an album, this endpoint works the same as the Album Endpoint.
* You can also use any of the additional routes that are used on an album in the album endpoint.
*
* @param string $username
* @param string $albumId
*
* @see https://api.imgur.com/endpoints/account#album
*
* @return array Album (@see https://api.imgur.com/models/album)
*/
public function album($albumId, $username = 'me')
{
return $this->get('account/' . $username . '/album/' . $albumId);
}
/**
* Return an array of all of the album IDs.
*
* @param string $username
* @param int $page
*
* @see https://api.imgur.com/endpoints/account#album-ids
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function albumIds($username = 'me', $page = 0)
{
return $this->get('account/' . $username . '/albums/ids/' . (int) $page);
}
/**
* Return the total number of albums associated with the account.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#album-count
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function albumCount($username = 'me')
{
return $this->get('account/' . $username . '/albums/count');
}
/**
* Delete an Album with a given id.
*
* @param string $username
* @param string $albumId
*
* @see https://api.imgur.com/endpoints/account#album-delete
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function albumDelete($albumId, $username = 'me')
{
return $this->delete('account/' . $username . '/album/' . $albumId);
}
/**
* Return the comments the user has created.
*
* @param string $username
* @param int $page
* @param string $sort 'best', 'worst', 'oldest', or 'newest'. Defaults to 'newest'
*
* @see https://api.imgur.com/endpoints/account#comments
*
* @return array Array of Comment (@see https://api.imgur.com/models/comment)
*/
public function comments($username = 'me', $page = 0, $sort = 'newest')
{
$this->validateSortArgument($sort, ['best', 'worst', 'oldest', 'newest']);
return $this->get('account/' . $username . '/comments/' . $sort . '/' . (int) $page);
}
/**
* Return information about a specific comment. This endpoint works the same as the Comment Endpoint.
* You can use any of the additional actions that the comment endpoint allows on this end point.
*
* @param string $commentId
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#comment
*
* @return array Comment (@see https://api.imgur.com/models/comment)
*/
public function comment($commentId, $username = 'me')
{
return $this->get('account/' . $username . '/comment/' . $commentId);
}
/**
* Return an array of all of the comment IDs.
*
* @param string $username
* @param int $page
* @param string $sort 'best', 'worst', 'oldest', or 'newest'. Defaults to 'newest'
*
* @see https://api.imgur.com/endpoints/account#comment-ids
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function commentIds($username = 'me', $page = 0, $sort = 'newest')
{
$this->validateSortArgument($sort, ['best', 'worst', 'oldest', 'newest']);
return $this->get('account/' . $username . '/comments/ids/' . $sort . '/' . (int) $page);
}
/**
* Return a count of all of the comments associated with the account.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#comment-count
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function commentCount($username = 'me')
{
return $this->get('account/' . $username . '/comments/count');
}
/**
* Delete a comment. You are required to be logged in as the user whom created the comment.
*
* @param string $commentId
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#comment-delete
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function commentDelete($commentId, $username = 'me')
{
return $this->delete('account/' . $username . '/comment/' . $commentId);
}
/**
* Return all of the images associated with the account.
* You can page through the images by setting the page, this defaults to 0.
*
* @param string $username
* @param int $page
*
* @see https://api.imgur.com/endpoints/account#images
*
* @return array Array of Image (@see https://api.imgur.com/models/image)
*/
public function images($username = 'me', $page = 0)
{
return $this->get('account/' . $username . '/images/' . (int) $page);
}
/**
* Return information about a specific image.
* This endpoint works the same as the Image Endpoint. You can use any of the additional actions that the image endpoint with this endpoint.
*
* @param string $imageId
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#image
*
* @return array Image (@see https://api.imgur.com/models/image)
*/
public function image($imageId, $username = 'me')
{
return $this->get('account/' . $username . '/image/' . $imageId);
}
/**
* Returns an array of Image IDs that are associated with the account.
*
* @param string $username
* @param int $page
*
* @see https://api.imgur.com/endpoints/account#image-ids
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function imageIds($username = 'me', $page = 0)
{
return $this->get('account/' . $username . '/images/ids/' . (int) $page);
}
/**
* Returns the total number of images associated with the account.
*
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#image-count
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function imageCount($username = 'me')
{
return $this->get('account/' . $username . '/images/count');
}
/**
* Deletes an Image. This requires a delete hash rather than an ID.
*
* @param string $deleteHash
* @param string $username
*
* @see https://api.imgur.com/endpoints/account#image-delete
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function imageDelete($deleteHash, $username = 'me')
{
return $this->delete('account/' . $username . '/image/' . $deleteHash);
}
/**
* Returns all of the reply notifications for the user. Required to be logged in as that user.
*
* @param string $username
* @param bool $onlyNew
*
* @see https://api.imgur.com/endpoints/account#replies
*
* @return array Array of Notification (@see https://api.imgur.com/models/notification)
*/
public function replies($username = 'me', $onlyNew = false)
{
$onlyNew = $onlyNew ? 'true' : 'false';
return $this->get('account/' . $username . '/notifications/replies', ['new' => $onlyNew]);
}
}