Breaking: fix RepositoriesService.listCollaborators
Return new type that includes the right information
MODIFY
CHANGELOG.md
CHANGELOG.md
+## v5.0.0
+
+- **BREAKING** `RepositoriesService.listCollaborators` now returns
+ `Stream<Collaborator>` instead of `Stream<User>`.
+ - `Collaborator` is a new type that includes collaborator-specific
+ information.
+
## v4.1.1
- Require at least Dart `2.1.0`.

MODIFY
lib/src/common/model/users.dart
lib/src/common/model/users.dart
@@ -86,6 +86,30 @@ class User {
}
}
+/// The response from listing collaborators on a repo.
+// https://developer.github.com/v3/repos/collaborators/#response
+@JsonSerializable(createToJson: false, fieldRename: FieldRename.snake)
+class Collaborator {
+ final String login;
+ final int id;
+ final String htmlUrl;
+ final String type;
+ final bool siteAdmin;
+ final Map<String, bool> permissions;
+
+ Collaborator(
+ this.login,
+ this.id,
+ this.htmlUrl,
+ this.type,
+ this.siteAdmin,
+ this.permissions,
+ );
+
+ factory Collaborator.fromJson(Map<String, dynamic> json) =>
+ _$CollaboratorFromJson(json);
+}
+
/// The Currently Authenticated User
@JsonSerializable(createToJson: false)
class CurrentUser extends User {

MODIFY
lib/src/common/model/users.g.dart
lib/src/common/model/users.g.dart
@@ -53,6 +53,18 @@ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
'updated_at': instance.updatedAt?.toIso8601String()
};
+Collaborator _$CollaboratorFromJson(Map<String, dynamic> json) {
+ return Collaborator(
+ json['login'] as String,
+ json['id'] as int,
+ json['html_url'] as String,
+ json['type'] as String,
+ json['site_admin'] as bool,
+ (json['permissions'] as Map<String, dynamic>)?.map(
+ (k, e) => MapEntry(k, e as bool),
+ ));
+}
+
CurrentUser _$CurrentUserFromJson(Map<String, dynamic> json) {
return CurrentUser()
..login = json['login'] as String

MODIFY
lib/src/common/repos_service.dart
lib/src/common/repos_service.dart
@@ -201,10 +201,12 @@ class RepositoriesService extends Service {
/// Lists the users that have access to the repository identified by [slug].
///
/// API docs: https://developer.github.com/v3/repos/collaborators/#list
- Stream<User> listCollaborators(RepositorySlug slug) {
- return PaginationHelper(_github)
- .objects("GET", "/repos/${slug.fullName}/collaborators", User.fromJson);
- }
+ Stream<Collaborator> listCollaborators(RepositorySlug slug) =>
+ PaginationHelper(_github).objects(
+ "GET",
+ "/repos/${slug.fullName}/collaborators",
+ (json) => Collaborator.fromJson(json),
+ );
Future<bool> isCollaborator(RepositorySlug slug, String user) {
return _github

MODIFY
pubspec.yaml
pubspec.yaml
name: github
-version: 4.1.1-dev
+version: 5.0.0-dev
author: Kenneth Endfinger <kaendfinger@gmail.com>
description: GitHub API Client Library
homepage: https://github.com/DirectMyFile/github.dart

Breaking: fix RepositoriesService.listCollaborators

Return new type that includes the right information