Centralize definition of v3 API mime type
MODIFY
lib/src/common/github.dart
lib/src/common/github.dart
@@ -229,7 +229,7 @@ class GitHub {
headers['Accept'] = preview;
}
- headers.putIfAbsent('Accept', () => 'application/vnd.github.v3+json');
+ headers.putIfAbsent('Accept', () => v3ApiMimeType);
final response = await request(
method,

MODIFY
lib/src/common/repos_service.dart
lib/src/common/repos_service.dart
@@ -1140,8 +1140,8 @@ class RepositoriesService extends Service {
) async {
ArgumentError.checkNotNull(slug);
final path = '/repos/${slug.fullName}/stats/contributors';
- final response = await github.request('GET', path,
- headers: {'Accept': 'application/vnd.github.v3+json'});
+ final response =
+ await github.request('GET', path, headers: {'Accept': v3ApiMimeType});
if (response.statusCode == StatusCodes.OK) {
return (jsonDecode(response.body) as List)

MODIFY
lib/src/common/util/pagination.dart
lib/src/common/util/pagination.dart
@@ -4,6 +4,7 @@ import 'dart:convert' show jsonDecode;
import 'package:http/http.dart' as http;
import '../../common.dart';
+import '../../util.dart';
/// Internal Helper for dealing with GitHub Pagination.
class PaginationHelper {
@@ -93,7 +94,7 @@ class PaginationHelper {
if (preview != null) {
headers['Accept'] = preview;
}
- headers.putIfAbsent('Accept', () => 'application/vnd.github.v3+json');
+ headers.putIfAbsent('Accept', () => v3ApiMimeType);
await for (final response in fetchStreamed(method, path,
pages: pages,

MODIFY
lib/src/util.dart
lib/src/util.dart
final RegExp githubDateRemoveRegExp = RegExp(r'\.\d*');
+const v3ApiMimeType = 'application/vnd.github.v3+json';
+
String buildQueryString(Map<String, dynamic> params) {
final queryString = StringBuffer();

Centralize definition of v3 API mime type