Skip to content

Commit

Permalink
Implement IssuesService.lock/unlock
Browse files Browse the repository at this point in the history
  • Loading branch information
Hixie committed Jun 16, 2023
1 parent 7e01a0d commit 9948047
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions lib/src/common/issues_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -443,4 +443,27 @@ class IssuesService extends Service {
TimelineEvent.fromJson,
);
}

/// Lock an issue.
///
/// API docs: https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#lock-an-issue
///
/// The `lockReason`, if specified, must be one of: `off-topic`, `too heated`, `resolved`, `spam`.
Future<void> lock(RepositorySlug slug, int number, { String? lockReason }) async {
String body;
if (lockReason != null) {
body = GitHubJson.encode({ 'lock_reason': lockReason });
} else {
body = '{}';
}
await github.postJSON('/repos/${slug.fullName}/issues/$number/lock',
body: body, statusCode: 204);
}

/// Unlock an issue.
///
/// API docs: https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#unlock-an-issue
Future<void> unlock(RepositorySlug slug, int number) async {
await github.request('DELETE', '/repos/${slug.fullName}/issues/$number/lock', statusCode: 204);
}
}

0 comments on commit 9948047

Please sign in to comment.