Skip to content

Commit 87ebd4d

Browse files
author
Daniel Miller
committed
Updated routes.js and user.js to include getAll for users
1 parent ca90bf2 commit 87ebd4d

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

api/v3.0.0/routes.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2919,6 +2919,20 @@
29192919
},
29202920

29212921
"user": {
2922+
"get-all": {
2923+
"url": "/users",
2924+
"method": "GET",
2925+
"params": {
2926+
"since":{
2927+
"type": "Number",
2928+
"required": false,
2929+
"validation": "",
2930+
"description": "The integer ID of the last User that you’ve seen."
2931+
}
2932+
}
2933+
2934+
},
2935+
29222936
"get-from": {
29232937
"url": "/users/:user",
29242938
"method": "GET",

api/v3.0.0/user.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,44 @@ var user = module.exports = {
1919
};
2020

2121
(function() {
22+
/** section: github
23+
* user#getAll(msg, callback) -> null
24+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
25+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
26+
*
27+
* ##### Params on the `msg` object:
28+
*
29+
* - 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'.
30+
**/
31+
this.getAll = function(msg, block, callback) {
32+
var self = this;
33+
this.client.httpSend(msg, block, function(err, res) {
34+
if (err)
35+
return self.sendError(err, null, msg, callback);
36+
37+
var ret;
38+
try {
39+
ret = res.data && JSON.parse(res.data);
40+
}
41+
catch (ex) {
42+
if (callback)
43+
callback(new error.InternalServerError(ex.message), res);
44+
return;
45+
}
46+
47+
if (!ret)
48+
ret = {};
49+
if (!ret.meta)
50+
ret.meta = {};
51+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
52+
if (res.headers[header])
53+
ret.meta[header] = res.headers[header];
54+
});
55+
56+
if (callback)
57+
callback(null, ret);
58+
});
59+
};
2260
/** section: github
2361
* user#getFrom(msg, callback) -> null
2462
* - msg (Object): Object that contains the parameters and their values to be sent to the server.

0 commit comments

Comments
 (0)