-
-
Notifications
You must be signed in to change notification settings - Fork 592
Expand file tree
/
Copy pathComments.php
More file actions
101 lines (90 loc) · 2.13 KB
/
Comments.php
File metadata and controls
101 lines (90 loc) · 2.13 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
<?php
namespace Github\Api\Gist;
use Github\Api\AbstractApi;
use Github\Api\AcceptHeaderTrait;
/**
* @link https://developer.github.com/v3/gists/comments/
*
* @author Kayla Daniels <kayladnls@gmail.com>
*/
class Comments extends AbstractApi
{
use AcceptHeaderTrait;
/**
* Configure the body type.
*
* @link https://developer.github.com/v3/gists/comments/#custom-media-types
*
* @param string|null $bodyType
*
* @return $this
*/
public function configure($bodyType = null)
{
if (!in_array($bodyType, ['text', 'html', 'full'])) {
$bodyType = 'raw';
}
$this->acceptHeaderValue = sprintf('application/vnd.github.%s+json', $bodyType);
return $this;
}
/**
* Get all comments for a gist.
*
* @param string $gist
*
* @return array
*/
public function all($gist)
{
return $this->get('/gists/'.rawurlencode($gist).'/comments');
}
/**
* Get a comment of a gist.
*
* @param string $gist
* @param int $comment
*
* @return array
*/
public function show($gist, $comment)
{
return $this->get('/gists/'.rawurlencode($gist).'/comments/'.$comment);
}
/**
* Create a comment for gist.
*
* @param string $gist
* @param string $body
*
* @return array
*/
public function create($gist, $body)
{
return $this->post('/gists/'.rawurlencode($gist).'/comments', ['body' => $body]);
}
/**
* Create a comment for a gist.
*
* @param string $gist
* @param int $comment_id
* @param string $body
*
* @return array
*/
public function update($gist, $comment_id, $body)
{
return $this->patch('/gists/'.rawurlencode($gist).'/comments/'.$comment_id, ['body' => $body]);
}
/**
* Delete a comment for a gist.
*
* @param string $gist
* @param int $comment
*
* @return array
*/
public function remove($gist, $comment)
{
return $this->delete('/gists/'.rawurlencode($gist).'/comments/'.$comment);
}
}