Permalink
Browse files

Merge pull request #65 from trevorah/master

issues can be requested with the per_page query
  • Loading branch information...
2 parents 84bf880 + 53e7bc6 commit 0bcd9e99e1f851e9f9a0dd617d40376479bef578 @pksunkara committed Nov 25, 2013
Showing with 19 additions and 14 deletions.
  1. +5 −1 README.md
  2. +7 −7 lib/octonode/repo.js
  3. +7 −6 src/octonode/repo.coffee
View
@@ -368,9 +368,13 @@ ghrepo.branches(callback); //array of branches
Issues are arranged in [pages](http://developer.github.com/v3/#pagination).
The page argument is optional and is used to specify which page of issues to retrieve.
+The perPage argument is also optional and is used to specify how many issues per page.
```js
-ghrepo.issues(page, callback); //array of issues
+ghrepo.issues(page, perPage, callback); //array of issues
+ghrepo.issues(1, 100, callback); //array of users
+ghrepo.issues(10, callback); //array of users
+ghrepo.issues(callback); //array of users
```
#### Get the README for a repository (GET /repos/pksunkara/hub/readme)
View
@@ -144,19 +144,19 @@
});
};
- Repo.prototype.issues = function(cbOrPage, cb) {
- if ((cb == null) && cbOrPage) {
- cb = cbOrPage;
- cbOrPage = 1;
- }
- return this.client.get("/repos/" + this.name + "/issues?page=" + cbOrPage, function(err, s, b) {
+ Repo.prototype.issues = function() {
+ var cb, page, params, per_page, _i;
+ params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), cb = arguments[_i++];
+ page = params[0] || 1;
+ per_page = params[1] || 30;
+ return this.client.get("/repos/" + this.name + "/issues", page, per_page, function(err, s, b, headers) {
if (err) {
return cb(err);
}
if (s !== 200) {
return cb(new Error("Repo issues error"));
} else {
- return cb(null, b);
+ return cb(null, b, headers);
}
});
};
@@ -87,13 +87,14 @@ class Repo
# Get the issues for a repository
# '/repos/pksunkara/hub/issues' GET
- issues: (cbOrPage, cb) ->
- if !cb? and cbOrPage
- cb = cbOrPage
- cbOrPage = 1
- @client.get "/repos/#{@name}/issues?page=#{cbOrPage}", (err, s, b) ->
+ # - page, optional - params[0]
+ # - per_page, optional - params[1]
+ issues: (params..., cb) ->
+ page = params[0] || 1
+ per_page = params[1] || 30
+ @client.get "/repos/#{@name}/issues", page, per_page, (err, s, b, headers) ->
return cb(err) if err
- if s isnt 200 then cb(new Error("Repo issues error")) else cb null, b
+ if s isnt 200 then cb(new Error("Repo issues error")) else cb null, b, headers
# Get the README for a repository
# '/repos/pksunkara/hub/readme' GET

0 comments on commit 0bcd9e9

Please sign in to comment.