-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathComment.php
125 lines (113 loc) · 3.21 KB
/
Comment.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
<?php
namespace Imgur\Api;
use Imgur\Exception\MissingArgumentException;
/**
* CRUD for Comment.
*
* @see https://api.imgur.com/endpoints/comment
*
* @author Adrian Ghiuta <[email protected]>
*/
class Comment extends AbstractApi
{
/**
* Get information about a specific comment.
*
* @param string $commentId
*
* @see https://api.imgur.com/endpoints/comment#comment
*
* @return array Comment (@see https://api.imgur.com/endpoints/gallery#gallery-comments)
*/
public function comment($commentId)
{
return $this->get('comment/' . $commentId);
}
/**
* Creates a new comment, returns the ID of the comment.
*
* @param array $data
*
* @see https://api.imgur.com/endpoints/comment#comment-create
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function create($data)
{
if (!isset($data['image_id'], $data['comment'])) {
throw new MissingArgumentException(['image_id', 'comment']);
}
return $this->post('comment', $data);
}
/**
* Delete a comment by the given id.
*
* @param string $commentId
*
* @see https://api.imgur.com/endpoints/comment#comment-delete
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function deleteComment($commentId)
{
return $this->delete('comment/' . $commentId);
}
/**
* Get the comment with all of the replies for the comment.
*
* @param string $commentId
*
* @see https://api.imgur.com/endpoints/comment#comment-replies
*
* @return array Comment (@see https://api.imgur.com/endpoints/gallery#gallery-comments)
*/
public function replies($commentId)
{
return $this->get('comment/' . $commentId . '/replied');
}
/**
* Create a reply for the given comment.
*
* @param string $commentId
* @param array $data
*
* @see https://api.imgur.com/endpoints/comment#comment-reply-create
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function createReply($commentId, $data)
{
if (!isset($data['image_id'], $data['comment'])) {
throw new MissingArgumentException(['image_id', 'comment']);
}
return $this->post('comment/' . $commentId, $data);
}
/**
* Vote on a comment. The $vote variable can only be set as "up" or "down".
*
* @param string $commentId
* @param string $vote
*
* @see https://api.imgur.com/endpoints/comment#comment-vote
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function vote($commentId, $vote)
{
$this->validateVoteArgument($vote, ['up', 'down']);
return $this->post('comment/' . $commentId . '/vote/' . $vote);
}
/**
* Report a comment for being inappropriate.
*
* @param string $commentId
*
* @see https://api.imgur.com/endpoints/comment#comment-report
*
* @return array (@see https://api.imgur.com/models/basic)
*/
public function report($commentId)
{
return $this->post('comment/' . $commentId . '/report');
}
}