More generic method fun
MODIFY
lib/src/common/activity_service.dart
lib/src/common/activity_service.dart
@@ -12,8 +12,7 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events
Stream<Event> listPublicEvents({int pages: 2}) {
return new PaginationHelper(_github)
- .objects("GET", "/events", Event.fromJSON, pages: pages)
- as Stream<Event>;
+ .objects("GET", "/events", Event.fromJSON, pages: pages);
}
/// Lists public events for a network of repositories.
@@ -23,7 +22,7 @@ class ActivityService extends Service {
{int pages: 2}) {
return new PaginationHelper(_github).objects(
"GET", "/networks/${slug.fullName}/events", Event.fromJSON,
- pages: pages) as Stream<Event>;
+ pages: pages);
}
/// Returns an [EventPoller] for repository network events.
@@ -44,7 +43,7 @@ class ActivityService extends Service {
Stream<Event> listRepositoryIssueEvents(RepositorySlug slug, {int pages}) {
return new PaginationHelper(_github).objects(
"GET", "/repos/${slug.fullName}/issues/events", Event.fromJSON,
- pages: pages) as Stream<Event>;
+ pages: pages);
}
/// Returns an [EventPoller] for public events.
@@ -58,7 +57,7 @@ class ActivityService extends Service {
Stream<Event> listRepositoryEvents(RepositorySlug slug, {int pages}) {
return new PaginationHelper(_github).objects(
"GET", "/repos/${slug.fullName}/events", Event.fromJSON,
- pages: pages) as Stream<Event>;
+ pages: pages);
}
/// Returns an [EventPoller] for repository events.
@@ -72,8 +71,7 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/events/#list-public-events-for-an-organization
Stream<Event> listEventsForOrganization(String name, {int pages}) {
return new PaginationHelper(_github)
- .objects("GET", "/orgs/$name/events", Event.fromJSON, pages: pages)
- as Stream<Event>;
+ .objects("GET", "/orgs/$name/events", Event.fromJSON, pages: pages);
}
/// Returns an [EventPoller] for public events for an organization.
@@ -99,8 +97,8 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/events/#list-events-performed-by-a-user
Stream<Event> listEventsPerformedByUser(String username, {int pages}) {
return new PaginationHelper(_github).objects(
- "GET", "/users/$username/events", Event.fromJSON, pages: pages)
- as Stream<Event>;
+ "GET", "/users/$username/events", Event.fromJSON,
+ pages: pages);
}
/// Lists the public events performed by a user.
@@ -109,7 +107,7 @@ class ActivityService extends Service {
Stream<Event> listPublicEventsPerformedByUser(String username, {int pages}) {
return new PaginationHelper(_github).objects(
"GET", "/users/$username/events/public", Event.fromJSON,
- pages: pages) as Stream<Event>;
+ pages: pages);
}
/// Returns an [EventPoller] for the user's organization dashboard.
@@ -127,8 +125,7 @@ class ActivityService extends Service {
{bool all: false, bool participating: false}) {
return new PaginationHelper(_github).objects(
"GET", '/notifications', Notification.fromJSON,
- params: {"all": all, "participating": participating})
- as Stream<Notification>;
+ params: {"all": all, "participating": participating});
}
/// Lists all notifications for a given repository.
@@ -136,12 +133,9 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/notifications/#list-your-notifications-in-a-repository
Stream<Notification> listRepositoryNotifications(RepositorySlug repository,
{bool all: false, bool participating: false}) {
- return new PaginationHelper(_github).objects(
- "GET",
- '/repos/${repository.fullName}/notifications',
- Notification.fromJSON,
- params: {"all": all, "participating": participating})
- as Stream<Notification>;
+ return new PaginationHelper(_github).objects("GET",
+ '/repos/${repository.fullName}/notifications', Notification.fromJSON,
+ params: {"all": all, "participating": participating});
}
/// Marks all notifications up to [lastRead] as read.
@@ -194,8 +188,7 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/starring/#list-stargazers
Stream<User> listStargazers(RepositorySlug slug) {
return new PaginationHelper(_github)
- .objects("GET", "/repos/${slug.fullName}/stargazers", User.fromJSON)
- as Stream<User>;
+ .objects("GET", "/repos/${slug.fullName}/stargazers", User.fromJSON);
}
/// Lists all the repos starred by a user.
@@ -203,16 +196,15 @@ class ActivityService extends Service {
/// API docs: https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
Stream<Repository> listStarredByUser(String user) {
return new PaginationHelper(_github)
- .objects("GET", "/users/$user/starred", Repository.fromJSON)
- as Stream<Repository>;
+ .objects("GET", "/users/$user/starred", Repository.fromJSON);
}
/// Lists all the repos by the current user.
///
/// API docs: https://developer.github.com/v3/activity/starring/#list-repositories-being-starred
Stream<Repository> listStarred() {
- return new PaginationHelper(_github).objects(
- "GET", "/user/starred", Repository.fromJSON) as Stream<Repository>;
+ return new PaginationHelper(_github)
+ .objects("GET", "/user/starred", Repository.fromJSON);
}
/// Checks if the currently authenticated user has starred the specified repository.
@@ -250,7 +242,7 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/watching/#list-watchers
Stream<User> listWatchers(RepositorySlug slug) {
- return new PaginationHelper<User>(_github)
+ return new PaginationHelper(_github)
.objects("GET", "/repos/${slug.fullName}/subscribers", User.fromJSON);
}
@@ -258,7 +250,7 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
Stream<Repository> listWatchedByUser(String user) {
- return new PaginationHelper<Repository>(_github)
+ return new PaginationHelper(_github)
.objects("GET", '/users/$user/subscriptions', Repository.fromJSON);
}
@@ -266,7 +258,7 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/watching/#list-repositories-being-watched
Stream<Repository> listWatched() {
- return new PaginationHelper<Repository>(_github)
+ return new PaginationHelper(_github)
.objects("GET", '/user/subscriptions', Repository.fromJSON);
}

MODIFY
lib/src/common/authorizations_service.dart
lib/src/common/authorizations_service.dart
@@ -15,8 +15,7 @@ class AuthorizationsService extends Service {
/// API docs: https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations
Stream<Authorization> listAuthorizations() {
return new PaginationHelper(_github)
- .objects("GET", "/authorizations", Authorization.fromJSON)
- as Stream<Authorization>;
+ .objects("GET", "/authorizations", Authorization.fromJSON);
}
/// Fetches an authorization specified by [id].

MODIFY
lib/src/common/gists_service.dart
lib/src/common/gists_service.dart
@@ -11,8 +11,8 @@ class GistsService extends Service {
///
/// API docs: https://developer.github.com/v3/gists/#list-gists
Stream<Gist> listUserGists(String username) {
- return new PaginationHelper(_github).objects(
- "GET", "/users/$username/gists", Gist.fromJSON) as Stream<Gist>;
+ return new PaginationHelper(_github)
+ .objects("GET", "/users/$username/gists", Gist.fromJSON);
}
/// Fetches the gists for the currently authenticated user.
@@ -20,8 +20,8 @@ class GistsService extends Service {
///
/// API docs: https://developer.github.com/v3/gists/#list-gists
Stream<Gist> listCurrentUserGists() {
- return new PaginationHelper(_github).objects("GET", "/gists", Gist.fromJSON)
- as Stream<Gist>;
+ return new PaginationHelper(_github)
+ .objects("GET", "/gists", Gist.fromJSON);
}
/// Fetches the currently authenticated user's public gists.
@@ -29,7 +29,7 @@ class GistsService extends Service {
/// API docs: https://developer.github.com/v3/gists/#list-gists
Stream<Gist> listCurrentUserPublicGists() {
return new PaginationHelper(_github)
- .objects("GET", "/gists/public", Gist.fromJSON) as Stream<Gist>;
+ .objects("GET", "/gists/public", Gist.fromJSON);
}
/// Fetches the currently authenticated user's starred gists.
@@ -37,7 +37,7 @@ class GistsService extends Service {
/// API docs: https://developer.github.com/v3/gists/#list-gists
Stream<Gist> listCurrentUserStarredGists() {
return new PaginationHelper(_github)
- .objects("GET", "/gists/starred", Gist.fromJSON) as Stream<Gist>;
+ .objects("GET", "/gists/starred", Gist.fromJSON);
}
/// Fetches a Gist by the specified [id].
@@ -154,8 +154,7 @@ class GistsService extends Service {
/// API docs: https://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
Stream<GistComment> listComments(String gistId) {
return new PaginationHelper(_github)
- .objects("GET", "/gists/$gistId/comments", GistComment.fromJSON)
- as Stream<GistComment>;
+ .objects("GET", "/gists/$gistId/comments", GistComment.fromJSON);
}
// TODO: Implement getComment: https://developer.github.com/v3/gists/comments/#get-a-single-comment

MODIFY
lib/src/common/git_service.dart
lib/src/common/git_service.dart
@@ -64,7 +64,7 @@ class GitService extends Service {
}
return new PaginationHelper(_github)
- .objects('GET', path, GitReference.fromJSON) as Stream<GitReference>;
+ .objects('GET', path, GitReference.fromJSON);
}
/// Creates a new reference in a repository.

MODIFY
lib/src/common/issues_service.dart
lib/src/common/issues_service.dart
@@ -118,8 +118,7 @@ class IssuesService extends Service {
}
return new PaginationHelper(_github)
- .objects("GET", pathSegment, Issue.fromJSON, params: params)
- as Stream<Issue>;
+ .objects("GET", pathSegment, Issue.fromJSON, params: params);
}
/// Edit an issue.
@@ -164,8 +163,7 @@ class IssuesService extends Service {
/// API docs: https://developer.github.com/v3/issues/assignees/#list-assignees
Stream<User> listAssignees(RepositorySlug slug) {
return new PaginationHelper(_github)
- .objects("GET", "/repos/${slug.fullName}/assignees", User.fromJSON)
- as Stream<User>;
+ .objects("GET", "/repos/${slug.fullName}/assignees", User.fromJSON);
}
/// Checks if a user is an assignee for the specified repository.
@@ -185,17 +183,15 @@ class IssuesService extends Service {
return new PaginationHelper(_github).objects(
'GET',
'/repos/${slug.fullName}/issues/$issueNumber/comments',
- IssueComment.fromJSON) as Stream<IssueComment>;
+ IssueComment.fromJSON);
}
/// Lists all comments in a repository.
///
/// API docs: https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
Stream<IssueComment> listCommentsByRepo(RepositorySlug slug) {
- return new PaginationHelper(_github).objects(
- 'GET',
- '/repos/${slug.fullName}/issues/comments',
- IssueComment.fromJSON) as Stream<IssueComment>;
+ return new PaginationHelper(_github).objects('GET',
+ '/repos/${slug.fullName}/issues/comments', IssueComment.fromJSON);
}
/// Fetches the specified issue comment.
@@ -235,9 +231,8 @@ class IssuesService extends Service {
///
/// API docs: https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
Stream<IssueLabel> listLabels(RepositorySlug slug) {
- return new PaginationHelper(_github).objects(
- "GET", "/repos/${slug.fullName}/labels", IssueLabel.fromJSON)
- as Stream<IssueLabel>;
+ return new PaginationHelper(_github)
+ .objects("GET", "/repos/${slug.fullName}/labels", IssueLabel.fromJSON);
}
/// Fetches a single label.
@@ -283,7 +278,7 @@ class IssuesService extends Service {
return new PaginationHelper(_github).objects(
"GET",
"/repos/${slug.fullName}/issues/$issueNumber/labels",
- IssueLabel.fromJSON) as Stream<IssueLabel>;
+ IssueLabel.fromJSON);
}
/// Adds labels to an issue.
@@ -341,8 +336,7 @@ class IssuesService extends Service {
/// API docs: https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository
Stream<Milestone> listMilestones(RepositorySlug slug) {
return new PaginationHelper(_github).objects(
- "GET", "/repos/${slug.fullName}/milestones", Milestone.fromJSON)
- as Stream<Milestone>;
+ "GET", "/repos/${slug.fullName}/milestones", Milestone.fromJSON);
}
// TODO: Implement getMilestone: https://developer.github.com/v3/issues/milestones/#get-a-single-milestone

MODIFY
lib/src/common/orgs_service.dart
lib/src/common/orgs_service.dart
@@ -17,8 +17,8 @@ class OrganizationsService extends Service {
if (userName == null) {
requestPath = "/user/orgs";
}
- return new PaginationHelper(_github).objects(
- "GET", requestPath, Organization.fromJSON) as Stream<Organization>;
+ return new PaginationHelper(_github)
+ .objects("GET", requestPath, Organization.fromJSON);
}
/// Fetches the organization specified by [name].
@@ -74,7 +74,7 @@ class OrganizationsService extends Service {
statusCode: 200,
convert: Organization.fromJSON,
// TODO: This is probably wrong. Map needs to be json encoded?
- body: map) as Future<Organization>;
+ body: map);
}
/// Lists all of the teams for the specified organization.
@@ -82,7 +82,7 @@ class OrganizationsService extends Service {
/// API docs: https://developer.github.com/v3/orgs/teams/#list-teams
Stream<Team> listTeams(String orgName) {
return new PaginationHelper(_github)
- .objects("GET", "/orgs/$orgName/teams", Team.fromJSON) as Stream<Team>;
+ .objects("GET", "/orgs/$orgName/teams", Team.fromJSON);
}
/// Gets the team specified by the [teamId].
@@ -141,8 +141,7 @@ class OrganizationsService extends Service {
/// API docs: https://developer.github.com/v3/orgs/teams/#list-team-members
Stream<TeamMember> listTeamMembers(int teamId) {
return new PaginationHelper(_github)
- .objects("GET", "/teams/$teamId/members", TeamMember.fromJSON)
- as Stream<TeamMember>;
+ .objects("GET", "/teams/$teamId/members", TeamMember.fromJSON);
}
Future<bool> getTeamMemberStatus(int teamId, String user) {
@@ -231,8 +230,7 @@ class OrganizationsService extends Service {
/// API docs: https://developer.github.com/v3/orgs/teams/#list-team-repos
Stream<Repository> listTeamRepositories(int teamId) {
return new PaginationHelper(_github)
- .objects("GET", "/teams/$teamId/repos", Repository.fromJSON)
- as Stream<Repository>;
+ .objects("GET", "/teams/$teamId/repos", Repository.fromJSON);
}
/// Checks if a team manages the specified repository.
@@ -273,7 +271,7 @@ class OrganizationsService extends Service {
/// API docs: https://developer.github.com/v3/orgs/teams/#list-user-teams
Stream<Team> listUserTeams() {
return new PaginationHelper(_github)
- .objects("GET", "/user/teams", Team.fromJSON) as Stream<Team>;
+ .objects("GET", "/user/teams", Team.fromJSON);
}
/// Lists the hooks for the specified organization.
@@ -281,8 +279,7 @@ class OrganizationsService extends Service {
/// API docs: https://developer.github.com/v3/orgs/hooks/#list-hooks
Stream<Hook> listHooks(String org) {
return new PaginationHelper(_github).objects("GET", "/orgs/$org/hooks",
- (Map<String, dynamic> input) => Hook.fromJSON(org, input))
- as Stream<Hook>;
+ (Map<String, dynamic> input) => Hook.fromJSON(org, input));
}
/// Fetches a single hook by [id].

MODIFY
lib/src/common/pulls_service.dart
lib/src/common/pulls_service.dart
@@ -10,7 +10,7 @@ class PullRequestsService extends Service {
Stream<PullRequest> list(RepositorySlug slug, {int pages}) {
return new PaginationHelper(_github).objects(
"GET", "/repos/${slug.fullName}/pulls", PullRequest.fromJSON,
- pages: pages) as Stream<PullRequest>;
+ pages: pages);
}
/// Fetches a single pull request.
@@ -56,7 +56,7 @@ class PullRequestsService extends Service {
return new PaginationHelper(_github).objects(
"GET",
'/repos/${slug.fullName}/pulls/$number/commits',
- RepositoryCommit.fromJSON) as Stream<RepositoryCommit>;
+ RepositoryCommit.fromJSON);
}
Stream<RepositoryCommit> listFiles(RepositorySlug slug, int number) {
@@ -102,17 +102,15 @@ class PullRequestsService extends Service {
return new PaginationHelper(_github).objects(
"GET",
"/repos/${slug.fullName}/pulls/$number/comments",
- PullRequestComment.fromJSON) as Stream<PullRequestComment>;
+ PullRequestComment.fromJSON);
}
/// Lists all comments on all pull requests for the repository.
///
/// API docs: https://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository
Stream<PullRequestComment> listComments(RepositorySlug slug) {
- return new PaginationHelper(_github).objects(
- "GET",
- "/repos/${slug.fullName}/pulls/comments",
- PullRequestComment.fromJSON) as Stream<PullRequestComment>;
+ return new PaginationHelper(_github).objects("GET",
+ "/repos/${slug.fullName}/pulls/comments", PullRequestComment.fromJSON);
}
/// Creates a new pull request comment.

MODIFY
lib/src/common/repos_service.dart
lib/src/common/repos_service.dart
@@ -17,8 +17,7 @@ class RepositoriesService extends Service {
var params = {"type": type, "sort": sort, "direction": direction};
return new PaginationHelper(_github)
- .objects("GET", "/user/repos", Repository.fromJSON, params: params)
- as Stream<Repository>;
+ .objects("GET", "/user/repos", Repository.fromJSON, params: params);
}
/// Lists the repositories of the user specified by [user] in a streamed fashion.
@@ -31,8 +30,8 @@ class RepositoriesService extends Service {
var params = {"type": type, "sort": sort, "direction": direction};
return new PaginationHelper(_github).objects(
- "GET", "/users/$user/repos", Repository.fromJSON, params: params)
- as Stream<Repository>;
+ "GET", "/users/$user/repos", Repository.fromJSON,
+ params: params);
}
/// List repositories for the specified [org].
@@ -45,8 +44,8 @@ class RepositoriesService extends Service {
};
return new PaginationHelper(_github).objects(
- "GET", "/orgs/$org/repos", Repository.fromJSON, params: params)
- as Stream<Repository>;
+ "GET", "/orgs/$org/repos", Repository.fromJSON,
+ params: params);
}
/// Lists all the public repositories on GitHub, in the order that they were
@@ -174,8 +173,8 @@ class RepositoriesService extends Service {
///
/// API docs: https://developer.github.com/v3/repos/#list-teams
Stream<Team> listTeams(RepositorySlug slug) {
- return new PaginationHelper(_github).objects(
- 'GET', '/repos/${slug.fullName}/teams', Team.fromJSON) as Stream<Team>;
+ return new PaginationHelper(_github)
+ .objects('GET', '/repos/${slug.fullName}/teams', Team.fromJSON);
}
/// Gets a language breakdown for the specified repository.
@@ -191,8 +190,7 @@ class RepositoriesService extends Service {
/// API docs: https://developer.github.com/v3/repos/#list-tags
Stream<Tag> listTags(RepositorySlug slug) {
return new PaginationHelper(_github).objects(
- 'GET', '/repos/${slug.fullName}/tags', (j) => new Tag.fromJson(j))
- as Stream<Tag>;
+ 'GET', '/repos/${slug.fullName}/tags', (j) => new Tag.fromJson(j));
}
/// Lists the branches of the specified repository.
@@ -200,8 +198,7 @@ class RepositoriesService extends Service {
/// API docs: https://developer.github.com/v3/repos/#list-branches
Stream<Branch> listBranches(RepositorySlug slug) {
return new PaginationHelper(_github)
- .objects('GET', '/repos/${slug.fullName}/branches', Branch.fromJSON)
- as Stream<Branch>;
+ .objects('GET', '/repos/${slug.fullName}/branches', Branch.fromJSON);
}
/// Fetches the specified branch.
@@ -215,9 +212,8 @@ class RepositoriesService extends Service {
///
/// API docs: https://developer.github.com/v3/repos/collaborators/#list
Stream<User> listCollaborators(RepositorySlug slug) {
- return new PaginationHelper(_github).objects(
- "GET", "/repos/${slug.fullName}/collaborators", User.fromJSON)
- as Stream<User>;
+ return new PaginationHelper(_github)
+ .objects("GET", "/repos/${slug.fullName}/collaborators", User.fromJSON);
}
Future<bool> isCollaborator(RepositorySlug slug, String user) {
@@ -256,8 +252,7 @@ class RepositoriesService extends Service {
/// API docs: https://developer.github.com/v3/repos/commits/#list-commits-on-a-repository
Stream<RepositoryCommit> listCommits(RepositorySlug slug) {
return new PaginationHelper(_github).objects(
- "GET", "/repos/${slug.fullName}/commits", RepositoryCommit.fromJSON)
- as Stream<RepositoryCommit>;
+ "GET", "/repos/${slug.fullName}/commits", RepositoryCommit.fromJSON);
}
/// Fetches the specified commit.
@@ -408,9 +403,8 @@ class RepositoriesService extends Service {
///
/// API docs: https://developer.github.com/v3/repos/forks/#list-forks
Stream<Repository> listForks(RepositorySlug slug) {
- return new PaginationHelper(_github).objects(
- "GET", "/repos/${slug.fullName}/forks", Repository.fromJSON)
- as Stream<Repository>;
+ return new PaginationHelper(_github)
+ .objects("GET", "/repos/${slug.fullName}/forks", Repository.fromJSON);
}
/// Creates a fork for the authenticated user.
@@ -430,8 +424,7 @@ class RepositoriesService extends Service {
return new PaginationHelper(_github).objects(
"GET",
"/repos/${slug.fullName}/hooks",
- (Map<String, dynamic> input) => Hook.fromJSON(slug.fullName, input))
- as Stream<Hook>;
+ (Map<String, dynamic> input) => Hook.fromJSON(slug.fullName, input));
}
/// Fetches a single hook by [id].
@@ -485,8 +478,7 @@ class RepositoriesService extends Service {
/// API docs: https://developer.github.com/v3/repos/keys/#list
Stream<PublicKey> listDeployKeys(RepositorySlug slug) {
return new PaginationHelper(_github)
- .objects("GET", "/repos/${slug.fullName}/keys", PublicKey.fromJSON)
- as Stream<PublicKey>;
+ .objects("GET", "/repos/${slug.fullName}/keys", PublicKey.fromJSON);
}
// TODO: Implement getDeployKey: https://developer.github.com/v3/repos/keys/#get
@@ -526,9 +518,8 @@ class RepositoriesService extends Service {
///
/// API docs: https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
Stream<Release> listReleases(RepositorySlug slug) {
- return new PaginationHelper(_github).objects(
- "GET", "/repos/${slug.fullName}/releases", Release.fromJSON)
- as Stream<Release>;
+ return new PaginationHelper(_github)
+ .objects("GET", "/repos/${slug.fullName}/releases", Release.fromJSON);
}
/// Fetches a single release.
@@ -588,7 +579,7 @@ class RepositoriesService extends Service {
return new PaginationHelper(_github).objects(
"GET",
"/repos/${slug.fullName}/stats/commit_activity",
- YearCommitCountWeek.fromJSON) as Stream<YearCommitCountWeek>;
+ YearCommitCountWeek.fromJSON);
}
/// Fetches weekly addition and deletion counts.
@@ -598,7 +589,7 @@ class RepositoriesService extends Service {
return new PaginationHelper(_github).objects(
"GET",
"/repos/${slug.fullName}/stats/code_frequency",
- WeeklyChangesCount.fromJSON) as Stream<WeeklyChangesCount>;
+ WeeklyChangesCount.fromJSON);
}
/// Fetches Participation Breakdowns.
@@ -612,10 +603,8 @@ class RepositoriesService extends Service {
///
/// API docs: https://developer.github.com/v3/repos/statistics/#punch-card
Stream<PunchcardEntry> listPunchcard(RepositorySlug slug) {
- return new PaginationHelper(_github).objects(
- "GET",
- "/repos/${slug.fullName}/stats/punchcard",
- PunchcardEntry.fromJSON) as Stream<PunchcardEntry>;
+ return new PaginationHelper(_github).objects("GET",
+ "/repos/${slug.fullName}/stats/punchcard", PunchcardEntry.fromJSON);
}
/// Lists the statuses of a repository at the specified reference.
@@ -626,7 +615,7 @@ class RepositoriesService extends Service {
return new PaginationHelper(_github).objects(
"GET",
"/repos/${slug.fullName}/commits/$ref/statuses",
- RepositoryStatus.fromJSON) as Stream<RepositoryStatus>;
+ RepositoryStatus.fromJSON);
}
/// Creates a new status for a repository at the specified reference.

MODIFY
lib/src/common/users_service.dart
lib/src/common/users_service.dart
@@ -85,13 +85,13 @@ class UsersService extends Service {
/// API docs: https://developer.github.com/v3/users/#get-all-users
Stream<User> listUsers({int pages, int since}) =>
new PaginationHelper(_github).objects("GET", "/users", User.fromJSON,
- pages: pages, params: {"since": since}) as Stream<User>;
+ pages: pages, params: {"since": since});
/// Lists all email addresses for the currently authenticated user.
///
/// API docs: https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user
Stream<UserEmail> listEmails() => new PaginationHelper(_github)
- .objects("GET", "/user/emails", UserEmail.fromJSON) as Stream<UserEmail>;
+ .objects("GET", "/user/emails", UserEmail.fromJSON);
/// Add Emails
///
@@ -99,7 +99,7 @@ class UsersService extends Service {
Stream<UserEmail> addEmails(List<String> emails) =>
new PaginationHelper(_github).objects(
"POST", "/user/emails", UserEmail.fromJSON,
- statusCode: 201, body: JSON.encode(emails)) as Stream<UserEmail>;
+ statusCode: 201, body: JSON.encode(emails));
/// Delete Emails
///
@@ -113,8 +113,7 @@ class UsersService extends Service {
///
/// API docs: https://developer.github.com/v3/users/followers/#list-followers-of-a-user
Stream<User> listUserFollowers(String user) => new PaginationHelper(_github)
- .objects("GET", "/users/$user/followers", User.fromJSON,
- statusCode: 200) as Stream<User>;
+ .objects("GET", "/users/$user/followers", User.fromJSON, statusCode: 200);
/// Check if the current user is following the specified user.
Future<bool> isFollowingUser(String user) =>
@@ -150,8 +149,7 @@ class UsersService extends Service {
///
/// API docs: https://developer.github.com/v3/users/followers/#list-followers-of-a-user
Stream<User> listCurrentUserFollowers() => new PaginationHelper(_github)
- .objects("GET", "/user/followers", User.fromJSON, statusCode: 200)
- as Stream<User>;
+ .objects("GET", "/user/followers", User.fromJSON, statusCode: 200);
/// Lists the verified public keys for a [userLogin]. If no [userLogin] is specified,
/// the public keys for the authenticated user are fetched.
@@ -161,7 +159,7 @@ class UsersService extends Service {
Stream<PublicKey> listPublicKeys([String userLogin]) {
var path = userLogin == null ? "/user/keys" : "/users/$userLogin/keys";
return new PaginationHelper(_github)
- .objects("GET", path, PublicKey.fromJSON) as Stream<PublicKey>;
+ .objects("GET", path, PublicKey.fromJSON);
}
// TODO: Implement getPublicKey: https://developer.github.com/v3/users/keys/#get-a-single-public-key

MODIFY
lib/src/common/util/pagination.dart
lib/src/common/util/pagination.dart
part of github.common;
/// Internal Helper for dealing with GitHub Pagination.
-class PaginationHelper<T> {
+class PaginationHelper {
final GitHub github;
PaginationHelper(this.github);
@@ -84,7 +84,7 @@ class PaginationHelper<T> {
}
}
- Stream<T> objects(String method, String path, JSONConverter<T> converter,
+ Stream<T> objects<T>(String method, String path, JSONConverter<T> converter,
{int pages,
Map<String, String> headers,
Map<String, dynamic> params,

More generic method fun