deleteFile method

Future<ContentCreation> deleteFile(
  1. RepositorySlug slug,
  2. String path,
  3. String message,
  4. String sha,
  5. String branch,
)

Deletes the specified file.

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

Implementation

Future<ContentCreation> deleteFile(
  RepositorySlug slug,
  String path,
  String message,
  String sha,
  String branch,
) async {
  ArgumentError.checkNotNull(slug);
  ArgumentError.checkNotNull(path);
  final map = createNonNullMap({
    'message': message,
    'sha': sha,
    'branch': branch,
  });
  final response = await github.request(
    'DELETE',
    '/repos/${slug.fullName}/contents/$path',
    body: GitHubJson.encode(map),
    statusCode: StatusCodes.OK,
  );
  return ContentCreation.fromJson(
    jsonDecode(response.body) as Map<String, dynamic>,
  );
}