Skip to content

Commit 56d79e5

Browse files
committed
Merge pull request octokit#185 from iFixit/master
Add get-issue-labels route
2 parents 569fd40 + 0373d45 commit 56d79e5

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

api/v3.0.0/issues.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,48 @@ var issues = module.exports = {
855855
});
856856
};
857857

858+
/** section: github
859+
* issues#getIssueLabels(msg, callback) -> null
860+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
861+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
862+
*
863+
* ##### Params on the `msg` object:
864+
*
865+
* - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'.
866+
* - user (String): Required.
867+
* - repo (String): Required.
868+
* - number (Number): Required. Validation rule: ` ^[0-9]+$ `.
869+
**/
870+
this.getIssueLabels = function(msg, block, callback) {
871+
var self = this;
872+
this.client.httpSend(msg, block, function(err, res) {
873+
if (err)
874+
return self.sendError(err, null, msg, callback);
875+
876+
var ret;
877+
try {
878+
ret = res.data && JSON.parse(res.data);
879+
}
880+
catch (ex) {
881+
if (callback)
882+
callback(new error.InternalServerError(ex.message), res);
883+
return;
884+
}
885+
886+
if (!ret)
887+
ret = {};
888+
if (!ret.meta)
889+
ret.meta = {};
890+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
891+
if (res.headers[header])
892+
ret.meta[header] = res.headers[header];
893+
});
894+
895+
if (callback)
896+
callback(null, ret);
897+
});
898+
};
899+
858900
/** section: github
859901
* issues#getAllMilestones(msg, callback) -> null
860902
* - msg (Object): Object that contains the parameters and their values to be sent to the server.

api/v3.0.0/routes.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1125,6 +1125,16 @@
11251125
}
11261126
},
11271127

1128+
"get-issue-labels": {
1129+
"url": "/repos/:user/:repo/issues/:number/labels",
1130+
"method": "GET",
1131+
"params": {
1132+
"$user": null,
1133+
"$repo": null,
1134+
"$number": null
1135+
}
1136+
},
1137+
11281138
"get-all-milestones": {
11291139
"url": "/repos/:user/:repo/milestones",
11301140
"method": "GET",

0 commit comments

Comments
 (0)