-
-
Notifications
You must be signed in to change notification settings - Fork 592
Expand file tree
/
Copy pathComments.php
More file actions
133 lines (120 loc) · 3.61 KB
/
Comments.php
File metadata and controls
133 lines (120 loc) · 3.61 KB
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
<?php
namespace Github\Api\Issue;
use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;
use Github\Exception\MissingArgumentException;
/**
* @link http://developer.github.com/v3/issues/comments/
*
* @author Joseph Bielawski <stloyd@gmail.com>
* @author Tobias Nyholm <tobias.nyholm@gmail.com>
*/
class Comments extends AbstractApi
{
use AcceptHeaderTrait;
/**
* Configure the body type.
*
* @link https://developer.github.com/v3/issues/comments/#custom-media-types
*
* @param string|null $bodyType
*
* @return $this
*/
public function configure($bodyType = null)
{
if (!in_array($bodyType, ['raw', 'text', 'html'])) {
$bodyType = 'full';
}
$this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType);
return $this;
}
/**
* Get all comments for an issue.
*
* @link https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
*
* @param string $username
* @param string $repository
* @param int $issue
* @param array $params
*
* @return array
*/
public function all($username, $repository, $issue, array $params = [])
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/comments', $params);
}
/**
* Get a comment for an issue.
*
* @link https://developer.github.com/v3/issues/comments/#get-a-single-comment
*
* @param string $username
* @param string $repository
* @param int $comment
*
* @return array
*/
public function show($username, $repository, $comment)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment);
}
/**
* Create a comment for an issue.
*
* @link https://developer.github.com/v3/issues/comments/#create-a-comment
*
* @param string $username
* @param string $repository
* @param int $issue
* @param array $params
*
* @throws \Github\Exception\MissingArgumentException
*
* @return array
*/
public function create($username, $repository, $issue, array $params)
{
if (!isset($params['body'])) {
throw new MissingArgumentException('body');
}
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/'.$issue.'/comments', $params);
}
/**
* Update a comment for an issue.
*
* @link https://developer.github.com/v3/issues/comments/#edit-a-comment
*
* @param string $username
* @param string $repository
* @param int $comment
* @param array $params
*
* @throws \Github\Exception\MissingArgumentException
*
* @return array
*/
public function update($username, $repository, $comment, array $params)
{
if (!isset($params['body'])) {
throw new MissingArgumentException('body');
}
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment, $params);
}
/**
* Delete a comment for an issue.
*
* @link https://developer.github.com/v3/issues/comments/#delete-a-comment
*
* @param string $username
* @param string $repository
* @param int $comment
*
* @return array
*/
public function remove($username, $repository, $comment)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/issues/comments/'.$comment);
}
}