-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathCustomGallery.php
115 lines (105 loc) · 3.4 KB
/
CustomGallery.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
<?php
namespace Imgur\Api;
/**
* CRUD for CustomGallery.
*
* @see https://api.imgur.com/endpoints/custom_gallery
*/
class CustomGallery extends AbstractApi
{
/**
* View images for current user's custom gallery.
*
* @param string $sort (viral | top | time)
* @param int $page
* @param string $window (day | week | month | year | all)
*
* @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery
*
* @return array Custom Gallery (@see https://api.imgur.com/models/custom_gallery)
*/
public function customGallery($sort = 'viral', $page = 0, $window = 'week')
{
$this->validateSortArgument($sort, ['viral', 'top', 'time']);
$this->validateWindowArgument($window, ['day', 'week', 'month', 'year', 'all']);
return $this->get('g/custom/' . $sort . '/' . $window . '/' . (int) $page);
}
/**
* Retrieve user's filtered out gallery.
*
* @param string $sort (viral | top | time)
* @param int $page
* @param string $window (day | week | month | year | all)
*
* @see https://api.imgur.com/endpoints/custom_gallery#filtered-out-gallery
*
* @return array Custom Gallery (@see https://api.imgur.com/models/custom_gallery)
*/
public function filtered($sort = 'viral', $page = 0, $window = 'week')
{
$this->validateSortArgument($sort, ['viral', 'top', 'time']);
$this->validateWindowArgument($window, ['day', 'week', 'month', 'year', 'all']);
return $this->get('g/filtered/' . $sort . '/' . $window . '/' . (int) $page);
}
/**
* View a single image in a user's custom gallery.
*
* @param string $imageId The ID for the gallery item
*
* @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-image
*
* @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 image($imageId)
{
return $this->get('g/custom/' . $imageId);
}
/**
* Add tags to a user's custom gallery.
*
* @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-add
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function addTags(array $tags)
{
return $this->put('g/add_tags', ['tags' => implode(',', $tags)]);
}
/**
* Remove tags from a custom gallery.
*
* @see https://api.imgur.com/endpoints/custom_gallery#custom-gallery-remove
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function removeTags(array $tags)
{
return $this->delete('g/remove_tags', ['tags' => implode(',', $tags)]);
}
/**
* Filter out a tag.
*
* @param string $tag
*
* @see https://api.imgur.com/endpoints/custom_gallery#filtered-out-block
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function blockTag($tag)
{
return $this->post('g/block_tag', ['tag' => $tag]);
}
/**
* Remove a filtered out tag.
*
* @param string $tag
*
* @see https://api.imgur.com/endpoints/custom_gallery#filtered-out-unblock
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function unBlockTag($tag)
{
return $this->post('g/unblock_tag', ['tag' => $tag]);
}
}