message: Use SDK v1.21 generic methods

diff:
@@ -180,11 +180,9 @@ class ActivityService extends Service {
/// Fetches the specified notification thread.
///
/// API docs: https://developer.github.com/v3/activity/notifications/#view-a-single-thread
- Future<Notification> getThread(String threadId) {
- return _github.getJSON("/notification/threads/${threadId}",
- statusCode: StatusCodes.OK,
- convert: Notification.fromJSON) as Future<Notification>;
- }
+ Future<Notification> getThread(String threadId) =>
+ _github.getJSON("/notification/threads/${threadId}",
+ statusCode: StatusCodes.OK, convert: Notification.fromJSON);
// TODO: Implement markThreadRead: https://developer.github.com/v3/activity/notifications/#mark-a-thread-as-read
// TODO: Implement getThreadSubscription: https://developer.github.com/v3/activity/notifications/#get-a-thread-subscription
@@ -276,12 +274,9 @@ class ActivityService extends Service {
///
/// API docs: https://developer.github.com/v3/activity/watching/#get-a-repository-subscription
Future<RepositorySubscription> getRepositorySubscription(
- RepositorySlug slug) {
- return _github.getJSON("/repos/${slug.fullName}/subscription",
- statusCode: StatusCodes.OK,
- convert: RepositorySubscription.fromJSON)
- as Future<RepositorySubscription>;
- }
+ RepositorySlug slug) =>
+ _github.getJSON("/repos/${slug.fullName}/subscription",
+ statusCode: StatusCodes.OK, convert: RepositorySubscription.fromJSON);
/// Sets the Repository Subscription Status
///

diff:
@@ -22,11 +22,9 @@ class AuthorizationsService extends Service {
/// Fetches an authorization specified by [id].
///
/// API docs: https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization
- Future<Authorization> getAuthorization(int id) {
- return _github.getJSON("/authorizations/${id}",
- statusCode: 200,
- convert: Authorization.fromJSON) as Future<Authorization>;
- }
+ Future<Authorization> getAuthorization(int id) =>
+ _github.getJSON("/authorizations/${id}",
+ statusCode: 200, convert: Authorization.fromJSON);
// TODO: Implement remaining API methods of authorizations:
// See https://developer.github.com/v3/oauth_authorizations/

diff:
@@ -43,10 +43,8 @@ class GistsService extends Service {
/// Fetches a Gist by the specified [id].
///
/// API docs: https://developer.github.com/v3/gists/#get-a-single-gist
- Future<Gist> getGist(String id) {
- return _github.getJSON("/gists/${id}",
- statusCode: StatusCodes.OK, convert: Gist.fromJSON) as Future<Gist>;
- }
+ Future<Gist> getGist(String id) => _github.getJSON("/gists/${id}",
+ statusCode: StatusCodes.OK, convert: Gist.fromJSON);
/// Creates a Gist
///

diff:
@@ -10,11 +10,9 @@ class GitService extends Service {
/// Fetches a blob from [slug] for a given [sha].
///
/// API docs: https://developer.github.com/v3/git/blobs/#get-a-blob
- Future<GitBlob> getBlob(RepositorySlug slug, String sha) {
- return _github.getJSON('/repos/${slug.fullName}/git/blobs/${sha}',
- convert: GitBlob.fromJSON,
- statusCode: StatusCodes.OK) as Future<GitBlob>;
- }
+ Future<GitBlob> getBlob(RepositorySlug slug, String sha) =>
+ _github.getJSON('/repos/${slug.fullName}/git/blobs/${sha}',
+ convert: GitBlob.fromJSON, statusCode: StatusCodes.OK);
/// Creates a blob with specified [blob] content.
///
@@ -29,11 +27,9 @@ class GitService extends Service {
/// Fetches a commit from [slug] for a given [sha].
///
/// API docs: https://developer.github.com/v3/git/commits/#get-a-commit
- Future<GitCommit> getCommit(RepositorySlug slug, String sha) {
- return _github.getJSON('/repos/${slug.fullName}/git/commits/${sha}',
- convert: GitCommit.fromJSON,
- statusCode: StatusCodes.OK) as Future<GitCommit>;
- }
+ Future<GitCommit> getCommit(RepositorySlug slug, String sha) =>
+ _github.getJSON('/repos/${slug.fullName}/git/commits/${sha}',
+ convert: GitCommit.fromJSON, statusCode: StatusCodes.OK);
/// Creates a new commit in a repository.
///
@@ -50,11 +46,9 @@ class GitService extends Service {
/// Note: The [ref] in the URL must be formatted as "heads/branch", not just "branch".
///
/// API docs: https://developer.github.com/v3/git/refs/#get-a-reference
- Future<GitReference> getReference(RepositorySlug slug, String ref) {
- return _github.getJSON('/repos/${slug.fullName}/git/refs/${ref}',
- convert: GitReference.fromJSON,
- statusCode: StatusCodes.OK) as Future<GitReference>;
- }
+ Future<GitReference> getReference(RepositorySlug slug, String ref) =>
+ _github.getJSON('/repos/${slug.fullName}/git/refs/${ref}',
+ convert: GitReference.fromJSON, statusCode: StatusCodes.OK);
/// Lists the references in a repository.
///
@@ -118,20 +112,18 @@ class GitService extends Service {
/// Fetches a tag from the repo given a SHA.
///
/// API docs: https://developer.github.com/v3/git/tags/#get-a-tag
- Future<GitTag> getTag(RepositorySlug slug, String sha) {
- return _github.getJSON('/repos/${slug.fullName}/git/tags/${sha}',
- convert: GitTag.fromJSON, statusCode: StatusCodes.OK) as Future<GitTag>;
- }
+ Future<GitTag> getTag(RepositorySlug slug, String sha) =>
+ _github.getJSON('/repos/${slug.fullName}/git/tags/${sha}',
+ convert: GitTag.fromJSON, statusCode: StatusCodes.OK);
/// Creates a new tag in a repository.
///
/// API docs: https://developer.github.com/v3/git/tags/#create-a-tag-object
- Future<GitTag> createTag(RepositorySlug slug, CreateGitTag tag) {
- return _github.postJSON('/repos/${slug.fullName}/git/tags',
+ Future<GitTag> createTag(RepositorySlug slug, CreateGitTag tag) =>
+ _github.postJSON('/repos/${slug.fullName}/git/tags',
convert: GitTag.fromJSON,
statusCode: StatusCodes.CREATED,
- body: tag.toJSON()) as Future<GitTag>;
- }
+ body: tag.toJSON());
/// Fetches a tree from a repository for the given ref [sha].
///
@@ -147,8 +139,7 @@ class GitService extends Service {
}
return _github.getJSON(path,
- convert: (j) => new GitTree.fromJson(j),
- statusCode: StatusCodes.OK) as Future<GitTree>;
+ convert: (j) => new GitTree.fromJson(j), statusCode: StatusCodes.OK);
}
/// Creates a new tree in a repository.

diff:
@@ -204,12 +204,12 @@ class GitHub {
/// [convert] is a simple function that is passed this [GitHub] instance and a JSON object.
/// The future will pass the object returned from this function to the then method.
/// The default [convert] function returns the input object.
- Future<dynamic> getJSON(String path,
+ Future<T> getJSON<T>(String path,
{int statusCode,
void fail(http.Response response),
Map<String, String> headers,
Map<String, String> params,
- JSONConverter convert,
+ JSONConverter<T> convert,
String preview}) async {
if (headers == null) headers = {};

diff:
@@ -138,10 +138,9 @@ class IssuesService extends Service {
/// Get an issue.
///
/// API docs: https://developer.github.com/v3/issues/#get-a-single-issue
- Future<Issue> get(RepositorySlug slug, int issueNumber) {
- return _github.getJSON("/repos/${slug.fullName}/issues/${issueNumber}",
- convert: Issue.fromJSON) as Future<Issue>;
- }
+ Future<Issue> get(RepositorySlug slug, int issueNumber) =>
+ _github.getJSON("/repos/${slug.fullName}/issues/${issueNumber}",
+ convert: Issue.fromJSON);
/// Create an issue.
///
@@ -202,10 +201,9 @@ class IssuesService extends Service {
/// Fetches the specified issue comment.
///
/// API docs: https://developer.github.com/v3/issues/comments/#get-a-single-comment
- Future<IssueComment> getComment(RepositorySlug slug, int id) {
- return _github.getJSON("/repos/${slug.fullName}/issues/comments/${id}",
- convert: IssueComment.fromJSON) as Future<IssueComment>;
- }
+ Future<IssueComment> getComment(RepositorySlug slug, int id) =>
+ _github.getJSON("/repos/${slug.fullName}/issues/comments/${id}",
+ convert: IssueComment.fromJSON);
/// Creates a new comment on the specified issue
///
@@ -245,11 +243,9 @@ class IssuesService extends Service {
/// Fetches a single label.
///
/// API docs: https://developer.github.com/v3/issues/labels/#get-a-single-label
- Future<IssueLabel> getLabel(RepositorySlug slug, String name) {
- return _github.getJSON("/repos/${slug.fullName}/labels/${name}",
- convert: IssueLabel.fromJSON,
- statusCode: StatusCodes.OK) as Future<IssueLabel>;
- }
+ Future<IssueLabel> getLabel(RepositorySlug slug, String name) =>
+ _github.getJSON("/repos/${slug.fullName}/labels/${name}",
+ convert: IssueLabel.fromJSON, statusCode: StatusCodes.OK);
/// Creates a new label on the specified repository.
///

diff:
@@ -27,10 +27,9 @@ class MiscService extends Service {
/// All template names can be fetched using [listGitignoreTemplates].
///
/// API docs: https://developer.github.com/v3/gitignore/#get-a-single-template
- Future<GitignoreTemplate> getGitignoreTemplate(String name) {
- return _github.getJSON("/gitignore/templates/${name}",
- convert: GitignoreTemplate.fromJSON) as Future<GitignoreTemplate>;
- }
+ Future<GitignoreTemplate> getGitignoreTemplate(String name) =>
+ _github.getJSON("/gitignore/templates/${name}",
+ convert: GitignoreTemplate.fromJSON);
/// Renders Markdown from the [input].
///
@@ -63,11 +62,9 @@ class MiscService extends Service {
}
/// Gets the GitHub API Status.
- Future<APIStatus> getApiStatus() {
- return _github.getJSON("https://status.github.com/api/status.json",
- statusCode: StatusCodes.OK,
- convert: APIStatus.fromJSON) as Future<APIStatus>;
- }
+ Future<APIStatus> getApiStatus() =>
+ _github.getJSON("https://status.github.com/api/status.json",
+ statusCode: StatusCodes.OK, convert: APIStatus.fromJSON);
/// Returns a stream of Octocats from Octodex.
///

diff:
@@ -24,15 +24,13 @@ class OrganizationsService extends Service {
/// Fetches the organization specified by [name].
///
/// API docs: https://developer.github.com/v3/orgs/#get-an-organization
- Future<Organization> get(String name) {
- return _github.getJSON("/orgs/${name}",
+ Future<Organization> get(String name) => _github.getJSON("/orgs/${name}",
convert: Organization.fromJSON,
statusCode: StatusCodes.OK, fail: (http.Response response) {
if (response.statusCode == 404) {
throw new OrganizationNotFound(_github, name);
}
- }) as Future<Organization>;
- }
+ });
/// Fetches the organizations specified by [names].
Stream<Organization> getMulti(List<String> names) {
@@ -287,11 +285,9 @@ class OrganizationsService extends Service {
/// Fetches a single hook by [id].
///
/// API docs: https://developer.github.com/v3/orgs/hooks/#get-single-hook
- Future<Hook> getHook(String org, int id) {
- return _github.getJSON("/orgs/${org}/hooks/${id}",
- convert: (Map<String, dynamic> i) => Hook.fromJSON(org, i))
- as Future<Hook>;
- }
+ Future<Hook> getHook(String org, int id) =>
+ _github.getJSON("/orgs/${org}/hooks/${id}",
+ convert: (Map<String, dynamic> i) => Hook.fromJSON(org, i));
/// Creates an organization hook based on the specified [hook].
///

diff:
@@ -16,11 +16,9 @@ class PullRequestsService extends Service {
/// Fetches a single pull request.
///
/// API docs: https://developer.github.com/v3/pulls/#get-a-single-pull-request
- Future<PullRequest> get(RepositorySlug slug, int number) {
- return _github.getJSON("/repos/${slug.fullName}/pulls/${number}",
- convert: PullRequest.fromJSON,
- statusCode: StatusCodes.OK) as Future<PullRequest>;
- }
+ Future<PullRequest> get(RepositorySlug slug, int number) =>
+ _github.getJSON("/repos/${slug.fullName}/pulls/${number}",
+ convert: PullRequest.fromJSON, statusCode: StatusCodes.OK);
/// Creates a Pull Request based on the given [request].
///

diff:
@@ -95,15 +95,14 @@ class RepositoriesService extends Service {
/// Fetches the repository specified by the [slug].
///
/// API docs: https://developer.github.com/v3/repos/#get
- Future<Repository> getRepository(RepositorySlug slug) {
- return _github.getJSON("/repos/${slug.owner}/${slug.name}",
+ Future<Repository> getRepository(RepositorySlug slug) =>
+ _github.getJSON("/repos/${slug.owner}/${slug.name}",
convert: Repository.fromJSON,
statusCode: StatusCodes.OK, fail: (http.Response response) {
if (response.statusCode == 404) {
throw new RepositoryNotFound(_github, slug.fullName);
}
- }) as Future<Repository>;
- }
+ });
/// Fetches a list of repositories specified by [slugs].
Stream<Repository> getRepositories(List<RepositorySlug> slugs) {
@@ -185,15 +184,15 @@ class RepositoriesService extends Service {
Future<LanguageBreakdown> listLanguages(RepositorySlug slug) =>
_github.getJSON("/repos/${slug.fullName}/languages",
statusCode: StatusCodes.OK,
- convert: (Map<String, int> input) => new LanguageBreakdown(input))
- as Future<LanguageBreakdown>;
+ convert: (Map<String, int> input) => new LanguageBreakdown(input));
/// Lists the tags of the specified repository.
///
/// 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))
+ as Stream<Tag>;
}
/// Lists the branches of the specified repository.
@@ -208,10 +207,9 @@ class RepositoriesService extends Service {
/// Fetches the specified branch.
///
/// API docs: https://developer.github.com/v3/repos/#get-branch
- Future<Branch> getBranch(RepositorySlug slug, String branch) {
- return _github.getJSON("/repos/${slug.fullName}/branches/${branch}",
- convert: Branch.fromJSON) as Future<Branch>;
- }
+ Future<Branch> getBranch(RepositorySlug slug, String branch) =>
+ _github.getJSON("/repos/${slug.fullName}/branches/${branch}",
+ convert: Branch.fromJSON);
/// Lists the users that have access to the repository identified by [slug].
///
@@ -265,10 +263,9 @@ class RepositoriesService extends Service {
/// Fetches the specified commit.
///
/// API docs: https://developer.github.com/v3/repos/commits/#get-a-single-commit
- Future<RepositoryCommit> getCommit(RepositorySlug slug, String sha) {
- return _github.getJSON("/repos/${slug.fullName}/commits/${sha}",
- convert: RepositoryCommit.fromJSON) as Future<RepositoryCommit>;
- }
+ Future<RepositoryCommit> getCommit(RepositorySlug slug, String sha) =>
+ _github.getJSON("/repos/${slug.fullName}/commits/${sha}",
+ convert: RepositoryCommit.fromJSON);
/// [refBase] and [refHead] can be the same value for a branch, commit, or ref
/// in [slug] or specify other repositories by using `repo:ref` syntax.
@@ -303,7 +300,7 @@ class RepositoriesService extends Service {
}
},
convert: (Map<String, dynamic> input) =>
- GitHubFile.fromJSON(input, slug)) as Future<GitHubFile>;
+ GitHubFile.fromJSON(input, slug));
}
/// Fetches content in a repository at the specified [path].
@@ -346,7 +343,7 @@ class RepositoriesService extends Service {
.toList();
}
return contents;
- }) as Future<RepositoryContents>;
+ });
}
/// Creates a new file in a repository.
@@ -441,11 +438,9 @@ class RepositoriesService extends Service {
/// Fetches a single hook by [id].
///
/// API docs: https://developer.github.com/v3/repos/hooks/#get-single-hook
- Future<Hook> getHook(RepositorySlug slug, int id) {
- return _github.getJSON("/repos/${slug.fullName}/hooks/${id}",
- convert: (Map<String, dynamic> i) =>
- Hook.fromJSON(slug.fullName, i)) as Future<Hook>;
- }
+ Future<Hook> getHook(RepositorySlug slug, int id) =>
+ _github.getJSON("/repos/${slug.fullName}/hooks/${id}",
+ convert: (Map<String, dynamic> i) => Hook.fromJSON(slug.fullName, i));
/// Creates a repository hook based on the specified [hook].
///
@@ -521,11 +516,9 @@ class RepositoriesService extends Service {
/// Fetches the GitHub pages information for the specified repository.
///
/// API docs: https://developer.github.com/v3/repos/pages/#get-information-about-a-pages-site
- Future<RepositoryPages> getPagesInfo(RepositorySlug slug) {
- return _github.getJSON("/repos/${slug.fullName}/pages",
- statusCode: 200,
- convert: RepositoryPages.fromJSON) as Future<RepositoryPages>;
- }
+ Future<RepositoryPages> getPagesInfo(RepositorySlug slug) =>
+ _github.getJSON("/repos/${slug.fullName}/pages",
+ statusCode: 200, convert: RepositoryPages.fromJSON);
// TODO: Implement listPagesBuilds: https://developer.github.com/v3/repos/pages/#list-pages-builds
// TODO: Implement getLatestPagesBuild: https://developer.github.com/v3/repos/pages/#list-latest-pages-build
@@ -542,10 +535,9 @@ class RepositoriesService extends Service {
/// Fetches a single release.
///
/// API docs: https://developer.github.com/v3/repos/releases/#get-a-single-release
- Future<Release> getRelease(RepositorySlug slug, int id) {
- return _github.getJSON("/repos/${slug.fullName}/releases/${id}",
- convert: Release.fromJSON) as Future<Release>;
- }
+ Future<Release> getRelease(RepositorySlug slug, int id) =>
+ _github.getJSON("/repos/${slug.fullName}/releases/${id}",
+ convert: Release.fromJSON);
/// Creates a Release based on the specified [release].
///
@@ -613,11 +605,9 @@ class RepositoriesService extends Service {
/// Fetches Participation Breakdowns.
///
/// API docs: https://developer.github.com/v3/repos/statistics/#participation
- Future<ContributorParticipation> getParticipation(RepositorySlug slug) {
- return _github.getJSON("/repos/${slug.fullName}/stats/participation",
- statusCode: 200, convert: ContributorParticipation.fromJSON)
- as Future<ContributorParticipation>;
- }
+ Future<ContributorParticipation> getParticipation(RepositorySlug slug) =>
+ _github.getJSON("/repos/${slug.fullName}/stats/participation",
+ statusCode: 200, convert: ContributorParticipation.fromJSON);
/// Fetches Punchcard.
///
@@ -655,9 +645,7 @@ class RepositoriesService extends Service {
///
/// API docs: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
Future<CombinedRepositoryStatus> getCombinedStatus(
- RepositorySlug slug, String ref) {
- return _github.getJSON("/repos/${slug.fullName}/commits/${ref}/status",
- convert: CombinedRepositoryStatus.fromJSON,
- statusCode: 200) as Future<CombinedRepositoryStatus>;
- }
+ RepositorySlug slug, String ref) =>
+ _github.getJSON("/repos/${slug.fullName}/commits/${ref}/status",
+ convert: CombinedRepositoryStatus.fromJSON, statusCode: 200);
}

diff:
@@ -11,7 +11,7 @@ class UsersService extends Service {
///
/// API docs: https://developer.github.com/v3/users/#get-a-single-user
Future<User> getUser(String name) =>
- _github.getJSON("/users/${name}", convert: User.fromJSON) as Future<User>;
+ _github.getJSON("/users/${name}", convert: User.fromJSON);
/// Updates the Current User.
///
@@ -65,14 +65,13 @@ class UsersService extends Service {
/// Throws [AccessForbidden] if we are not authenticated.
///
/// API docs: https://developer.github.com/v3/users/#get-the-authenticated-user
- Future<CurrentUser> getCurrentUser() {
- return _github.getJSON("/user", statusCode: StatusCodes.OK,
+ Future<CurrentUser> getCurrentUser() =>
+ _github.getJSON("/user", statusCode: StatusCodes.OK,
fail: (http.Response response) {
if (response.statusCode == StatusCodes.FORBIDDEN) {
throw new AccessForbidden(_github);
}
- }, convert: CurrentUser.fromJSON) as Future<CurrentUser>;
- }
+ }, convert: CurrentUser.fromJSON);
/// Checks if a user exists.
Future<bool> isUser(String name) => _github

diff:
@@ -4,7 +4,7 @@ author: Kenneth Endfinger <kaendfinger@gmail.com>
description: GitHub API Client Library
homepage: https://github.com/DirectMyFile/github.dart
environment:
- sdk: '>=1.13.0 <2.0.0'
+ sdk: '>=1.21.0 <2.0.0'
dependencies:
html: '>=0.12.0 <0.14.0'
http: '^0.11.3'

original_message: Use SDK v1.21 generic methods


message: More generic method fun

change_type: MODIFY

diff:
@@ -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);
}

diff:
@@ -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].

diff:
@@ -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

diff:
@@ -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.

diff:
@@ -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

diff:
@@ -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].

diff:
@@ -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.

diff:
@@ -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.

diff:
@@ -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

diff:
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,

license: MIT License

original_message: More generic method fun


message: make tool/build.dart executable

diff:
+#!/usr/bin/env dart --checked
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.

original_message: make tool/build.dart executable


message: Update to latest json_serializable and source_gen

diff:
@@ -9,7 +9,7 @@ import "package:html/dom.dart" as html;
import "package:html/parser.dart" as html_parser;
import "package:http/http.dart" as http;
import "package:quiver/async.dart" show FutureGroup;
-import "package:source_gen/generators/json_serializable.dart";
+import "package:json_serializable/annotations.dart";
import "package:xml/xml.dart" as xml;
import 'util.dart';

diff:
@@ -4,23 +4,20 @@ part of github.common;
// **************************************************************************
// Generator: JsonSerializableGenerator
-// Target: class GitTree
// **************************************************************************
-GitTree _$GitTreeFromJson(Map json) => new GitTree(
+GitTree _$GitTreeFromJson(Map<String, dynamic> json) => new GitTree(
json['sha'] as String,
json['url'] as String,
json['truncated'] as bool,
(json['tree'] as List)
- ?.map((v0) => v0 == null ? null : new GitTreeEntry.fromJson(v0))
+ ?.map((e) => e == null
+ ? null
+ : new GitTreeEntry.fromJson(e as Map<String, dynamic>))
?.toList());
-// **************************************************************************
-// Generator: JsonSerializableGenerator
-// Target: class GitTreeEntry
-// **************************************************************************
-
-GitTreeEntry _$GitTreeEntryFromJson(Map json) => new GitTreeEntry(
+GitTreeEntry _$GitTreeEntryFromJson(Map<String, dynamic> json) =>
+ new GitTreeEntry(
json['path'] as String,
json['mode'] as String,
json['type'] as String,
@@ -28,80 +25,53 @@ GitTreeEntry _$GitTreeEntryFromJson(Map json) => new GitTreeEntry(
json['sha'] as String,
json['url'] as String);
-// **************************************************************************
-// Generator: JsonSerializableGenerator
-// Target: class GitHubComparison
-// **************************************************************************
-
-GitHubComparison _$GitHubComparisonFromJson(Map json) => new GitHubComparison(
+GitHubComparison _$GitHubComparisonFromJson(Map<String, dynamic> json) =>
+ new GitHubComparison(
json['url'] as String,
json['status'] as String,
json['ahead_by'] as int,
json['behind_by'] as int,
json['total_commits'] as int);
-// **************************************************************************
-// Generator: JsonSerializableGenerator
-// Target: class Tag
-// **************************************************************************
-
-Tag _$TagFromJson(Map json) => new Tag(
+Tag _$TagFromJson(Map<String, dynamic> json) => new Tag(
json['name'] as String,
- json['commit'] == null ? null : new CommitInfo.fromJson(json['commit']),
+ json['commit'] == null
+ ? null
+ : new CommitInfo.fromJson(json['commit'] as Map<String, dynamic>),
json['zipball_url'] as String,
json['tarball_url'] as String);
-// **************************************************************************
-// Generator: JsonSerializableGenerator
-// Target: class CommitData
-// **************************************************************************
-
-CommitData _$CommitDataFromJson(Map json) => new CommitData(
+CommitData _$CommitDataFromJson(Map<String, dynamic> json) => new CommitData(
json['sha'] as String,
json['commit'] == null ? null : new GitCommit.fromJson(json['commit']),
json['url'] as String,
json['html_url'] as String,
json['comments_url'] as String,
- json['author'] == null ? null : new CommitDataUser.fromJson(json['author']),
+ json['author'] == null
+ ? null
+ : new CommitDataUser.fromJson(json['author'] as Map<String, dynamic>),
json['committer'] == null
? null
- : new CommitDataUser.fromJson(json['committer']),
- (json['parents'] as List)
- ?.map((v0) => v0 as Map<String, dynamic>)
- ?.toList());
+ : new CommitDataUser.fromJson(
+ json['committer'] as Map<String, dynamic>),
+ (json['parents'] as List)?.map((e) => e as Map<String, dynamic>)?.toList());
-// **************************************************************************
-// Generator: JsonSerializableGenerator
-// Target: class CommitDataUser
-// **************************************************************************
-
-CommitDataUser _$CommitDataUserFromJson(Map json) => new CommitDataUser(
+CommitDataUser _$CommitDataUserFromJson(Map<String, dynamic> json) =>
+ new CommitDataUser(
json['login'] as String, json['id'] as int, json['type'] as String);
-// **************************************************************************
-// Generator: JsonSerializableGenerator
-// Target: class CommitInfo
-// **************************************************************************
-
-CommitInfo _$CommitInfoFromJson(Map json) => new CommitInfo(
+CommitInfo _$CommitInfoFromJson(Map<String, dynamic> json) => new CommitInfo(
json['sha'] as String,
- json['tree'] == null ? null : new GitTree.fromJson(json['tree']));
-
-// **************************************************************************
-// Generator: JsonSerializableGenerator
-// Target: class UserInformation
-// **************************************************************************
+ json['tree'] == null
+ ? null
+ : new GitTree.fromJson(json['tree'] as Map<String, dynamic>));
-UserInformation _$UserInformationFromJson(Map json) => new UserInformation(
- json['login'] as String,
- json['id'] as int,
- json['avatar_url'] as String,
- json['html_url'] as String);
+UserInformation _$UserInformationFromJson(Map<String, dynamic> json) =>
+ new UserInformation(json['login'] as String, json['id'] as int,
+ json['avatar_url'] as String, json['html_url'] as String);
-// **************************************************************************
-// Generator: JsonSerializableGenerator
-// Target: class Branch
-// **************************************************************************
-
-Branch _$BranchFromJson(Map json) => new Branch(json['name'] as String,
- json['commit'] == null ? null : new CommitData.fromJson(json['commit']));
+Branch _$BranchFromJson(Map<String, dynamic> json) => new Branch(
+ json['name'] as String,
+ json['commit'] == null
+ ? null
+ : new CommitData.fromJson(json['commit'] as Map<String, dynamic>));

diff:
@@ -164,7 +164,7 @@ class GitTree {
/// GitHub's maximum limit.
final bool truncated;
- @JsonKey("tree")
+ @JsonKey(name: "tree")
final List<GitTreeEntry> entries;
GitTree(this.sha, this.url, this.truncated, this.entries);

diff:
@@ -6,13 +6,13 @@ class GitHubComparison {
final String status;
- @JsonKey('ahead_by')
+ @JsonKey(name: 'ahead_by')
final int aheadBy;
- @JsonKey('behind_by')
+ @JsonKey(name: 'behind_by')
final int behindBy;
- @JsonKey('total_commits')
+ @JsonKey(name: 'total_commits')
final int totalCommits;
GitHubComparison(
@@ -206,9 +206,9 @@ class Tag {
final String name;
final CommitInfo commit;
- @JsonKey('zipball_url')
+ @JsonKey(name: 'zipball_url')
final String zipUrl;
- @JsonKey('tarball_url')
+ @JsonKey(name: 'tarball_url')
final String tarUrl;
Tag(this.name, this.commit, this.zipUrl, this.tarUrl);
@@ -225,13 +225,13 @@ class CommitData {
final String sha;
final GitCommit commit;
- @JsonKey("url")
+ @JsonKey(name: "url")
final String url;
- @JsonKey("html_url")
+ @JsonKey(name: "html_url")
final String htmlUrl;
- @JsonKey("comments_url")
+ @JsonKey(name: "comments_url")
final String commentsUrl;
final CommitDataUser author, committer;
@@ -277,11 +277,11 @@ class UserInformation {
final int id;
/// Avatar Url
- @JsonKey("avatar_url")
+ @JsonKey(name: "avatar_url")
final String avatarUrl;
/// Url to the user's GitHub Profile
- @JsonKey("html_url")
+ @JsonKey(name: "html_url")
final String htmlUrl;
UserInformation(this.login, this.id, this.avatarUrl, this.htmlUrl);

diff:
import 'package:build_runner/build_runner.dart';
+import 'package:json_serializable/generators.dart';
import 'package:source_gen/source_gen.dart';
-import 'package:source_gen/generators/json_serializable_generator.dart';
final PhaseGroup phases = new PhaseGroup.singleAction(
- new GeneratorBuilder(const [
+ new PartBuilder(const [
const JsonSerializableGenerator(),
]),
new InputSet('github', const ['lib/src/common.dart']));


message: Support the latest pkg/quiver, require the latest pkg/build_runner

diff:
@@ -10,5 +10,5 @@ import 'package:build_runner/build_runner.dart';
import 'phases.dart';
Future main() async {
- await build(phases, deleteFilesByDefault: true);
+ await build(buildActions, deleteFilesByDefault: true);
}

diff:
@@ -2,8 +2,11 @@ import 'package:build_runner/build_runner.dart';
import 'package:json_serializable/generators.dart';
import 'package:source_gen/source_gen.dart';
-final PhaseGroup phases = new PhaseGroup.singleAction(
+final buildActions = <BuildAction>[
+ new BuildAction(
new PartBuilder(const [
const JsonSerializableGenerator(),
]),
- new InputSet('github', const ['lib/src/common.dart']));
+ 'github',
+ inputs: ['lib/src/common.dart'])
+];

diff:
@@ -7,5 +7,5 @@ import 'package:build_runner/build_runner.dart';
import 'phases.dart';
void main() {
- watch(phases, deleteFilesByDefault: true);
+ watch(buildActions, deleteFilesByDefault: true);
}


message:
Use latest json_serializable and json_annotation
Separates dev and runtime dependencies

diff:
@@ -9,7 +9,7 @@ import "package:html/dom.dart" as html;
import "package:html/parser.dart" as html_parser;
import "package:http/http.dart" as http;
import "package:quiver/async.dart" show FutureGroup;
-import "package:json_serializable/annotations.dart";
+import "package:json_annotation/json_annotation.dart";
import "package:xml/xml.dart" as xml;
import 'util.dart';


diff:
@@ -6,7 +6,8 @@ part of github.common;
// Generator: JsonSerializableGenerator
// **************************************************************************
-GitTree _$GitTreeFromJson(Map<String, dynamic> json) => new GitTree(
+GitTree _$GitTreeFromJson(Map<String, dynamic> json) {
+ return new GitTree(
json['sha'] as String,
json['url'] as String,
json['truncated'] as bool,
@@ -15,33 +16,39 @@ GitTree _$GitTreeFromJson(Map<String, dynamic> json) => new GitTree(
? null
: new GitTreeEntry.fromJson(e as Map<String, dynamic>))
?.toList());
+}
-GitTreeEntry _$GitTreeEntryFromJson(Map<String, dynamic> json) =>
- new GitTreeEntry(
+GitTreeEntry _$GitTreeEntryFromJson(Map<String, dynamic> json) {
+ return new GitTreeEntry(
json['path'] as String,
json['mode'] as String,
json['type'] as String,
json['size'] as int,
json['sha'] as String,
json['url'] as String);
+}
-GitHubComparison _$GitHubComparisonFromJson(Map<String, dynamic> json) =>
- new GitHubComparison(
+GitHubComparison _$GitHubComparisonFromJson(Map<String, dynamic> json) {
+ return new GitHubComparison(
json['url'] as String,
json['status'] as String,
json['ahead_by'] as int,
json['behind_by'] as int,
json['total_commits'] as int);
+}
-Tag _$TagFromJson(Map<String, dynamic> json) => new Tag(
+Tag _$TagFromJson(Map<String, dynamic> json) {
+ return new Tag(
json['name'] as String,
json['commit'] == null
? null
: new CommitInfo.fromJson(json['commit'] as Map<String, dynamic>),
json['zipball_url'] as String,
json['tarball_url'] as String);
+}
-CommitData _$CommitDataFromJson(Map<String, dynamic> json) => new CommitData(
+CommitData _$CommitDataFromJson(Map<String, dynamic> json) {
+ return new CommitData(
json['sha'] as String,
json['commit'] == null ? null : new GitCommit.fromJson(json['commit']),
json['url'] as String,
@@ -54,24 +61,33 @@ CommitData _$CommitDataFromJson(Map<String, dynamic> json) => new CommitData(
? null
: new CommitDataUser.fromJson(
json['committer'] as Map<String, dynamic>),
- (json['parents'] as List)?.map((e) => e as Map<String, dynamic>)?.toList());
+ (json['parents'] as List)
+ ?.map((e) => e as Map<String, dynamic>)
+ ?.toList());
+}
-CommitDataUser _$CommitDataUserFromJson(Map<String, dynamic> json) =>
- new CommitDataUser(
+CommitDataUser _$CommitDataUserFromJson(Map<String, dynamic> json) {
+ return new CommitDataUser(
json['login'] as String, json['id'] as int, json['type'] as String);
+}
-CommitInfo _$CommitInfoFromJson(Map<String, dynamic> json) => new CommitInfo(
+CommitInfo _$CommitInfoFromJson(Map<String, dynamic> json) {
+ return new CommitInfo(
json['sha'] as String,
json['tree'] == null
? null
: new GitTree.fromJson(json['tree'] as Map<String, dynamic>));
+}
-UserInformation _$UserInformationFromJson(Map<String, dynamic> json) =>
- new UserInformation(json['login'] as String, json['id'] as int,
+UserInformation _$UserInformationFromJson(Map<String, dynamic> json) {
+ return new UserInformation(json['login'] as String, json['id'] as int,
json['avatar_url'] as String, json['html_url'] as String);
+}
-Branch _$BranchFromJson(Map<String, dynamic> json) => new Branch(
+Branch _$BranchFromJson(Map<String, dynamic> json) {
+ return new Branch(
json['name'] as String,
json['commit'] == null
? null
: new CommitData.fromJson(json['commit'] as Map<String, dynamic>));
+}

change_type: DELETE

diff:
-#!/usr/bin/env dart --checked
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'dart:async';
-
-import 'package:build_runner/build_runner.dart';
-
-import 'phases.dart';
-
-Future main() async {
- await build(buildActions, deleteFilesByDefault: true);
-}

diff:
-import 'package:build_runner/build_runner.dart';
-import 'package:json_serializable/generators.dart';
-import 'package:source_gen/source_gen.dart';
-
-final buildActions = <BuildAction>[
- new BuildAction(
- new PartBuilder(const [
- const JsonSerializableGenerator(),
- ]),
- 'github',
- inputs: ['lib/src/common.dart'])
-];

diff:
-// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-import 'package:build_runner/build_runner.dart';
-
-import 'phases.dart';
-
-void main() {
- watch(buildActions, deleteFilesByDefault: true);
-}

original_message: Upgrade dependencies, regenerate code with latest json_serializable (#104)


message:
cleanup: eliminate a lot of type errors and casts
Generic type params FTW

diff:
@@ -280,7 +280,7 @@ class ActivityService extends Service {
return _github.postJSON("/repos/${slug.fullName}/subscription",
statusCode: StatusCodes.OK,
convert: RepositorySubscription.fromJSON,
- body: map) as Future<RepositorySubscription>;
+ body: map);
}
/// Deletes a Repository Subscription

diff:
@@ -68,9 +68,7 @@ class GistsService extends Service {
map["files"] = f;
return _github.postJSON("/gists",
- statusCode: 201,
- body: JSON.encode(map),
- convert: Gist.fromJSON) as Future<Gist>;
+ statusCode: 201, body: JSON.encode(map), convert: Gist.fromJSON);
}
/// Deletes the specified Gist.
@@ -102,9 +100,7 @@ class GistsService extends Service {
}
return _github.postJSON("/gists/$id",
- statusCode: 200,
- body: JSON.encode(map),
- convert: Gist.fromJSON) as Future<Gist>;
+ statusCode: 200, body: JSON.encode(map), convert: Gist.fromJSON);
}
// TODO: Implement listGistCommits: https://developer.github.com/v3/gists/#list-gist-commits
@@ -164,8 +160,7 @@ class GistsService extends Service {
/// API docs: https://developer.github.com/v3/gists/comments/#create-a-comment
Future<GistComment> createComment(String gistId, CreateGistComment request) {
return _github.postJSON("/gists/$gistId/comments",
- body: request.toJSON(),
- convert: GistComment.fromJSON) as Future<GistComment>;
+ body: request.toJSON(), convert: GistComment.fromJSON);
}
// TODO: Implement editComment: https://developer.github.com/v3/gists/comments/#edit-a-comment

diff:
@@ -21,7 +21,7 @@ class GitService extends Service {
return _github.postJSON('/repos/${slug.fullName}/git/blobs',
convert: GitBlob.fromJSON,
statusCode: StatusCodes.CREATED,
- body: blob.toJSON()) as Future<GitBlob>;
+ body: blob.toJSON());
}
/// Fetches a commit from [slug] for a given [sha].
@@ -38,7 +38,7 @@ class GitService extends Service {
return _github.postJSON('/repos/${slug.fullName}/git/commits',
convert: GitCommit.fromJSON,
statusCode: StatusCodes.CREATED,
- body: commit.toJSON()) as Future<GitCommit>;
+ body: commit.toJSON());
}
/// Fetches a reference from a repository for the given [ref].
@@ -78,7 +78,7 @@ class GitService extends Service {
return _github.postJSON('/repos/${slug.fullName}/git/refs',
convert: GitReference.fromJSON,
statusCode: StatusCodes.CREATED,
- body: JSON.encode({'ref': ref, 'sha': sha})) as Future<GitReference>;
+ body: JSON.encode({'ref': ref, 'sha': sha}));
}
/// Updates a reference in a repository.
@@ -149,6 +149,6 @@ class GitService extends Service {
return _github.postJSON('/repos/${slug.fullName}/git/trees',
convert: (j) => new GitTree.fromJson(j),
statusCode: StatusCodes.CREATED,
- body: tree.toJSON()) as Future<GitTree>;
+ body: tree.toJSON());
}
}

diff:
@@ -204,12 +204,12 @@ class GitHub {
/// [convert] is a simple function that is passed this [GitHub] instance and a JSON object.
/// The future will pass the object returned from this function to the then method.
/// The default [convert] function returns the input object.
- Future<T> getJSON<T>(String path,
+ Future<T> getJSON<S, T>(String path,
{int statusCode,
void fail(http.Response response),
Map<String, String> headers,
Map<String, String> params,
- JSONConverter<T> convert,
+ JSONConverter<S, T> convert,
String preview}) async {
if (headers == null) headers = {};
@@ -218,7 +218,7 @@ class GitHub {
}
if (convert == null) {
- convert = (input) => input;
+ convert = (input) => input as T;
}
headers.putIfAbsent("Accept", () => "application/vnd.github.v3+json");
@@ -261,12 +261,12 @@ class GitHub {
/// The future will pass the object returned from this function to the then method.
/// The default [convert] function returns the input object.
/// [body] is the data to send to the server.
- Future<dynamic> postJSON(String path,
+ Future<T> postJSON<S, T>(String path,
{int statusCode,
void fail(http.Response response),
Map<String, String> headers,
Map<String, String> params,
- JSONConverter convert,
+ JSONConverter<S, T> convert,
String body,
String preview}) async {
if (headers == null) headers = {};
@@ -276,7 +276,7 @@ class GitHub {
}
if (convert == null) {
- convert = (input) => input;
+ convert = (input) => input as T;
}
headers.putIfAbsent("Accept", () => "application/vnd.github.v3+json");

diff:
@@ -211,7 +211,7 @@ class IssuesService extends Service {
'/repos/${slug.fullName}/issues/$issueNumber/comments',
body: it,
convert: IssueComment.fromJSON,
- statusCode: StatusCodes.CREATED) as Future<IssueComment>;
+ statusCode: StatusCodes.CREATED);
}
// TODO: Implement editComment: https://developer.github.com/v3/issues/comments/#edit-a-comment
@@ -249,7 +249,7 @@ class IssuesService extends Service {
RepositorySlug slug, String name, String color) {
return _github.postJSON("/repos/${slug.fullName}/labels",
body: JSON.encode({"name": name, "color": color}),
- convert: IssueLabel.fromJSON) as Future<IssueLabel>;
+ convert: IssueLabel.fromJSON);
}
/// Edits a label.
@@ -258,7 +258,7 @@ class IssuesService extends Service {
Future<IssueLabel> editLabel(RepositorySlug slug, String name, String color) {
return _github.postJSON("/repos/${slug.fullName}/labels/$name",
body: JSON.encode({"name": name, "color": color}),
- convert: IssueLabel.fromJSON) as Future<IssueLabel>;
+ convert: IssueLabel.fromJSON);
}
/// Deletes a label.
@@ -347,8 +347,7 @@ class IssuesService extends Service {
Future<Milestone> createMilestone(
RepositorySlug slug, CreateMilestone request) {
return _github.postJSON("/repos/${slug.fullName}/milestones",
- body: JSON.encode(request.toJSON()),
- convert: Milestone.fromJSON) as Future<Milestone>;
+ body: JSON.encode(request.toJSON()), convert: Milestone.fromJSON);
}
// TODO: Implement editMilestone: https://developer.github.com/v3/issues/milestones/#update-a-milestone

diff:
@@ -109,7 +109,7 @@ class OrganizationsService extends Service {
statusCode: 201,
convert: Team.fromJSON,
// TODO: This is probably wrong, map needs to be json encoded?
- body: map) as Future<Team>;
+ body: map);
}
/// Edits a Team.
@@ -124,7 +124,7 @@ class OrganizationsService extends Service {
statusCode: 200,
convert: Team.fromJSON,
// TODO: This is probably wrong, map needs to be json encoded?
- body: map) as Future<Team>;
+ body: map);
}
/// Deletes the team specified by the [teamId]
@@ -295,7 +295,7 @@ class OrganizationsService extends Service {
Future<Hook> createHook(String org, CreateHook hook) {
return _github.postJSON("/orgs/$org/hooks",
convert: (Map<String, dynamic> i) => Hook.fromJSON(org, i),
- body: hook.toJSON()) as Future<Hook>;
+ body: hook.toJSON());
}
// TODO: Implement editHook: https://developer.github.com/v3/orgs/hooks/#edit-a-hook

diff:
@@ -42,8 +42,7 @@ class PullRequestsService extends Service {
Future<PullRequestInformation> create(
RepositorySlug slug, CreatePullRequest request) {
return _github.postJSON("/repos/${slug.fullName}/pulls",
- convert: PullRequestInformation.fromJSON,
- body: request.toJSON()) as Future<PullRequestInformation>;
+ convert: PullRequestInformation.fromJSON, body: request.toJSON());
}
/// Edit a pull request.

diff:
@@ -82,12 +82,10 @@ class RepositoriesService extends Service {
{String org}) {
if (org != null) {
return _github.postJSON('/orgs/$org/repos',
- body: repository.toJSON(),
- convert: TeamRepository.fromJSON) as Future<Repository>;
+ body: repository.toJSON(), convert: TeamRepository.fromJSON);
} else {
return _github.postJSON('/user/repos',
- body: repository.toJSON(),
- convert: Repository.fromJSON) as Future<Repository>;
+ body: repository.toJSON(), convert: Repository.fromJSON);
}
}
@@ -183,7 +181,7 @@ class RepositoriesService extends Service {
Future<LanguageBreakdown> listLanguages(RepositorySlug slug) =>
_github.getJSON("/repos/${slug.fullName}/languages",
statusCode: StatusCodes.OK,
- convert: (Map<String, int> input) => new LanguageBreakdown(input));
+ convert: (input) => new LanguageBreakdown(input));
/// Lists the tags of the specified repository.
///
@@ -367,7 +365,7 @@ class RepositoriesService extends Service {
// TODO: map probably needs to be json encoded
body: map,
statusCode: 200,
- convert: ContentCreation.fromJSON) as Future<ContentCreation>;
+ convert: ContentCreation.fromJSON);
}
/// Deletes the specified file.
@@ -413,8 +411,7 @@ class RepositoriesService extends Service {
Future<Repository> createFork(RepositorySlug slug, [CreateFork fork]) {
if (fork == null) fork = new CreateFork();
return _github.postJSON("/repos/${slug.fullName}/forks",
- body: fork.toJSON(),
- convert: Repository.fromJSON) as Future<Repository>;
+ body: fork.toJSON(), convert: Repository.fromJSON);
}
/// Lists the hooks of the specified repository.
@@ -440,7 +437,7 @@ class RepositoriesService extends Service {
Future<Hook> createHook(RepositorySlug slug, CreateHook hook) {
return _github.postJSON("/repos/${slug.fullName}/hooks",
convert: (Map<String, dynamic> i) => Hook.fromJSON(slug.fullName, i),
- body: hook.toJSON()) as Future<Hook>;
+ body: hook.toJSON());
}
// TODO: Implement editHook: https://developer.github.com/v3/repos/hooks/#edit-a-hook
@@ -501,7 +498,7 @@ class RepositoriesService extends Service {
return _github.postJSON("/repos/${slug.fullName}/merges",
body: merge.toJSON(),
convert: RepositoryCommit.fromJSON,
- statusCode: 201) as Future<RepositoryCommit>;
+ statusCode: 201);
}
/// Fetches the GitHub pages information for the specified repository.
@@ -625,8 +622,7 @@ class RepositoriesService extends Service {
Future<RepositoryStatus> createStatus(
RepositorySlug slug, String ref, CreateStatus request) {
return _github.postJSON("/repos/${slug.fullName}/statuses/$ref",
- body: request.toJSON(),
- convert: RepositoryStatus.fromJSON) as Future<RepositoryStatus>;
+ body: request.toJSON(), convert: RepositoryStatus.fromJSON);
}
/// Gets a Combined Status for the specified repository and ref.

diff:
@@ -39,11 +39,9 @@ class SearchService extends Service {
return;
}
- List<dynamic> items = input['items'];
+ var items = input['items'] as List;
- items
- .map((Map<String, dynamic> item) => Repository.fromJSON(item))
- .forEach(controller.add);
+ items.map((item) => Repository.fromJSON(item)).forEach(controller.add);
}).onDone(controller.close);
return controller.stream;
@@ -87,11 +85,9 @@ class SearchService extends Service {
return;
}
- List<dynamic> items = input['items'];
+ var items = input['items'] as List;
- items
- .map((Map<String, dynamic> item) => User.fromJSON(item))
- .forEach(controller.add);
+ items.map((item) => User.fromJSON(item)).forEach(controller.add);
}).onDone(controller.close);
return controller.stream;

diff:
@@ -38,7 +38,7 @@ class UsersService extends Service {
// TODO: map probably needs to be JSON encoded.
body: map,
statusCode: 200,
- convert: CurrentUser.fromJSON) as Future<CurrentUser>;
+ convert: CurrentUser.fromJSON);
}
/// Fetches a list of users specified by [names].

diff:
part of github.common;
/// Creates a Model Object from the JSON [input]
-typedef T JSONConverter<T>(dynamic input);
+typedef T JSONConverter<S, T>(S input);

diff:
@@ -84,7 +84,8 @@ class PaginationHelper {
}
}
- Stream<T> objects<T>(String method, String path, JSONConverter<T> converter,
+ Stream<T> objects<S, T>(
+ String method, String path, JSONConverter<S, T> converter,
{int pages,
Map<String, String> headers,
Map<String, dynamic> params,


message: cleanup: dartfmt example directory

diff:
@@ -21,11 +21,9 @@ void loadCat() {
var index = random.nextInt(cats.length);
var cat = cats[index];
print("Selected Octocat at ${index} (${cat.name})");
- $octocat.appendHtml(
- """
+ $octocat.appendHtml("""

${cat.name}

- """,
- treeSanitizer: NodeTreeSanitizer.trusted);
+ """, treeSanitizer: NodeTreeSanitizer.trusted);
});
}

diff:
@@ -19,13 +19,11 @@ void loadReleases() {
.toList()
.then((releases) {
for (var release in releases) {
- releasesDiv.appendHtml(
- """
+ releasesDiv.appendHtml("""

${release.name}

- """,
- treeSanitizer: NodeTreeSanitizer.trusted);
+ """, treeSanitizer: NodeTreeSanitizer.trusted);
var rel = releasesDiv.querySelector("#release-${release.id}");
void append(String key, String value) {
if (value == null) return;

diff:
@@ -54,8 +54,7 @@ void updateRepos(List<Repository> repos,
document.querySelector("#repos").children.clear();
repos.sort(compare);
for (var repo in repos) {
- repositoriesDiv.appendHtml(
- """
+ repositoriesDiv.appendHtml("""

${repo.name}

@@ -73,8 +72,7 @@ void updateRepos(List<Repository> repos,
Size: ${repo.size} bytes

- """,
- treeSanitizer: NodeTreeSanitizer.trusted);
+ """, treeSanitizer: NodeTreeSanitizer.trusted);
}
}

original_message: cleanup: dartfmt example directory


message: fix: fix type error in explore_service

diff:
@@ -61,7 +61,7 @@ class ExploreService extends Service {
var description = page.querySelector(".collection-description");
// TODO: This is most likely wrong
- showcase.description = description;
+ showcase.description = description.text;
showcase.lastUpdated = lastUpdated;
showcase.title = title;
showcase.items = [];

diff:
@@ -57,7 +57,7 @@ class PaginationHelper {
} while (true);
}
- Stream jsonObjects(String method, String path,
+ Stream<T> jsonObjects<T>(String method, String path,
{int pages,
Map<String, String> headers,
Map<String, dynamic> params,
@@ -79,7 +79,7 @@ class PaginationHelper {
var json = jsonDecode(response.body) as List;
for (var item in json) {
- yield item;
+ yield item as T;
}
}
}

original_message: fix: fix type error in explore_service


message: Update generated code for latest release of source_gen


message: add getLicense to repo service

diff:
@@ -91,3 +91,102 @@ Branch _$BranchFromJson(Map<String, dynamic> json) {
? null
: new CommitData.fromJson(json['commit'] as Map<String, dynamic>));
}
+
+LicenseDetails _$LicenseDetailsFromJson(Map<String, dynamic> json) {
+ return new LicenseDetails(
+ name: json['name'] as String,
+ path: json['path'] as String,
+ sha: json['sha'] as String,
+ size: json['size'] as int,
+ url: json['url'] == null ? null : Uri.parse(json['url'] as String),
+ htmlUrl: json['html_url'] == null
+ ? null
+ : Uri.parse(json['html_url'] as String),
+ gitUrl:
+ json['git_url'] == null ? null : Uri.parse(json['git_url'] as String),
+ downloadUrl: json['download_url'] == null
+ ? null
+ : Uri.parse(json['download_url'] as String),
+ type: json['type'] as String,
+ content: json['content'] as String,
+ encoding: json['encoding'] as String,
+ links: json['_links'] == null
+ ? null
+ : new Links.fromJson(json['_links'] as Map<String, dynamic>),
+ license: json['license'] == null
+ ? null
+ : new LicenseKind.fromJson(json['license'] as Map<String, dynamic>));
+}
+
+abstract class _$LicenseDetailsSerializerMixin {
+ String get name;
+ String get path;
+ String get sha;
+ int get size;
+ Uri get url;
+ Uri get htmlUrl;
+ Uri get gitUrl;
+ Uri get downloadUrl;
+ String get type;
+ String get content;
+ String get encoding;
+ Links get links;
+ LicenseKind get license;
+ Map<String, dynamic> toJson() => <String, dynamic>{
+ 'name': name,
+ 'path': path,
+ 'sha': sha,
+ 'size': size,
+ 'url': url?.toString(),
+ 'html_url': htmlUrl?.toString(),
+ 'git_url': gitUrl?.toString(),
+ 'download_url': downloadUrl?.toString(),
+ 'type': type,
+ 'content': content,
+ 'encoding': encoding,
+ '_links': links,
+ 'license': license
+ };
+}
+
+LicenseKind _$LicenseKindFromJson(Map<String, dynamic> json) {
+ return new LicenseKind(
+ key: json['key'] as String,
+ name: json['name'] as String,
+ spdxId: json['spdx_id'] as String,
+ url: json['url'] == null ? null : Uri.parse(json['url'] as String),
+ nodeId: json['node_id'] as String);
+}
+
+abstract class _$LicenseKindSerializerMixin {
+ String get key;
+ String get name;
+ String get spdxId;
+ Uri get url;
+ String get nodeId;
+ Map<String, dynamic> toJson() => <String, dynamic>{
+ 'key': key,
+ 'name': name,
+ 'spdx_id': spdxId,
+ 'url': url?.toString(),
+ 'node_id': nodeId
+ };
+}
+
+Links _$LinksFromJson(Map<String, dynamic> json) {
+ return new Links(
+ git: json['git'] == null ? null : Uri.parse(json['git'] as String),
+ self: json['self'] == null ? null : Uri.parse(json['self'] as String),
+ html: json['html'] == null ? null : Uri.parse(json['html'] as String));
+}
+
+abstract class _$LinksSerializerMixin {
+ Uri get self;
+ Uri get git;
+ Uri get html;
+ Map<String, dynamic> toJson() => <String, dynamic>{
+ 'self': self?.toString(),
+ 'git': git?.toString(),
+ 'html': html?.toString()
+ };
+}

diff:
@@ -258,7 +258,7 @@ class PullRequestComment {
..updatedAt = parseDateTime(input['updated_at'])
..url = input['html_url']
..pullRequestUrl = input['pull_request_url']
- ..links = Links.fromJSON(input['_links'] as Map<String, dynamic>);
+ ..links = new Links.fromJson(input['_links'] as Map<String, dynamic>);
}
}

diff:
@@ -453,3 +453,64 @@ class LanguageBreakdown {
return buffer.toString();
}
}
+
+@JsonSerializable()
+class LicenseDetails extends Object with _$LicenseDetailsSerializerMixin {
+ final String name;
+ final String path;
+ final String sha;
+ final int size;
+ final Uri url;
+
+ @JsonKey(name: 'html_url')
+ final Uri htmlUrl;
+ @JsonKey(name: 'git_url')
+ final Uri gitUrl;
+ @JsonKey(name: 'download_url')
+ final Uri downloadUrl;
+
+ final String type;
+ final String content;
+ final String encoding;
+
+ @JsonKey(name: '_links')
+ final Links links;
+
+ final LicenseKind license;
+
+ LicenseDetails(
+ {this.name,
+ this.path,
+ this.sha,
+ this.size,
+ this.url,
+ this.htmlUrl,
+ this.gitUrl,
+ this.downloadUrl,
+ this.type,
+ this.content,
+ this.encoding,
+ this.links,
+ this.license});
+
+ factory LicenseDetails.fromJson(Map<String, dynamic> json) =>
+ _$LicenseDetailsFromJson(json);
+}
+
+@JsonSerializable()
+class LicenseKind extends Object with _$LicenseKindSerializerMixin {
+ final String key;
+ final String name;
+
+ @JsonKey(name: 'spdx_id')
+ final String spdxId;
+ final Uri url;
+
+ @JsonKey(name: 'node_id')
+ final String nodeId;
+
+ LicenseKind({this.key, this.name, this.spdxId, this.url, this.nodeId});
+
+ factory LicenseKind.fromJson(Map<String, dynamic> json) =>
+ _$LicenseKindFromJson(json);
+}

diff:
@@ -64,33 +64,23 @@ class GitHubFile {
..sha = input['sha']
..gitUrl = input['git_url']
..htmlUrl = input['html_url']
- ..links = Links.fromJSON(input['_links'] as Map<String, dynamic>)
+ ..links = new Links.fromJson(input['_links'] as Map<String, dynamic>)
..sourceRepository = slug;
}
}
-/// File links.
-class Links {
- /// Git Link
- @ApiName("git")
- String git;
+@JsonSerializable()
+class Links extends Object with _$LinksSerializerMixin {
+ final Uri self;
+ final Uri git;
+ final Uri html;
- /// Self Link
- @ApiName("self")
- String self;
+ Links({this.git, this.self, this.html});
- /// HTML Link
- @ApiName("html")
- String html;
-
- static Links fromJSON(Map<String, dynamic> input) {
+ factory Links.fromJson(Map<String, dynamic> input) {
if (input == null) return null;
- var links = new Links();
- links.git = input['git'];
- links.self = input['self'];
- links.html = input['html'];
- return links;
+ return _$LinksFromJson(input);
}
}

diff:
@@ -89,6 +89,10 @@ class RepositoriesService extends Service {
}
}
+ Future<LicenseDetails> getLicense(RepositorySlug slug) =>
+ _github.getJSON("/repos/${slug.owner}/${slug.name}/license",
+ convert: (json) => new LicenseDetails.fromJson(json));
+
/// Fetches the repository specified by the [slug].
///
/// API docs: https://developer.github.com/v3/repos/#get

change_type: ADD

original_message: add getLicense to repo service


message: Added getResponseDate helper and add etag for all responses

diff:
@@ -9,6 +9,7 @@ import "dart:convert"
import "package:html/dom.dart" as html;
import "package:html/parser.dart" as html_parser;
import "package:http/http.dart" as http;
+import 'package:http_parser/http_parser.dart' as http_parser;
import "package:quiver/async.dart" show FutureGroup;
import "package:json_annotation/json_annotation.dart";
import "package:xml/xml.dart" as xml;
@@ -63,3 +64,14 @@ part "common/util/oauth2.dart";
part "common/util/pagination.dart";
part "common/util/service.dart";
part "common/util/utils.dart";
+
+void _applyExpandos(Object target, http.Response response) {
+ _etagExpando[target] = response.headers['etag'];
+ _dateExpando[target] = http_parser.parseHttpDate(response.headers['date']);
+}
+
+final _etagExpando = new Expando<String>('etag');
+final _dateExpando = new Expando<DateTime>('date');
+
+String getResponseEtag(Object obj) => _etagExpando[obj];
+DateTime getResponseDate(Object obj) => _dateExpando[obj];

diff:
@@ -237,10 +237,13 @@ class GitHub {
var json = jsonDecode(response.body);
if (convert == null) {
+ _applyExpandos(json, response);
return json;
}
- return convert(json);
+ final returnValue = convert(json);
+ _applyExpandos(returnValue, response);
+ return returnValue;
}
/// Handles Post Requests that respond with JSO


message: small dart2 fix

diff:
@@ -333,8 +333,8 @@ class RepositoriesService extends Service {
}
contents.file = GitHubFile.fromJSON(input as Map<String, dynamic>);
} else {
- contents.tree = (input as List<Map<String, dynamic>>)
- .map((Map<String, dynamic> it) => GitHubFile.fromJSON(it))
+ contents.tree = (input as List)
+ .map((it) => GitHubFile.fromJSON(it))
.toList();
}
return contents;

diff:
@@ -92,7 +92,7 @@ class PaginationHelper {
String body,
int statusCode: 200,
String preview}) {
- return jsonObjects(method, path,
+ return jsonObjects<S>(method, path,
pages: pages,
headers: headers,
params: params,

original_message: small dart2 fix (#107)


message: Latest source gen, and other fixes

diff:
-analyzer:
- strong-mode: true
-
linter:
rules:
- always_declare_return_types

diff:
@@ -118,36 +118,22 @@ LicenseDetails _$LicenseDetailsFromJson(Map<String, dynamic> json) {
: new LicenseKind.fromJson(json['license'] as Map<String, dynamic>));
}
-abstract class _$LicenseDetailsSerializerMixin {
- String get name;
- String get path;
- String get sha;
- int get size;
- Uri get url;
- Uri get htmlUrl;
- Uri get gitUrl;
- Uri get downloadUrl;
- String get type;
- String get content;
- String get encoding;
- Links get links;
- LicenseKind get license;
- Map<String, dynamic> toJson() => <String, dynamic>{
- 'name': name,
- 'path': path,
- 'sha': sha,
- 'size': size,
- 'url': url?.toString(),
- 'html_url': htmlUrl?.toString(),
- 'git_url': gitUrl?.toString(),
- 'download_url': downloadUrl?.toString(),
- 'type': type,
- 'content': content,
- 'encoding': encoding,
- '_links': links,
- 'license': license
+Map<String, dynamic> _$LicenseDetailsToJson(LicenseDetails instance) =>
+ <String, dynamic>{
+ 'name': instance.name,
+ 'path': instance.path,
+ 'sha': instance.sha,
+ 'size': instance.size,
+ 'url': instance.url?.toString(),
+ 'html_url': instance.htmlUrl?.toString(),
+ 'git_url': instance.gitUrl?.toString(),
+ 'download_url': instance.downloadUrl?.toString(),
+ 'type': instance.type,
+ 'content': instance.content,
+ 'encoding': instance.encoding,
+ '_links': instance.links,
+ 'license': instance.license
};
-}
LicenseKind _$LicenseKindFromJson(Map<String, dynamic> json) {
return new LicenseKind(
@@ -158,20 +144,14 @@ LicenseKind _$LicenseKindFromJson(Map<String, dynamic> json) {
nodeId: json['node_id'] as String);
}
-abstract class _$LicenseKindSerializerMixin {
- String get key;
- String get name;
- String get spdxId;
- Uri get url;
- String get nodeId;
- Map<String, dynamic> toJson() => <String, dynamic>{
- 'key': key,
- 'name': name,
- 'spdx_id': spdxId,
- 'url': url?.toString(),
- 'node_id': nodeId
+Map<String, dynamic> _$LicenseKindToJson(LicenseKind instance) =>
+ <String, dynamic>{
+ 'key': instance.key,
+ 'name': instance.name,
+ 'spdx_id': instance.spdxId,
+ 'url': instance.url?.toString(),
+ 'node_id': instance.nodeId
};
-}
Links _$LinksFromJson(Map<String, dynamic> json) {
return new Links(
@@ -180,13 +160,8 @@ Links _$LinksFromJson(Map<String, dynamic> json) {
html: json['html'] == null ? null : Uri.parse(json['html'] as String));
}
-abstract class _$LinksSerializerMixin {
- Uri get self;
- Uri get git;
- Uri get html;
- Map<String, dynamic> toJson() => <String, dynamic>{
- 'self': self?.toString(),
- 'git': git?.toString(),
- 'html': html?.toString()
+Map<String, dynamic> _$LinksToJson(Links instance) => <String, dynamic>{
+ 'self': instance.self?.toString(),
+ 'git': instance.git?.toString(),
+ 'html': instance.html?.toString()
};
-}

diff:
@@ -95,8 +95,8 @@ class GitService extends Service {
.request('PATCH', '/repos/${slug.fullName}/git/refs/$ref',
body: body, headers: headers)
.then((response) {
- return GitReference
- .fromJSON(jsonDecode(response.body) as Map<String, dynamic>);
+ return GitReference.fromJSON(
+ jsonDecode(response.body) as Map<String, dynamic>);
});
}

diff:
@@ -22,8 +22,8 @@ class Authorization {
..id = input['id']
..scopes = input['scopes'] as List<String>
..token = input['token']
- ..app = AuthorizationApplication
- .fromJSON(input['app'] as Map<String, dynamic>)
+ ..app = AuthorizationApplication.fromJSON(
+ input['app'] as Map<String, dynamic>)
..note = input['note']
..noteUrl = input['note_url']
..createdAt = parseDateTime(input['created_at'])

diff:
@@ -77,8 +77,8 @@ class Issue {
..milestone =
Milestone.fromJSON(input['milestone'] as Map<String, dynamic>)
..commentsCount = input['comments']
- ..pullRequest = IssuePullRequest
- .fromJSON(input['pull_request'] as Map<String, dynamic>)
+ ..pullRequest = IssuePullRequest.fromJSON(
+ input['pull_request'] as Map<String, dynamic>)
..createdAt = parseDateTime(input['created_at'])
..updatedAt = parseDateTime(input['updated_at'])
..closedAt = parseDateTime(input['closed_at'])

diff:
@@ -208,8 +208,8 @@ class TeamRepository extends Repository {
..pushedAt = parseDateTime(input['pushed_at'])
..owner = UserInformation.fromJSON(input['owner'] as Map<String, dynamic>)
..isPrivate = input['private']
- ..permissions = TeamRepositoryPermissions
- .fromJSON(input['permissions'] as Map<String, dynamic>);
+ ..permissions = TeamRepositoryPermissions.fromJSON(
+ input['permissions'] as Map<String, dynamic>);
}
}

diff:
@@ -455,7 +455,7 @@ class LanguageBreakdown {
}
@JsonSerializable()
-class LicenseDetails extends Object with _$LicenseDetailsSerializerMixin {
+class LicenseDetails {
final String name;
final String path;
final String sha;
@@ -495,10 +495,12 @@ class LicenseDetails extends Object with _$LicenseDetailsSerializerMixin {
factory LicenseDetails.fromJson(Map<String, dynamic> json) =>
_$LicenseDetailsFromJson(json);
+
+ Map<String, dynamic> toJson() => _$LicenseDetailsToJson(this);
}
@JsonSerializable()
-class LicenseKind extends Object with _$LicenseKindSerializerMixin {
+class LicenseKind {
final String key;
final String name;
@@ -513,4 +515,6 @@ class LicenseKind extends Object with _$LicenseKindSerializerMixin {
factory LicenseKind.fromJson(Map<String, dynamic> json) =>
_$LicenseKindFromJson(json);
+
+ Map<String, dynamic> toJson() => _$LicenseKindToJson(this);
}

diff:
@@ -70,7 +70,7 @@ class GitHubFile {
}
@JsonSerializable()
-class Links extends Object with _$LinksSerializerMixin {
+class Links {
final Uri self;
final Uri git;
final Uri html;
@@ -82,6 +82,8 @@ class Links extends Object with _$LinksSerializerMixin {
return _$LinksFromJson(input);
}
+
+ Map<String, dynamic> toJson() => _$LinksToJson(this);
}
/// Model class for a file or directory.

diff:
@@ -59,8 +59,8 @@ class PullRequestsService extends Service {
.request("POST", '/repos/${slug.fullName}/pulls/$number',
body: jsonEncode(map))
.then((response) {
- return PullRequest
- .fromJSON(jsonDecode(response.body) as Map<String, dynamic>);
+ return PullRequest.fromJSON(
+ jsonDecode(response.body) as Map<String, dynamic>);
});
}
@@ -104,8 +104,8 @@ class PullRequestsService extends Service {
.request("PUT", "/repos/${slug.fullName}/pulls/$number/merge",
body: jsonEncode(json))
.then((response) {
- return PullRequestMerge
- .fromJSON(jsonDecode(response.body) as Map<String, dynamic>);
+ return PullRequestMerge.fromJSON(
+ jsonDecode(response.body) as Map<String, dynamic>);
});
}

original_message: Latest source gen, and other fixes (#111)


diff:
@@ -7,19 +7,19 @@ part of github.common;
// **************************************************************************
GitTree _$GitTreeFromJson(Map<String, dynamic> json) {
- return new GitTree(
+ return GitTree(
json['sha'] as String,
json['url'] as String,
json['truncated'] as bool,
(json['tree'] as List)
?.map((e) => e == null
? null
- : new GitTreeEntry.fromJson(e as Map<String, dynamic>))
+ : GitTreeEntry.fromJson(e as Map<String, dynamic>))
?.toList());
}
GitTreeEntry _$GitTreeEntryFromJson(Map<String, dynamic> json) {
- return new GitTreeEntry(
+ return GitTreeEntry(
json['path'] as String,
json['mode'] as String,
json['type'] as String,
@@ -29,7 +29,7 @@ GitTreeEntry _$GitTreeEntryFromJson(Map<String, dynamic> json) {
}
GitHubComparison _$GitHubComparisonFromJson(Map<String, dynamic> json) {
- return new GitHubComparison(
+ return GitHubComparison(
json['url'] as String,
json['status'] as String,
json['ahead_by'] as int,
@@ -38,62 +38,61 @@ GitHubComparison _$GitHubComparisonFromJson(Map<String, dynamic> json) {
}
Tag _$TagFromJson(Map<String, dynamic> json) {
- return new Tag(
+ return Tag(
json['name'] as String,
json['commit'] == null
? null
- : new CommitInfo.fromJson(json['commit'] as Map<String, dynamic>),
+ : CommitInfo.fromJson(json['commit'] as Map<String, dynamic>),
json['zipball_url'] as String,
json['tarball_url'] as String);
}
CommitData _$CommitDataFromJson(Map<String, dynamic> json) {
- return new CommitData(
+ return CommitData(
json['sha'] as String,
- json['commit'] == null ? null : new GitCommit.fromJson(json['commit']),
+ json['commit'] == null ? null : GitCommit.fromJson(json['commit']),
json['url'] as String,
json['html_url'] as String,
json['comments_url'] as String,
json['author'] == null
? null
- : new CommitDataUser.fromJson(json['author'] as Map<String, dynamic>),
+ : CommitDataUser.fromJson(json['author'] as Map<String, dynamic>),
json['committer'] == null
? null
- : new CommitDataUser.fromJson(
- json['committer'] as Map<String, dynamic>),
+ : CommitDataUser.fromJson(json['committer'] as Map<String, dynamic>),
(json['parents'] as List)
?.map((e) => e as Map<String, dynamic>)
?.toList());
}
CommitDataUser _$CommitDataUserFromJson(Map<String, dynamic> json) {
- return new CommitDataUser(
+ return CommitDataUser(
json['login'] as String, json['id'] as int, json['type'] as String);
}
CommitInfo _$CommitInfoFromJson(Map<String, dynamic> json) {
- return new CommitInfo(
+ return CommitInfo(
json['sha'] as String,
json['tree'] == null
? null
- : new GitTree.fromJson(json['tree'] as Map<String, dynamic>));
+ : GitTree.fromJson(json['tree'] as Map<String, dynamic>));
}
UserInformation _$UserInformationFromJson(Map<String, dynamic> json) {
- return new UserInformation(json['login'] as String, json['id'] as int,
+ return UserInformation(json['login'] as String, json['id'] as int,
json['avatar_url'] as String, json['html_url'] as String);
}
Branch _$BranchFromJson(Map<String, dynamic> json) {
- return new Branch(
+ return Branch(
json['name'] as String,
json['commit'] == null
? null
- : new CommitData.fromJson(json['commit'] as Map<String, dynamic>));
+ : CommitData.fromJson(json['commit'] as Map<String, dynamic>));
}
LicenseDetails _$LicenseDetailsFromJson(Map<String, dynamic> json) {
- return new LicenseDetails(
+ return LicenseDetails(
name: json['name'] as String,
path: json['path'] as String,
sha: json['sha'] as String,
@@ -112,10 +111,10 @@ LicenseDetails _$LicenseDetailsFromJson(Map<String, dynamic> json) {
encoding: json['encoding'] as String,
links: json['_links'] == null
? null
- : new Links.fromJson(json['_links'] as Map<String, dynamic>),
+ : Links.fromJson(json['_links'] as Map<String, dynamic>),
license: json['license'] == null
? null
- : new LicenseKind.fromJson(json['license'] as Map<String, dynamic>));
+ : LicenseKind.fromJson(json['license'] as Map<String, dynamic>));
}
Map<String, dynamic> _$LicenseDetailsToJson(LicenseDetails instance) =>
@@ -136,7 +135,7 @@ Map<String, dynamic> _$LicenseDetailsToJson(LicenseDetails instance) =>
};
LicenseKind _$LicenseKindFromJson(Map<String, dynamic> json) {
- return new LicenseKind(
+ return LicenseKind(
key: json['key'] as String,
name: json['name'] as String,
spdxId: json['spdx_id'] as String,
@@ -154,7 +153,7 @@ Map<String, dynamic> _$LicenseKindToJson(LicenseKind instance) =>
};
Links _$LinksFromJson(Map<String, dynamic> json) {
- return new Links(
+ return Links(
git: json['git'] == null ? null : Uri.parse(json['git'] as String),
self: json['self'] == null ? null : Uri.parse(json['self'] as String),
html: json['html'] == null ? null : Uri.parse(json['html'] as String));

diff:
part of github.common;
-@JsonSerializable(createToJson: false)
+@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
class GitHubComparison {
final String url;
-
final String status;
-
- @JsonKey(name: 'ahead_by')
final int aheadBy;
-
- @JsonKey(name: 'behind_by')
final int behindBy;
-
- @JsonKey(name: 'total_commits')
final int totalCommits;
GitHubComparison(
@@ -205,7 +198,6 @@ class CloneUrls {
class Tag {
final String name;
final CommitInfo commit;
-
@JsonKey(name: 'zipball_url')
final String zipUrl;
@JsonKey(name: 'tarball_url')
@@ -220,18 +212,12 @@ class Tag {
String toString() => 'Tag: $name';
}
-@JsonSerializable(createToJson: false)
+@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
class CommitData {
final String sha;
final GitCommit commit;
-
- @JsonKey(name: "url")
final String url;
-
- @JsonKey(name: "html_url")
final String htmlUrl;
-
- @JsonKey(name: "comments_url")
final String commentsUrl;
final CommitDataUser author, committer;
@@ -268,7 +254,7 @@ class CommitInfo {
}
/// User Information
-@JsonSerializable(createToJson: false)
+@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
class UserInformation {
/// Owner Username
final String login;
@@ -277,11 +263,9 @@ class UserInformation {
final int id;
/// Avatar Url
- @JsonKey(name: "avatar_url")
final String avatarUrl;
/// Url to the user's GitHub Profile
- @JsonKey(name: "html_url")
final String htmlUrl;
UserInformation(this.login, this.id, this.avatarUrl, this.htmlUrl);
@@ -454,7 +438,7 @@ class LanguageBreakdown {
}
}
-@JsonSerializable()
+@JsonSerializable(fieldRename: FieldRename.snake)
class LicenseDetails {
final String name;
final String path;
@@ -462,11 +446,8 @@ class LicenseDetails {
final int size;
final Uri url;
- @JsonKey(name: 'html_url')
final Uri htmlUrl;
- @JsonKey(name: 'git_url')
final Uri gitUrl;
- @JsonKey(name: 'download_url')
final Uri downloadUrl;
final String type;
@@ -499,16 +480,12 @@ class LicenseDetails {
Map<String, dynamic> toJson() => _$LicenseDetailsToJson(this);
}
-@JsonSerializable()
+@JsonSerializable(fieldRename: FieldRename.snake)
class LicenseKind {
final String key;
final String name;
-
- @JsonKey(name: 'spdx_id')
final String spdxId;
final Uri url;
-
- @JsonKey(name: 'node_id')
final String nodeId;
LicenseKind({this.key, this.name, this.spdxId, this.url, this.nodeId});

diff:
@@ -4,15 +4,15 @@ author: Kenneth Endfinger <kaendfinger@gmail.com>
description: GitHub API Client Library
homepage: https://github.com/DirectMyFile/github.dart
environment:
- sdk: '>=2.0.0-dev.36 <2.0.0'
+ sdk: '>=2.0.0-dev.36 <3.0.0'
dependencies:
html: '>=0.12.0 <0.14.0'
http: '^0.11.3'
http_parser: ^3.1.1
- json_annotation: '>=0.2.8 <2.0.0'
+ json_annotation: ^1.1.0
xml: '>=2.0.0 <4.0.0'
dev_dependencies:
- build_runner: ^0.9.0
- json_serializable: ^1.0.0
- test: '^0.12.0'
- mockito: '^1.0.1'
+ build_runner: ^0.10.0
+ json_serializable: ^1.1.0
+ test: ^1.3.0
+ mockito: ^3.0.0

diff:
@@ -133,8 +133,7 @@ void main() {
// given
http.Response expectedResponse = new http.Response('{}', 200);
- when(github.request(any, any,
- body: any, headers: typed(any, named: 'headers')))
+ when(github.request(any, any, body: any, headers: any))
.thenReturn(new Future.value(expectedResponse));
// when
@@ -142,22 +141,21 @@ void main() {
// then
verify(github.request('PATCH', '/repos/o/n/git/refs/heads/b',
- headers: typed(any, named: 'headers'), body: any));
+ headers: any, body: any));
});
test('creates valid JSON body', () {
// given
http.Response expectedResponse = new http.Response('{}', 200);
- when(github.request(any, any,
- body: any, headers: typed(any, named: 'headers')))
+ when(github.request(any, any, body: any, headers: any))
.thenReturn(new Future.value(expectedResponse));
// when
git.editReference(repo, 'heads/b', someSha, force: true);
// then
- var captured = verify(github.request(any, any,
- body: captureAny, headers: typed(captureAny, named: 'headers')))
+ var captured = verify(
+ github.request(any, any, body: captureAny, headers: captureAny))
.captured;
var body = jsonDecode(captured[0]);

original_message: 4 commits: dart2 support, latest json_serial, etc (#112)


diff:
@@ -146,7 +146,7 @@ TeamRepository _$TeamRepositoryFromJson(Map<String, dynamic> json) {
..hasDownloads = json['has_downloads'] as bool
..forksCount = json['forks_count'] as int
..openIssuesCount = json['open_issues_count'] as int
- ..defaultBranch = json['defaultBranch'] as String
+ ..defaultBranch = json['default_branch'] as String
..subscribersCount = json['subscribers_count'] as int
..networkCount = json['network_count'] as int
..createdAt = json['created_at'] == null
@@ -201,7 +201,7 @@ Repository _$RepositoryFromJson(Map<String, dynamic> json) {
..hasDownloads = json['has_downloads'] as bool
..forksCount = json['forks_count'] as int
..openIssuesCount = json['open_issues_count'] as int
- ..defaultBranch = json['defaultBranch'] as String
+ ..defaultBranch = json['default_branch'] as String
..subscribersCount = json['subscribers_count'] as int
..networkCount = json['network_count'] as int
..createdAt = json['created_at'] == null

diff:
@@ -103,6 +103,7 @@ class Repository {
int openIssuesCount;
/// Repository Default Branch
+ @JsonKey(name: 'default_branch')
String defaultBranch;
/// Number of Subscribers

original_message: Fix encoded name of Repository.defaultBranch (#114)


message: Remove sort_constructors_first lint

diff:
@@ -32,7 +32,6 @@ linter:
- prefer_is_not_empty
- prefer_is_not_empty
- slash_for_doc_comments
- - sort_constructors_first
- sort_unnamed_constructors_first
- super_goes_last
- test_types_in_equals

original_message: Remove sort_constructors_first lint


message: Support latest pkg:http version

diff:
@@ -14,6 +14,9 @@ export "src/common.dart";
/// Creates a GitHub Client
GitHub createGitHubClient(
{Authentication auth, String endpoint: "https://api.github.com"}) {
+ // NOTE: This library is not needed if `pkg:http` is updated to support
+ // pkg:http ^0.12.0. Make sure to update the dependency if/when you remove
+ // browser.dart
return new GitHub(
auth: auth, client: new BrowserClient(), endpoint: endpoint);
}

original_message: Support latest pkg:http version