Skip to content

Commit

Permalink
Update editRepository according to current documentation
Browse files Browse the repository at this point in the history
Current Github docs specify most of the parameters as optional. This
commit update the existing editRepository method to these specs.

https://docs.github.com/en/rest/repos/repos#update-a-repository
  • Loading branch information
ianmaciel committed Oct 25, 2022
1 parent 344c841 commit 7e93cc9
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions lib/src/common/repos_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -168,29 +168,34 @@ class RepositoriesService extends Service {

/// Edit a Repository.
///
/// API docs: https://developer.github.com/v3/repos/#edit
Future<Repository> editRepository(RepositorySlug slug,
{String? name,
String? description,
String? homepage,
bool? private,
bool? hasIssues,
bool? hasWiki,
bool? hasDownloads}) async {
/// API docs: https://docs.github.com/en/rest/repos/repos#update-a-repository
Future<Repository> editRepository(
RepositorySlug slug, {
String? name,
String? description,
String? homepage,
bool? private,
bool? hasIssues,
bool? hasWiki,
bool? hasDownloads,
String? defaultBranch,
}) async {
ArgumentError.checkNotNull(slug);

final data = createNonNullMap({
'name': name!,
'description': description!,
'homepage': homepage!,
'private': private!,
'has_issues': hasIssues!,
'has_wiki': hasWiki!,
'has_downloads': hasDownloads!,
'default_branch': 'defaultBranch'
'name': name,
'description': description,
'homepage': homepage,
'private': private,
'has_issues': hasIssues,
'has_wiki': hasWiki,
'has_downloads': hasDownloads,
'default_branch': defaultBranch,
});
return github.postJSON(
return github.postJSON<Map<String, dynamic>, Repository>(
'/repos/${slug.fullName}',
body: GitHubJson.encode(data),
convert: (i) => Repository.fromJson(i),
statusCode: 200,
);
}
Expand Down

0 comments on commit 7e93cc9

Please sign in to comment.