IssueApi.js
7.47 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/**
* Copyright 2010 Ajax.org B.V.
*
* This product includes software developed by
* Ajax.org B.V. (http://www.ajax.org/).
*
* Author: Fabian Jaokbs <fabian@ajax.org>
*/
var sys = require("sys");
var AbstractApi = require("./AbstractApi").AbstractApi;
var IssueApi = exports.IssueApi = function(api) {
this.$api = api;
};
sys.inherits(IssueApi, AbstractApi);
(function() {
/**
* List issues by username, repo and state
* http://develop.github.com/p/issues.html#list_a_projects_issues
*
* @param {String} username the username
* @param {String} repo the repo
* @param {String} $state the issue state, can be open or closed
*/
this.getList = function(username, repo, state, callback)
{
var state = state || "open";
this.$api.get(
'issues/list/' + encodeURI(username) + "/" + encodeURI(repo) + "/" + encodeURI(state),
null, null,
this.$createListener(callback, "issues")
);
};
}).call(IssueApi.prototype);
//
///**
// * Search issues by username, repo, state and search term
// * http://develop.github.com/p/issues.html#list_a_projects_issues
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} $state the issue state, can be open or closed
// * @param {String} $searchTerm the search term to filter issues by
// */
//this.search = function(username, repo, $state, $searchTerm)
//{
// $response = $this->api->get('issues/search/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode($state).'/'.urlencode($searchTerm));
//
// return $response['issues'];
//}
//
///**
// * Get extended information about an issue by its username, repo and number
// * http://develop.github.com/p/issues.html#view_an_issue
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} issueNumber the issue number
// */
//this.show = function(username, repo, issueNumber)
//{
// $response = $this->api->get('issues/show/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode(issueNumber));
//
// return $response['issue'];
//}
//
///**
// * Create a new issue for the given username and repo.
// * The issue is assigned to the authenticated user. Requires authentication.
// * http://develop.github.com/p/issues.html#open_and_close_issues
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} $issueTitle the new issue title
// * @param {String} $issueBody the new issue body
// */
//this.open = function(username, repo, $issueTitle, $issueBody)
//{
// $response = $this->api->post('issues/open/'.urlencode(username).'/'.urlencode(repo), array(
// 'title' => $issueTitle,
// 'body' => $issueBody
// ));
//
// return $response['issue'];
//}
//
///**
// * Close an existing issue by username, repo and issue number. Requires authentication.
// * http://develop.github.com/p/issues.html#open_and_close_issues
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} issueNumber the issue number
// */
//this.close = function(username, repo, issueNumber)
//{
// $response = $this->api->post('issues/close/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode(issueNumber));
//
// return $response['issue'];
//}
//
///**
// * Update issue informations by username, repo and issue number. Requires authentication.
// * http://develop.github.com/p/issues.html#edit_existing_issues
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} issueNumber the issue number
// * @param array $data key=>value user attributes to update.
// * key can be title or body
// */
//this.update = function(username, repo, issueNumber, array $data)
//{
// $response = $this->api->post('issues/edit/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode(issueNumber), $data);
//
// return $response['issue'];
//}
//
///**
// * Repoen an existing issue by username, repo and issue number. Requires authentication.
// * http://develop.github.com/p/issues.html#open_and_close_issues
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} issueNumber the issue number
// */
//this.reOpen = function(username, repo, issueNumber)
//{
// $response = $this->api->post('issues/reopen/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode(issueNumber));
//
// return $response['issue'];
//}
//
///**
// * List an issue comments by username, repo and issue number
// * http://develop.github.com/p/issues.html#list_an_issues_comments
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} issueNumber the issue number
// */
//this.getComments = function(username, repo, issueNumber)
//{
// $response = $this->api->get('issues/comments/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode(issueNumber));
//
// return $response['comments'];
//}
//
///**
// * Add a comment to the issue by username, repo and issue number
// * http://develop.github.com/p/issues.html#comment_on_issues
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} issueNumber the issue number
// * @param {String} $comment the comment body
// */
//this.addComment = function(username, repo, issueNumber, $commentBody)
//{
// $response = $this->api->post('issues/comment/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode(issueNumber), array(
// 'comment' => $commentBody
// ));
//
// return $response['comment'];
//}
//
///**
// * List all project labels by username and repo
// * http://develop.github.com/p/issues.html#listing_labels
// *
// * @param {String} username the username
// * @param {String} repo the repo
// */
//this.getLabels = function(username, repo)
//{
// $response = $this->api->get('issues/labels/'.urlencode(username).'/'.urlencode(repo));
//
// return $response['labels'];
//}
//
///**
// * Add a label to the issue by username, repo and issue number. Requires authentication.
// * http://develop.github.com/p/issues.html#add_and_remove_labels
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} issueNumber the issue number
// * @param {String} labelName the label name
// */
//this.addLabel = function(username, repo, labelName, issueNumber)
//{
// $response = $this->api->post('issues/label/add/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode(labelName).'/'.urlencode(issueNumber));
//
// return $response['labels'];
//}
//
///**
// * Remove a label from the issue by username, repo, issue number and label name. Requires authentication.
// * http://develop.github.com/p/issues.html#add_and_remove_labels
// *
// * @param {String} username the username
// * @param {String} repo the repo
// * @param {String} issueNumber the issue number
// * @param {String} labelName the label name
// */
//this.removeLabel = function(username, repo, labelName, issueNumber)
//{
// $response = $this->api->post('issues/label/remove/'.urlencode(username).'/'.urlencode(repo).'/'.urlencode(labelName).'/'.urlencode(issueNumber));
//
// return $response['labels'];
//}