@@ -13,7 +13,7 @@ class Issue extends Api
13
13
{
14
14
/**
15
15
* List issues by username, repo and state
16
- * http://develop .i.8713187.xyz/p /issues.html#list_a_projects_issues
16
+ * @link http://developer .i.8713187.xyz/v3 /issues/
17
17
*
18
18
* @param string $username the username
19
19
* @param string $repo the repo
@@ -22,9 +22,7 @@ class Issue extends Api
22
22
*/
23
23
public function getList ($ username , $ repo , $ state = 'open ' )
24
24
{
25
- $ response = $ this ->get ('issues/list/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ state ));
26
-
27
- return $ response ['issues ' ];
25
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/issues?state= ' .urlencode ($ state ));
28
26
}
29
27
30
28
/**
@@ -39,9 +37,7 @@ public function getList($username, $repo, $state = 'open')
39
37
*/
40
38
public function search ($ username , $ repo , $ state , $ searchTerm )
41
39
{
42
- $ response = $ this ->get ('issues/search/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ state ).'/ ' .urlencode ($ searchTerm ));
43
-
44
- return $ response ['issues ' ];
40
+ throw new \BadMethodCallException ('Method cannot be implemented using new api version ' );
45
41
}
46
42
47
43
/**
@@ -54,46 +50,40 @@ public function search($username, $repo, $state, $searchTerm)
54
50
*/
55
51
public function searchLabel ($ username , $ repo , $ label )
56
52
{
57
- $ response = $ this ->get ('issues/list/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/label/ ' .urlencode ($ label ));
58
-
59
- return $ response ['issues ' ];
53
+ throw new \BadMethodCallException ('Method cannot be implemented using new api version ' );
60
54
}
61
55
62
56
/**
63
57
* Get extended information about an issue by its username, repo and number
64
- * http://develop .i.8713187.xyz/p /issues.html#view_an_issue
58
+ * @link http://developer .i.8713187.xyz/v3 /issues/
65
59
*
66
60
* @param string $username the username
67
61
* @param string $repo the repo
68
- * @param string $issueNumber the issue number
62
+ * @param string $number the issue number
69
63
* @return array information about the issue
70
64
*/
71
- public function show ($ username , $ repo , $ issueNumber )
65
+ public function show ($ username , $ repo , $ number )
72
66
{
73
- $ response = $ this ->get ('issues/show/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ issueNumber ));
74
-
75
- return $ response ['issue ' ];
67
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/issues/ ' .urlencode ($ number ));
76
68
}
77
69
78
70
/**
79
71
* Create a new issue for the given username and repo.
80
72
* The issue is assigned to the authenticated user. Requires authentication.
81
- * http://develop .i.8713187.xyz/p /issues.html#open_and_close_issues
73
+ * @link http://developer .i.8713187.xyz/v3 /issues/
82
74
*
83
75
* @param string $username the username
84
76
* @param string $repo the repo
85
- * @param string $issueTitle the new issue title
86
- * @param string $issueBody the new issue body
77
+ * @param string $title the new issue title
78
+ * @param string $body the new issue body
87
79
* @return array information about the issue
88
80
*/
89
- public function open ($ username , $ repo , $ issueTitle , $ issueBody )
81
+ public function open ($ username , $ repo , $ title , $ body )
90
82
{
91
- $ response = $ this ->post ('issues/open/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ), array (
92
- 'title ' => $ issueTitle ,
93
- 'body ' => $ issueBody
83
+ return $ this ->post ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ). ' /issues ' , array (
84
+ 'title ' => $ title ,
85
+ 'body ' => $ body
94
86
));
95
-
96
- return $ response ['issue ' ];
97
87
}
98
88
99
89
/**
@@ -102,14 +92,12 @@ public function open($username, $repo, $issueTitle, $issueBody)
102
92
*
103
93
* @param string $username the username
104
94
* @param string $repo the repo
105
- * @param string $issueNumber the issue number
95
+ * @param string $number the issue number
106
96
* @return array information about the issue
107
97
*/
108
- public function close ($ username , $ repo , $ issueNumber )
98
+ public function close ($ username , $ repo , $ number )
109
99
{
110
- $ response = $ this ->post ('issues/close/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ issueNumber ));
111
-
112
- return $ response ['issue ' ];
100
+ return $ this ->update ($ username , $ repo , $ number , array ('state ' => 'closed ' ));
113
101
}
114
102
115
103
/**
@@ -118,16 +106,14 @@ public function close($username, $repo, $issueNumber)
118
106
*
119
107
* @param string $username the username
120
108
* @param string $repo the repo
121
- * @param string $issueNumber the issue number
109
+ * @param string $number the issue number
122
110
* @param array $data key=>value user attributes to update.
123
111
* key can be title or body
124
112
* @return array information about the issue
125
113
*/
126
- public function update ($ username , $ repo , $ issueNumber , array $ data )
114
+ public function update ($ username , $ repo , $ number , array $ data )
127
115
{
128
- $ response = $ this ->post ('issues/edit/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ issueNumber ), $ data );
129
-
130
- return $ response ['issue ' ];
116
+ return $ this ->post ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/issues/ ' .urlencode ($ number ), $ data );
131
117
}
132
118
133
119
/**
@@ -136,14 +122,12 @@ public function update($username, $repo, $issueNumber, array $data)
136
122
*
137
123
* @param string $username the username
138
124
* @param string $repo the repo
139
- * @param string $issueNumber the issue number
125
+ * @param string $number the issue number
140
126
* @return array informations about the issue
141
127
*/
142
- public function reOpen ($ username , $ repo , $ issueNumber )
128
+ public function reOpen ($ username , $ repo , $ number )
143
129
{
144
- $ response = $ this ->post ('issues/reopen/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ issueNumber ));
145
-
146
- return $ response ['issue ' ];
130
+ return $ this ->update ($ username , $ repo , $ number , array ('state ' => 'open ' ));
147
131
}
148
132
149
133
/**
@@ -152,81 +136,102 @@ public function reOpen($username, $repo, $issueNumber)
152
136
*
153
137
* @param string $username the username
154
138
* @param string $repo the repo
155
- * @param string $issueNumber the issue number
139
+ * @param string $number the issue number
156
140
* @return array list of issue comments
157
141
*/
158
- public function getComments ($ username , $ repo , $ issueNumber )
142
+ public function getComments ($ username , $ repo , $ number )
159
143
{
160
- $ response = $ this ->get ('issues/comments/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ issueNumber ));
144
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/issues/ ' .urlencode ($ number ).'/comments ' );
145
+ }
161
146
162
- return $ response ['comments ' ];
147
+ /**
148
+ * Get an issue comments by username, repo, issue number and comment id
149
+ * @link http://developer.github.com/v3/issues/comments/
150
+ *
151
+ * @param string $username the username
152
+ * @param string $repo the repo
153
+ * @param string $number the issue number
154
+ * @param string $id the comment id
155
+ * @return array list of issue comments
156
+ */
157
+ public function getComment ($ username , $ repo , $ number , $ id )
158
+ {
159
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/issues/ ' .urlencode ($ number ).'/comments/ ' .urlencode ($ id ));
163
160
}
164
161
165
162
/**
166
163
* Add a comment to the issue by username, repo and issue number
167
- * http://develop .i.8713187.xyz/p /issues.html#comment_on_issues
164
+ * @link http://developer .i.8713187.xyz/v3 /issues/comments/
168
165
*
169
166
* @param string $username the username
170
167
* @param string $repo the repo
171
- * @param string $issueNumber the issue number
172
- * @param string $comment the comment body
168
+ * @param string $number the issue number
169
+ * @param string $body the comment body
173
170
* @return array the created comment
174
171
*/
175
- public function addComment ($ username , $ repo , $ issueNumber , $ commentBody )
172
+ public function addComment ($ username , $ repo , $ number , $ body )
176
173
{
177
- $ response = $ this ->post ('issues/comment/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ issueNumber ) , array (
178
- 'comment ' => $ commentBody
174
+ return $ this ->post ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/issues/ ' .urlencode ($ number ). ' /comments ' , array (
175
+ 'body ' => $ body
179
176
));
180
-
181
- return $ response ['comment ' ];
182
177
}
183
178
184
179
/**
185
180
* List all project labels by username and repo
186
- * http://develop .i.8713187.xyz/p /issues.html#listing_labels
181
+ * @link http://developer .i.8713187.xyz/v3 /issues/labels/
187
182
*
188
183
* @param string $username the username
189
184
* @param string $repo the repo
190
185
* @return array list of project labels
191
186
*/
192
187
public function getLabels ($ username , $ repo )
193
188
{
194
- $ response = $ this ->get ('issues/labels/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ));
189
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/labels ' );
190
+ }
195
191
196
- return $ response ['labels ' ];
192
+ /**
193
+ * Get project label by username and repo
194
+ * @link http://developer.github.com/v3/issues/labels/
195
+ *
196
+ * @param string $username the username
197
+ * @param string $repo the repo
198
+ * @param string $name the label name
199
+ * @return array list of project labels
200
+ */
201
+ public function getLabel ($ username , $ repo , $ name )
202
+ {
203
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/labels/ ' .urlencode ($ name ));
197
204
}
198
205
199
206
/**
200
207
* Add a label to the issue by username, repo and issue number. Requires authentication.
201
- * http://develop .i.8713187.xyz/p /issues.html#add_and_remove_labels
208
+ * @link http://developer .i.8713187.xyz/v3 /issues/labels/
202
209
*
203
210
* @param string $username the username
204
211
* @param string $repo the repo
205
- * @param string $issueNumber the issue number
206
212
* @param string $labelName the label name
213
+ * @param string $labelColor the label color
207
214
* @return array list of issue labels
208
215
*/
209
- public function addLabel ($ username , $ repo , $ labelName , $ issueNumber )
216
+ public function addLabel ($ username , $ repo , $ labelName , $ labelColor )
210
217
{
211
- $ response = $ this ->post ('issues/label/add/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ labelName ).'/ ' .urlencode ($ issueNumber ));
212
-
213
- return $ response ['labels ' ];
218
+ return $ this ->post ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/labels ' , array (
219
+ 'name ' => $ labelName ,
220
+ 'color ' => $ labelColor
221
+ ));
214
222
}
215
223
216
224
/**
217
225
* Remove a label from the issue by username, repo, issue number and label name. Requires authentication.
218
- * http://develop .i.8713187.xyz/p /issues.html#add_and_remove_labels
226
+ * @link http://developer .i.8713187.xyz/v3 /issues/labels/
219
227
*
220
228
* @param string $username the username
221
229
* @param string $repo the repo
222
- * @param string $issueNumber the issue number
223
230
* @param string $labelName the label name
224
231
* @return array list of issue labels
225
232
*/
226
- public function removeLabel ($ username , $ repo , $ labelName, $ issueNumber )
233
+ public function removeLabel ($ username , $ repo , $ labelName )
227
234
{
228
- $ response = $ this ->post ('issues/label/remove/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/ ' .urlencode ($ labelName ).'/ ' .urlencode ($ issueNumber ));
229
-
230
- return $ response ['labels ' ];
235
+ return $ this ->delete ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/labels/ ' .urlencode ($ labelName ));
231
236
}
232
237
}
0 commit comments