Repository navigation
Expand file tree
/
Copy pathComments.php
More file actions
75 lines (61 loc) · 2.27 KB
/
Copy pathComments.php
File metadata and controls
75 lines (61 loc) · 2.27 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
<?php
namespace Github\Api\Repository;
use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;
use Github\Exception\MissingArgumentException;
/**
* @link http://developer.github.com/v3/repos/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/repos/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.%s+json', $this->getApiVersion(), $bodyType);
return $this;
}
public function all($username, $repository, $sha = null)
{
if (null === $sha) {
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/comments');
}
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($sha).'/comments');
}
public function show($username, $repository, $comment)
{
return $this->get('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/comments/'.rawurlencode($comment));
}
public function create($username, $repository, $sha, array $params)
{
if (!isset($params['body'])) {
throw new MissingArgumentException('body');
}
return $this->post('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/commits/'.rawurlencode($sha).'/comments', $params);
}
public function update($username, $repository, $comment, array $params)
{
if (!isset($params['body'])) {
throw new MissingArgumentException('body');
}
return $this->patch('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/comments/'.rawurlencode($comment), $params);
}
public function remove($username, $repository, $comment)
{
return $this->delete('/repos/'.rawurlencode($username).'/'.rawurlencode($repository).'/comments/'.rawurlencode($comment));
}
}