Skip to content

Commit 9f8664a

Browse files
committed
Merge pull request octokit#189 from reviewninja/master
add repos one
2 parents 5480e5c + b31f492 commit 9f8664a

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

api/v3.0.0/repos.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,46 @@ var repos = module.exports = {
290290
});
291291
};
292292

293+
/** section: github
294+
* repos#one(msg, callback) -> null
295+
* - msg (Object): Object that contains the parameters and their values to be sent to the server.
296+
* - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument.
297+
*
298+
* ##### Params on the `msg` object:
299+
*
300+
* - 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'.
301+
* - id (String): Required.
302+
**/
303+
this.one = function(msg, block, callback) {
304+
var self = this;
305+
this.client.httpSend(msg, block, function(err, res) {
306+
if (err)
307+
return self.sendError(err, null, msg, callback);
308+
309+
var ret;
310+
try {
311+
ret = res.data && JSON.parse(res.data);
312+
}
313+
catch (ex) {
314+
if (callback)
315+
callback(new error.InternalServerError(ex.message), res);
316+
return;
317+
}
318+
319+
if (!ret)
320+
ret = {};
321+
if (!ret.meta)
322+
ret.meta = {};
323+
["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) {
324+
if (res.headers[header])
325+
ret.meta[header] = res.headers[header];
326+
});
327+
328+
if (callback)
329+
callback(null, ret);
330+
});
331+
};
332+
293333
/** section: github
294334
* repos#update(msg, callback) -> null
295335
* - msg (Object): Object that contains the parameters and their values to be sent to the server.

api/v3.0.0/routes.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1935,6 +1935,14 @@
19351935
}
19361936
},
19371937

1938+
"one": {
1939+
"url": "/repositories/:id",
1940+
"method": "GET",
1941+
"params": {
1942+
"$id": null
1943+
}
1944+
},
1945+
19381946
"update": {
19391947
"url": "/repos/:user/:repo",
19401948
"method": "PATCH",

0 commit comments

Comments
 (0)