createDeployKey method

Future<PublicKey> createDeployKey(
  1. RepositorySlug slug,
  2. CreatePublicKey key
)

Adds a deploy key for a repository.

API docs: https://developer.github.com/v3/repos/keys/#create

Implementation

Future<PublicKey> createDeployKey(
    RepositorySlug slug, CreatePublicKey key) async {
  ArgumentError.checkNotNull(slug);
  ArgumentError.checkNotNull(key);
  return github.postJSON<Map<String, dynamic>, PublicKey>(
    '/repos/${slug.fullName}/keys',
    body: GitHubJson.encode(key),
    statusCode: StatusCodes.CREATED,
    convert: (i) => PublicKey.fromJson(i),
  );
}