Add IssueService.listReactions function
MODIFY
CHANGELOG.md
CHANGELOG.md
+## 6.1.0
+ - Add (experimental) `listReactions` method to `IssueService`.
+
## 6.0.6
- Clean up lints https://github.com/SpinlockLabs/github.dart/pull/202

MODIFY
lib/src/common.dart
lib/src/common.dart
@@ -17,6 +17,7 @@ export 'package:github/src/common/model/misc.dart';
export 'package:github/src/common/model/notifications.dart';
export 'package:github/src/common/model/orgs.dart';
export 'package:github/src/common/model/pulls.dart';
+export 'package:github/src/common/model/reaction.dart';
export 'package:github/src/common/model/repos.dart';
export 'package:github/src/common/model/repos_commits.dart';
export 'package:github/src/common/model/repos_contents.dart';

MODIFY
lib/src/common/issues_service.dart
lib/src/common/issues_service.dart
import 'dart:async';
import 'dart:convert';
+
import 'package:github/src/common.dart';
import 'package:github/src/common/model/users.dart';
import 'package:github/src/common/util/pagination.dart';
@@ -129,6 +130,19 @@ class IssuesService extends Service {
);
}
+ /// This API is currently in preview. It may break.
+ ///
+ /// See https://developer.github.com/v3/reactions/
+ Stream<Reaction> listReactions(RepositorySlug slug, int issueNumber) =>
+ PaginationHelper(github).objects(
+ 'GET',
+ '/repos/${slug.owner}/${slug.name}/issues/$issueNumber/reactions',
+ (i) => Reaction.fromJson(i),
+ headers: {
+ 'Accept': 'application/vnd.github.squirrel-girl-preview+json',
+ },
+ );
+
/// Edit an issue.
///
/// API docs: https://developer.github.com/v3/issues/#edit-an-issue

ADD
lib/src/common/model/reaction.dart
+import 'package:github/src/common.dart';
+import 'package:github/src/common/model/users.dart';
+import 'package:json_annotation/json_annotation.dart';
+
+part 'reaction.g.dart';
+
+/// This API is currently in preview. It may break.
+///
+/// See https://developer.github.com/v3/reactions/
+@JsonSerializable(fieldRename: FieldRename.snake)
+class Reaction {
+ final int id;
+ final String nodeId;
+ final User user;
+ final String content;
+ final DateTime createdAt;
+
+ Reaction({
+ this.id,
+ this.nodeId,
+ this.user,
+ this.content,
+ this.createdAt,
+ });
+
+ factory Reaction.fromJson(Map<String, dynamic> json) =>
+ _$ReactionFromJson(json);
+
+ Map<String, dynamic> toJson() => _$ReactionToJson(this);
+}

ADD
lib/src/common/model/reaction.g.dart
+// GENERATED CODE - DO NOT MODIFY BY HAND
+
+part of 'reaction.dart';
+
+// **************************************************************************
+// JsonSerializableGenerator
+// **************************************************************************
+
+Reaction _$ReactionFromJson(Map<String, dynamic> json) {
+ return Reaction(
+ id: json['id'] as int,
+ nodeId: json['node_id'] as String,
+ user: json['user'] == null
+ ? null
+ : User.fromJson(json['user'] as Map<String, dynamic>),
+ content: json['content'] as String,
+ createdAt: json['created_at'] == null
+ ? null
+ : DateTime.parse(json['created_at'] as String),
+ );
+}
+
+Map<String, dynamic> _$ReactionToJson(Reaction instance) => <String, dynamic>{
+ 'id': instance.id,
+ 'node_id': instance.nodeId,
+ 'user': instance.user,
+ 'content': instance.content,
+ 'created_at': instance.createdAt?.toIso8601String(),
+ };

MODIFY
pubspec.yaml
pubspec.yaml
name: github
-version: 6.0.6
+version: 6.1.0-dev
description: A high-level GitHub API Client Library that uses Github's v3 API
homepage: https://github.com/SpinlockLabs/github.dart

Add IssueService.listReactions function