| 246 | func (r ReviewerTeam) sealedReviewerCandidate() {} |
| 247 | |
| 248 | func AddReview(client *Client, repo ghrepo.Interface, pr *PullRequest, input *PullRequestReviewInput) error { |
| 249 | var mutation struct { |
| 250 | AddPullRequestReview struct { |
| 251 | ClientMutationID string |
| 252 | } `graphql:"addPullRequestReview(input:$input)"` |
| 253 | } |
| 254 | |
| 255 | state := githubv4.PullRequestReviewEventComment |
| 256 | switch input.State { |
| 257 | case ReviewApprove: |
| 258 | state = githubv4.PullRequestReviewEventApprove |
| 259 | case ReviewRequestChanges: |
| 260 | state = githubv4.PullRequestReviewEventRequestChanges |
| 261 | } |
| 262 | |
| 263 | body := githubv4.String(input.Body) |
| 264 | variables := map[string]interface{}{ |
| 265 | "input": githubv4.AddPullRequestReviewInput{ |
| 266 | PullRequestID: pr.ID, |
| 267 | Event: &state, |
| 268 | Body: &body, |
| 269 | }, |
| 270 | } |
| 271 | |
| 272 | return client.Mutate(repo.RepoHost(), "PullRequestReviewAdd", &mutation, variables) |
| 273 | } |
| 274 | |
| 275 | // AddPullRequestReviews adds the given user and team reviewers to a pull request using the REST API. |
| 276 | // Team identifiers can be in "org/slug" format. |