Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose IssueLabel.description; update labels REST APIs #355

Merged
merged 4 commits into from
Mar 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
44 changes: 37 additions & 7 deletions lib/src/common/issues_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -290,19 +290,49 @@ class IssuesService extends Service {
///
/// API docs: https://developer.github.com/v3/issues/labels/#create-a-label
Future<IssueLabel> createLabel(
RepositorySlug slug, String name, String color) {
return github.postJSON('/repos/${slug.fullName}/labels',
body: GitHubJson.encode({'name': name, 'color': color}),
convert: IssueLabel.fromJson);
RepositorySlug slug,
String name, {
String? color,
String? description,
}) {
return github.postJSON(
'/repos/${slug.fullName}/labels',
body: GitHubJson.encode({
'name': name,
if (color != null) 'color': color,
if (description != null) 'description': description,
}),
convert: IssueLabel.fromJson,
);
}

/// Edits a label.
///
/// API docs: https://developer.github.com/v3/issues/labels/#update-a-label
@Deprecated('See updateLabel instead.')
Future<IssueLabel> editLabel(RepositorySlug slug, String name, String color) {
return github.postJSON('/repos/${slug.fullName}/labels/$name',
body: GitHubJson.encode({'name': name, 'color': color}),
convert: IssueLabel.fromJson);
return updateLabel(slug, name, color: color);
}

/// Update a label.
///
/// API docs: https://developer.github.com/v3/issues/labels/#update-a-label
Future<IssueLabel> updateLabel(
devoncarew marked this conversation as resolved.
Show resolved Hide resolved
RepositorySlug slug,
String name, {
String? newName,
String? color,
String? description,
}) {
return github.patchJSON(
'/repos/${slug.fullName}/labels/$name',
body: GitHubJson.encode({
if (newName != null) 'new_name': newName,
if (color != null) 'color': color,
if (description != null) 'description': description,
}),
convert: IssueLabel.fromJson,
);
}

/// Deletes a label.
Expand Down
3 changes: 3 additions & 0 deletions lib/src/common/model/issues.dart
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,15 @@ class IssueLabel {
IssueLabel({
this.name = '',
this.color = '',
this.description = '',
});

String name;

String color;

String description;

factory IssueLabel.fromJson(Map<String, dynamic> input) =>
_$IssueLabelFromJson(input);
Map<String, dynamic> toJson() => _$IssueLabelToJson(this);
Expand Down
2 changes: 2 additions & 0 deletions lib/src/common/model/issues.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.