createRepository method

Future<Repository> createRepository(
  1. CreateRepository repository,
  2. {String? org}
)

Creates a repository with repository. If an org is specified, the new repository will be created under that organization. If no org is specified, it will be created for the authenticated user.

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

Implementation

Future<Repository> createRepository(CreateRepository repository,
    {String? org}) async {
  ArgumentError.checkNotNull(repository);
  if (org != null) {
    return github.postJSON<Map<String, dynamic>, Repository>(
      '/orgs/$org/repos',
      body: GitHubJson.encode(repository),
      convert: (i) => Repository.fromJson(i),
    );
  } else {
    return github.postJSON<Map<String, dynamic>, Repository>(
      '/user/repos',
      body: GitHubJson.encode(repository),
      convert: (i) => Repository.fromJson(i),
    );
  }
}