Skip to content

Commit 4effb60

Browse files
authored
Implement IssuesService.lock/unlock (#376)
1 parent 7e01a0d commit 4effb60

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

lib/src/common/issues_service.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,30 @@ class IssuesService extends Service {
443443
TimelineEvent.fromJson,
444444
);
445445
}
446+
447+
/// Lock an issue.
448+
///
449+
/// API docs: https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#lock-an-issue
450+
///
451+
/// The `lockReason`, if specified, must be one of: `off-topic`, `too heated`, `resolved`, `spam`.
452+
Future<void> lock(RepositorySlug slug, int number,
453+
{String? lockReason}) async {
454+
String body;
455+
if (lockReason != null) {
456+
body = GitHubJson.encode({'lock_reason': lockReason});
457+
} else {
458+
body = '{}';
459+
}
460+
await github.postJSON('/repos/${slug.fullName}/issues/$number/lock',
461+
body: body, statusCode: 204);
462+
}
463+
464+
/// Unlock an issue.
465+
///
466+
/// API docs: https://docs.github.com/en/rest/issues/issues?apiVersion=2022-11-28#unlock-an-issue
467+
Future<void> unlock(RepositorySlug slug, int number) async {
468+
await github.request(
469+
'DELETE', '/repos/${slug.fullName}/issues/$number/lock',
470+
statusCode: 204);
471+
}
446472
}

0 commit comments

Comments
 (0)