createHook method

Future<Hook> createHook(
  1. RepositorySlug slug,
  2. CreateHook hook
)

Creates a repository hook based on the specified hook.

API docs: https://developer.github.com/v3/repos/hooks/#create-a-hook

Implementation

Future<Hook> createHook(RepositorySlug slug, CreateHook hook) async {
  ArgumentError.checkNotNull(slug);
  ArgumentError.checkNotNull(hook);
  return github.postJSON<Map<String, dynamic>, Hook>(
    '/repos/${slug.fullName}/hooks',
    convert: (i) => Hook.fromJson(i)..repoName = slug.fullName,
    body: GitHubJson.encode(hook),
  );
}