Repository navigation
Expand file tree
/
Copy pathComments.php
More file actions
76 lines (60 loc) · 2.52 KB
/
Copy pathComments.php
File metadata and controls
76 lines (60 loc) · 2.52 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
<?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;
public function configure($bodyType = null)
{
switch ($bodyType) {
case 'raw':
$header = sprintf('Accept: application/vnd.github.%s.raw+json', $this->client->getApiVersion());
break;
case 'text':
$header = sprintf('Accept: application/vnd.github.%s.text+json', $this->client->getApiVersion());
break;
case 'html':
$header = sprintf('Accept: application/vnd.github.%s.html+json', $this->client->getApiVersion());
break;
default:
$header = sprintf('Accept: application/vnd.github.%s.full+json', $this->client->getApiVersion());
}
$this->acceptHeaderValue = $header;
}
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));
}
}