Skip to content

Commit 5f2c34e

Browse files
committed
Merge pull request SpinlockLabs#71 from kevmoo/add_perPage_to_listByRepo
Add per page to list by repo
2 parents 39c9014 + 915e452 commit 5f2c34e

File tree

2 files changed

+41
-14
lines changed

2 files changed

+41
-14
lines changed

lib/src/common/issues_service.dart

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,39 @@ class IssuesService extends Service {
1111
/// including owned repositories, member repositories, and organization repositories
1212
///
1313
/// API docs: https://developer.github.com/v3/issues/#list-issues
14-
Stream<Issue> listAll() {
15-
return new PaginationHelper(_github)
16-
.objects("GET", "/issues", Issue.fromJSON);
14+
Stream<Issue> listAll(
15+
{String state,
16+
String direction,
17+
String sort,
18+
DateTime since,
19+
int perPage}) {
20+
return _listIssues("/issues", state, direction, sort, since, perPage);
1721
}
1822

1923
/// List all issues across owned and member repositories for the authenticated
2024
/// user.
2125
///
2226
/// API docs: https://developer.github.com/v3/issues/#list-issues
23-
Stream<Issue> listByUser() {
24-
return new PaginationHelper(_github)
25-
.objects("GET", "/user/issues", Issue.fromJSON);
27+
Stream<Issue> listByUser(
28+
{String state,
29+
String direction,
30+
String sort,
31+
DateTime since,
32+
int perPage}) {
33+
return _listIssues("/user/issues", state, direction, sort, since, perPage);
2634
}
2735

2836
/// List all issues for a given organization for the authenticated user.
2937
///
3038
/// API docs: https://developer.github.com/v3/issues/#list-issues
31-
Stream<Issue> listByOrg(String org) {
32-
return new PaginationHelper(_github)
33-
.objects("GET", "/orgs/${org}/issues", Issue.fromJSON);
39+
Stream<Issue> listByOrg(String org,
40+
{String state,
41+
String direction,
42+
String sort,
43+
DateTime since,
44+
int perPage}) {
45+
return _listIssues(
46+
"/orgs/${org}/issues", state, direction, sort, since, perPage);
3447
}
3548

3649
/// Lists the issues for the specified repository.
@@ -39,8 +52,23 @@ class IssuesService extends Service {
3952
///
4053
/// API docs:https://developer.github.com/v3/issues/#list-issues-for-a-repository
4154
Stream<Issue> listByRepo(RepositorySlug slug,
42-
{String state, String direction, String sort, DateTime since}) {
55+
{String state,
56+
String direction,
57+
String sort,
58+
DateTime since,
59+
int perPage}) {
60+
return _listIssues("/repos/${slug.fullName}/issues", state, direction, sort,
61+
since, perPage);
62+
}
63+
64+
Stream<Issue> _listIssues(String pathSegment, String state, String direction,
65+
String sort, DateTime since, int perPage) {
4366
var params = <String, String>{};
67+
68+
if (perPage != null) {
69+
params['per_page'] = perPage.toString();
70+
}
71+
4472
if (state != null) {
4573
// should be `open`, `closed` or `all`
4674
params['state'] = state;
@@ -62,9 +90,8 @@ class IssuesService extends Service {
6290
params['since'] = since.toUtc().toIso8601String();
6391
}
6492

65-
return new PaginationHelper(_github).objects(
66-
"GET", "/repos/${slug.fullName}/issues", Issue.fromJSON,
67-
params: params);
93+
return new PaginationHelper(_github)
94+
.objects("GET", pathSegment, Issue.fromJSON, params: params);
6895
}
6996

7097
/// Edit an issue.

test/git_integration_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ main() {
9696
test('create and get a new reference (branch)', () async {
9797
var branchName = _randomGitName();
9898

99-
var createdRef = await github.git
99+
await github.git
100100
.createReference(slug, 'refs/heads/$branchName', createdCommitSha);
101101

102102
var fetchedRef = await github.git.getReference(slug, 'heads/$branchName');

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy