Skip to content

Commit 83bddf3

Browse files
committed
Fix contributors response
1 parent dde81ec commit 83bddf3

File tree

3 files changed

+66
-3
lines changed

3 files changed

+66
-3
lines changed

lib/src/common/model/users.dart

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,45 @@ class Collaborator {
115115
_$CollaboratorFromJson(json);
116116
}
117117

118+
/// The response from listing contributors on a repo.
119+
// https://developer.github.com/v3/repos/collaborators/#response
120+
@JsonSerializable(fieldRename: FieldRename.snake)
121+
class Contributor {
122+
Contributor({
123+
this.id,
124+
this.login,
125+
this.avatarUrl,
126+
this.htmlUrl,
127+
this.type,
128+
this.siteAdmin,
129+
this.contributions,
130+
});
131+
132+
/// User's Username
133+
String login;
134+
135+
/// User ID
136+
int id;
137+
138+
/// Avatar URL
139+
String avatarUrl;
140+
141+
/// Url to this user's profile.
142+
String htmlUrl;
143+
144+
String type;
145+
146+
/// If the user is a site administrator
147+
bool siteAdmin;
148+
149+
/// Contributions count
150+
int contributions;
151+
152+
factory Contributor.fromJson(Map<String, dynamic> input) =>
153+
_$ContributorFromJson(input);
154+
Map<String, dynamic> toJson() => _$ContributorToJson(this);
155+
}
156+
118157
/// The Currently Authenticated User
119158
@JsonSerializable(fieldRename: FieldRename.snake)
120159
class CurrentUser extends User {

lib/src/common/model/users.g.dart

Lines changed: 23 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/common/repos_service.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,13 +203,14 @@ class RepositoriesService extends Service {
203203
/// Lists the contributors of the specified repository.
204204
///
205205
/// API docs: https://developer.github.com/v3/repos/#list-contributors
206-
Stream<User> listContributors(RepositorySlug slug, {bool anon = false}) {
206+
Stream<Contributor> listContributors(RepositorySlug slug,
207+
{bool anon = false}) {
207208
ArgumentError.checkNotNull(slug);
208209
ArgumentError.checkNotNull(anon);
209-
return PaginationHelper(github).objects<Map<String, dynamic>, User>(
210+
return PaginationHelper(github).objects<Map<String, dynamic>, Contributor>(
210211
'GET',
211212
'/repos/${slug.fullName}/contributors',
212-
(i) => User.fromJson(i),
213+
(i) => Contributor.fromJson(i),
213214
params: <String, dynamic>{'anon': anon.toString()},
214215
);
215216
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

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

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


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy