@@ -11,26 +11,39 @@ class IssuesService extends Service {
11
11
/// including owned repositories, member repositories, and organization repositories
12
12
///
13
13
/// 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);
17
21
}
18
22
19
23
/// List all issues across owned and member repositories for the authenticated
20
24
/// user.
21
25
///
22
26
/// 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);
26
34
}
27
35
28
36
/// List all issues for a given organization for the authenticated user.
29
37
///
30
38
/// 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);
34
47
}
35
48
36
49
/// Lists the issues for the specified repository.
@@ -39,8 +52,23 @@ class IssuesService extends Service {
39
52
///
40
53
/// API docs:https://developer.github.com/v3/issues/#list-issues-for-a-repository
41
54
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) {
43
66
var params = < String , String > {};
67
+
68
+ if (perPage != null ) {
69
+ params['per_page' ] = perPage.toString ();
70
+ }
71
+
44
72
if (state != null ) {
45
73
// should be `open`, `closed` or `all`
46
74
params['state' ] = state;
@@ -62,9 +90,8 @@ class IssuesService extends Service {
62
90
params['since' ] = since.toUtc ().toIso8601String ();
63
91
}
64
92
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);
68
95
}
69
96
70
97
/// Edit an issue.
0 commit comments