Repository navigation
Expand file tree
/
Copy pathGists.php
More file actions
116 lines (95 loc) · 2.58 KB
/
Copy pathGists.php
File metadata and controls
116 lines (95 loc) · 2.58 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
<?php
namespace Github\Api;
use Github\Api\Gist\Comments;
use Github\Exception\MissingArgumentException;
/**
* Creating, editing, deleting and listing gists.
*
* @link http://developer.github.com/v3/gists/
*
* @author Joseph Bielawski <stloyd@gmail.com>
* @author Edoardo Rivello <edoardo.rivello at gmail dot com>
*/
class Gists extends AbstractApi
{
use AcceptHeaderTrait;
/**
* Configure the body type.
*
* @link https://developer.github.com/v3/gists/#custom-media-types
*
* @param string|null $bodyType
*
* @return self
*/
public function configure($bodyType = null)
{
if ('base64' !== $bodyType) {
$bodyType = 'raw';
}
$this->acceptHeaderValue = sprintf('application/vnd.github.%s.%s', $this->client->getApiVersion(), $bodyType);
return $this;
}
public function all($type = null)
{
if (!in_array($type, ['public', 'starred'])) {
return $this->get('/gists');
}
return $this->get('/gists/'.rawurlencode($type));
}
public function show($number)
{
return $this->get('/gists/'.rawurlencode($number));
}
public function create(array $params)
{
if (!isset($params['files']) || (!is_array($params['files']) || 0 === count($params['files']))) {
throw new MissingArgumentException('files');
}
$params['public'] = (bool) $params['public'];
return $this->post('/gists', $params);
}
public function update($id, array $params)
{
return $this->patch('/gists/'.rawurlencode($id), $params);
}
public function commits($id)
{
return $this->get('/gists/'.rawurlencode($id).'/commits');
}
public function fork($id)
{
return $this->post('/gists/'.rawurlencode($id).'/fork');
}
public function forks($id)
{
return $this->get('/gists/'.rawurlencode($id).'/forks');
}
public function remove($id)
{
return $this->delete('/gists/'.rawurlencode($id));
}
public function check($id)
{
return $this->get('/gists/'.rawurlencode($id).'/star');
}
public function star($id)
{
return $this->put('/gists/'.rawurlencode($id).'/star');
}
public function unstar($id)
{
return $this->delete('/gists/'.rawurlencode($id).'/star');
}
/**
* Get a gist's comments.
*
* @link http://developer.github.com/v3/gists/comments/
*
* @return Comments
*/
public function comments()
{
return new Comments($this->client);
}
}