-
Notifications
You must be signed in to change notification settings - Fork 3
/
GithubGists.php
135 lines (119 loc) · 2.57 KB
/
GithubGists.php
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
<?php
require_once('Github.php');
class GithubGists extends Github {
/**
* List a user’s gists:
*
* @param string $username
*/
public function listUser($username) {
return $this->request('/users/'.$username.'/gists');
}
/**
* List the authenticated user’s gists or if called anonymously, this will return all public gists
*/
public function listOwn() {
return $this->request('/gists');
}
/**
* List all public gists
*/
public function listPublic() {
return $this->request('/gists/public');
}
/**
* List the authenticated user’s starred gists
*/
public function listStarred() {
return $this->request('/gists/starred');
}
/**
* Get a single gist
*
* @param string $id
*/
public function get($id) {
return $this->request('/gists/'.$id);
}
/**
* Create a gist
*
* @param boolean $public
* @param array $files
* "file1.txt": {
* "content": "String file contents"
* }
* @param string $description
*/
public function create($public, $files, $description = false) {
return $this->request('/gists', 'POST', array(
'public' => $public,
'files' => $files,
'description' => $description,
));
}
/**
* Edit a gist
*
* @param string $id
* @param array $files
* "file1.txt": {
* "content": "updated file contents"
* },
* "old_name.txt": {
* "filename": "new_name.txt",
* "content": "modified contents"
* },
* "new_file.txt": {
* "content": "a new file"
* },
* "delete_this_file.txt": null
* @param string $description
*/
public function edit($id, $files, $description = false) {
return $this->request('/gists/'.$id, 'PATCH', array(
'files' => $files,
'description' => $description,
));
}
/**
* Star a gist
*
* @param string $id
*/
public function star($id) {
$result = $this->request('/gists/'.$id.'/star', 'PUT');
return (is_null($result)) ? true : false;
}
/**
* Unstar a gist
*
* @param string $id
*/
public function unstar($id) {
$result = $this->request('/gists/'.$id.'/star', 'DELETE');
return (is_null($result)) ? true : false;
}
/**
* Check if a gist is starred
*
* @param string $id
*/
public function checkStar($id) {
$result = $this->request('/gists/'.$id.'/star');
return (is_null($result)) ? true : false;
}
/**public function fork($id) {
return $this->request('/gists/'.$id.'/fork', 'POST');
}*/
/**
* Delete a gist
*
* @param string $id
*/
public function delete($id) {
$result = $this->request('/gists/'.$id, 'DELETE');
return (is_null($result)) ? true : false;
}
}
?>