-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgithub-api-client.ts
30 lines (25 loc) · 980 Bytes
/
github-api-client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import { getOctokit } from "@actions/github";
import type { GitHub } from "@actions/github/lib/utils";
import { GitHubIssue, GitHubIssueReference } from "./models";
export class GitHubApiClient {
private readonly client: InstanceType<typeof GitHub>;
constructor(accessToken: string) {
this.client = getOctokit(accessToken);
}
public async getIssue(issueRef: GitHubIssueReference): Promise<GitHubIssue> {
const response = await this.client.rest.issues.get({
owner: issueRef.repoOwner,
repo: issueRef.repoName,
issue_number: issueRef.issueNumber,
});
return response.data;
}
public async updateIssueContent(issueRef: GitHubIssueReference, body: string): Promise<void> {
await this.client.rest.issues.update({
owner: issueRef.repoOwner,
repo: issueRef.repoName,
issue_number: issueRef.issueNumber,
body: body,
});
}
}