createLabel method

Future<IssueLabel> createLabel(
  1. RepositorySlug slug,
  2. String name, {
  3. String? color,
  4. String? description,
})

Creates a new label on the specified repository.

API docs: https://developer.github.com/v3/issues/labels/#create-a-label

Implementation

Future<IssueLabel> createLabel(
  RepositorySlug slug,
  String name, {
  String? color,
  String? description,
}) {
  return github.postJSON(
    '/repos/${slug.fullName}/labels',
    body: GitHubJson.encode({
      'name': name,
      if (color != null) 'color': color,
      if (description != null) 'description': description,
    }),
    convert: IssueLabel.fromJson,
  );
}