createFile method

Future<ContentCreation> createFile(
  1. RepositorySlug slug,
  2. CreateFile file
)

Creates a new file in a repository.

API docs: https://developer.github.com/v3/repos/contents/#create-a-file

Implementation

Future<ContentCreation> createFile(
    RepositorySlug slug, CreateFile file) async {
  ArgumentError.checkNotNull(slug);
  ArgumentError.checkNotNull(file);
  final response = await github.request(
    'PUT',
    '/repos/${slug.fullName}/contents/${file.path}',
    body: GitHubJson.encode(file),
  );
  return ContentCreation.fromJson(
      jsonDecode(response.body) as Map<String, dynamic>);
}