Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add author_association to the IssueComment object for access. #348

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 9.9.0

* Add "author_association" field to the IssueComment object by @ricardoamador in https://github.com/SpinlockLabs/github.dart/pull/348

**Full Changelog**: https://github.com/SpinlockLabs/github.dart/compare/9.8.0...9.9.0

## 9.8.0

* Add "head_branch" field to CheckSuite object by @nehalvpatel in https://github.com/SpinlockLabs/github.dart/pull/347
Expand Down
2 changes: 2 additions & 0 deletions lib/src/common/model/issues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class IssueComment {
this.url,
this.htmlUrl,
this.issueUrl,
this.authorAssociation,
});
int? id;
String? body;
Expand All @@ -158,6 +159,7 @@ class IssueComment {
String? url;
String? htmlUrl;
String? issueUrl;
String? authorAssociation;

factory IssueComment.fromJson(Map<String, dynamic> input) =>
_$IssueCommentFromJson(input);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/common/model/issues.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

63 changes: 63 additions & 0 deletions test/unit/issues_test.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import 'dart:convert';
import 'package:github/src/common/model/issues.dart';

import 'package:test/test.dart';


const String testIssueCommentJson = '''
{
"url": "https://api.github.com/repos/flutter/cocoon/issues/comments/1352355796",
"html_url": "https://github.com/flutter/cocoon/pull/2356#issuecomment-1352355796",
"issue_url": "https://api.github.com/repos/flutter/cocoon/issues/2356",
"id": 1352355796,
"node_id": "IC_kwDOA8VHis5Qm0_U",
"user": {
"login": "CaseyHillers",
"id": 2148558,
"node_id": "MDQ6VXNlcjIxNDg1NTg=",
"avatar_url": "https://avatars.githubusercontent.com/u/2148558?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/CaseyHillers",
"html_url": "https://github.com/CaseyHillers",
"followers_url": "https://api.github.com/users/CaseyHillers/followers",
"following_url": "https://api.github.com/users/CaseyHillers/following{/other_user}",
"gists_url": "https://api.github.com/users/CaseyHillers/gists{/gist_id}",
"starred_url": "https://api.github.com/users/CaseyHillers/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/CaseyHillers/subscriptions",
"organizations_url": "https://api.github.com/users/CaseyHillers/orgs",
"repos_url": "https://api.github.com/users/CaseyHillers/repos",
"events_url": "https://api.github.com/users/CaseyHillers/events{/privacy}",
"received_events_url": "https://api.github.com/users/CaseyHillers/received_events",
"type": "User",
"site_admin": false
},
"created_at": "2022-12-14T23:26:32Z",
"updated_at": "2022-12-14T23:26:32Z",
"author_association": "MEMBER",
"body": "FYI you need to run https://github.com/flutter/cocoon/blob/main/format.sh for formatting Cocoon code",
"reactions": {
"url": "https://api.github.com/repos/flutter/cocoon/issues/comments/1352355796/reactions",
"total_count": 0,
"+1": 0,
"-1": 0,
"laugh": 0,
"hooray": 0,
"confused": 0,
"heart": 0,
"rocket": 0,
"eyes": 0
},
"performed_via_github_app": null
}
''';

void main() {
group('Issue Comments', () {
test('IssueComment from Json', () {
final issueComment = IssueComment.fromJson(jsonDecode(testIssueCommentJson));
expect(1352355796, issueComment.id);
expect('MEMBER', issueComment.authorAssociation);
expect('CaseyHillers', issueComment.user!.login);
});
});
}