Repository navigation
Expand file tree
/
Copy pathGists.php
More file actions
71 lines (57 loc) · 1.64 KB
/
Copy pathGists.php
File metadata and controls
71 lines (57 loc) · 1.64 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
<?php
namespace Github\Api;
use Github\Api\AbstractApi;
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
{
public function all($type = null)
{
if (!in_array($type, array('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'] = (boolean) $params['public'];
return $this->post('gists', $params);
}
public function update($id, array $params)
{
return $this->patch('gists/'.rawurlencode($id), $params);
}
public function fork($id)
{
return $this->post('gists/'.rawurlencode($id).'/fork');
}
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');
}
}