listContributorStats method

Future<List<ContributorStatistics>> listContributorStats(
  1. RepositorySlug slug
)

Lists repository contributor statistics.

It's possible that this API will throw NotReady in which case you should try the call again later.

API docs: https://developer.github.com/v3/repos/statistics/#contributors

Implementation

Future<List<ContributorStatistics>> listContributorStats(
  RepositorySlug slug,
) async {
  ArgumentError.checkNotNull(slug);
  final path = '/repos/${slug.fullName}/stats/contributors';
  final response =
      await github.request('GET', path, headers: {'Accept': v3ApiMimeType});

  if (response.statusCode == StatusCodes.OK) {
    return (jsonDecode(response.body) as List)
        .map((e) => ContributorStatistics.fromJson(e))
        .toList();
  } else if (response.statusCode == StatusCodes.ACCEPTED) {
    throw NotReady(github, path);
  }
  github.handleStatusCode(response);
  throw UnknownError(github);
}