create method

Future<Issue> create(
  1. RepositorySlug slug,
  2. IssueRequest issue
)

Implementation

Future<Issue> create(RepositorySlug slug, IssueRequest issue) async {
  final response = await github.request(
    'POST',
    '/repos/${slug.fullName}/issues',
    body: GitHubJson.encode(issue),
  );

  if (StatusCodes.isClientError(response.statusCode)) {
    //TODO: throw a more friendly error – better this than silent failure
    throw GitHubError(github, response.body);
  }

  return Issue.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}