github.com/google/go-github/v70@v70.0.0/github/reactions.go (about) 1 // Copyright 2016 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "context" 10 "fmt" 11 "net/http" 12 ) 13 14 // ReactionsService provides access to the reactions-related functions in the 15 // GitHub API. 16 // 17 // GitHub API docs: https://docs.github.com/rest/reactions 18 type ReactionsService service 19 20 // Reaction represents a GitHub reaction. 21 type Reaction struct { 22 // ID is the Reaction ID. 23 ID *int64 `json:"id,omitempty"` 24 User *User `json:"user,omitempty"` 25 NodeID *string `json:"node_id,omitempty"` 26 // Content is the type of reaction. 27 // Possible values are: 28 // "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 29 Content *string `json:"content,omitempty"` 30 CreatedAt *Timestamp `json:"created_at,omitempty"` 31 } 32 33 // Reactions represents a summary of GitHub reactions. 34 type Reactions struct { 35 TotalCount *int `json:"total_count,omitempty"` 36 PlusOne *int `json:"+1,omitempty"` 37 MinusOne *int `json:"-1,omitempty"` 38 Laugh *int `json:"laugh,omitempty"` 39 Confused *int `json:"confused,omitempty"` 40 Heart *int `json:"heart,omitempty"` 41 Hooray *int `json:"hooray,omitempty"` 42 Rocket *int `json:"rocket,omitempty"` 43 Eyes *int `json:"eyes,omitempty"` 44 URL *string `json:"url,omitempty"` 45 } 46 47 func (r Reaction) String() string { 48 return Stringify(r) 49 } 50 51 // ListCommentReactionOptions specifies the optional parameters to the 52 // ReactionsService.ListCommentReactions method. 53 type ListCommentReactionOptions struct { 54 // Content restricts the returned comment reactions to only those with the given type. 55 // Omit this parameter to list all reactions to a commit comment. 56 // Possible values are: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 57 Content string `url:"content,omitempty"` 58 59 ListOptions 60 } 61 62 // ListCommentReactions lists the reactions for a commit comment. 63 // 64 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-commit-comment 65 // 66 //meta:operation GET /repos/{owner}/{repo}/comments/{comment_id}/reactions 67 func (s *ReactionsService) ListCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListCommentReactionOptions) ([]*Reaction, *Response, error) { 68 u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions", owner, repo, id) 69 u, err := addOptions(u, opts) 70 if err != nil { 71 return nil, nil, err 72 } 73 74 req, err := s.client.NewRequest("GET", u, nil) 75 if err != nil { 76 return nil, nil, err 77 } 78 79 // TODO: remove custom Accept headers when APIs fully launch. 80 req.Header.Set("Accept", mediaTypeReactionsPreview) 81 82 var m []*Reaction 83 resp, err := s.client.Do(ctx, req, &m) 84 if err != nil { 85 return nil, resp, err 86 } 87 88 return m, resp, nil 89 } 90 91 // CreateCommentReaction creates a reaction for a commit comment. 92 // Note that if you have already created a reaction of type content, the 93 // previously created reaction will be returned with Status: 200 OK. 94 // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 95 // 96 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-commit-comment 97 // 98 //meta:operation POST /repos/{owner}/{repo}/comments/{comment_id}/reactions 99 func (s *ReactionsService) CreateCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { 100 u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions", owner, repo, id) 101 102 body := &Reaction{Content: Ptr(content)} 103 req, err := s.client.NewRequest("POST", u, body) 104 if err != nil { 105 return nil, nil, err 106 } 107 108 // TODO: remove custom Accept headers when APIs fully launch. 109 req.Header.Set("Accept", mediaTypeReactionsPreview) 110 111 m := &Reaction{} 112 resp, err := s.client.Do(ctx, req, m) 113 if err != nil { 114 return nil, resp, err 115 } 116 117 return m, resp, nil 118 } 119 120 // DeleteCommentReaction deletes the reaction for a commit comment. 121 // 122 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-a-commit-comment-reaction 123 // 124 //meta:operation DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id} 125 func (s *ReactionsService) DeleteCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) { 126 u := fmt.Sprintf("repos/%v/%v/comments/%v/reactions/%v", owner, repo, commentID, reactionID) 127 128 return s.deleteReaction(ctx, u) 129 } 130 131 // DeleteCommentReactionByID deletes the reaction for a commit comment by repository ID. 132 // 133 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-a-commit-comment-reaction 134 // 135 //meta:operation DELETE /repos/{owner}/{repo}/comments/{comment_id}/reactions/{reaction_id} 136 func (s *ReactionsService) DeleteCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) { 137 u := fmt.Sprintf("repositories/%v/comments/%v/reactions/%v", repoID, commentID, reactionID) 138 139 return s.deleteReaction(ctx, u) 140 } 141 142 // ListIssueReactions lists the reactions for an issue. 143 // 144 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#list-reactions-for-an-issue 145 // 146 //meta:operation GET /repos/{owner}/{repo}/issues/{issue_number}/reactions 147 func (s *ReactionsService) ListIssueReactions(ctx context.Context, owner, repo string, number int, opts *ListOptions) ([]*Reaction, *Response, error) { 148 u := fmt.Sprintf("repos/%v/%v/issues/%v/reactions", owner, repo, number) 149 u, err := addOptions(u, opts) 150 if err != nil { 151 return nil, nil, err 152 } 153 154 req, err := s.client.NewRequest("GET", u, nil) 155 if err != nil { 156 return nil, nil, err 157 } 158 159 // TODO: remove custom Accept headers when APIs fully launch. 160 req.Header.Set("Accept", mediaTypeReactionsPreview) 161 162 var m []*Reaction 163 resp, err := s.client.Do(ctx, req, &m) 164 if err != nil { 165 return nil, resp, err 166 } 167 168 return m, resp, nil 169 } 170 171 // CreateIssueReaction creates a reaction for an issue. 172 // Note that if you have already created a reaction of type content, the 173 // previously created reaction will be returned with Status: 200 OK. 174 // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 175 // 176 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-an-issue 177 // 178 //meta:operation POST /repos/{owner}/{repo}/issues/{issue_number}/reactions 179 func (s *ReactionsService) CreateIssueReaction(ctx context.Context, owner, repo string, number int, content string) (*Reaction, *Response, error) { 180 u := fmt.Sprintf("repos/%v/%v/issues/%v/reactions", owner, repo, number) 181 182 body := &Reaction{Content: Ptr(content)} 183 req, err := s.client.NewRequest("POST", u, body) 184 if err != nil { 185 return nil, nil, err 186 } 187 188 // TODO: remove custom Accept headers when APIs fully launch. 189 req.Header.Set("Accept", mediaTypeReactionsPreview) 190 191 m := &Reaction{} 192 resp, err := s.client.Do(ctx, req, m) 193 if err != nil { 194 return nil, resp, err 195 } 196 197 return m, resp, nil 198 } 199 200 // DeleteIssueReaction deletes the reaction to an issue. 201 // 202 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-an-issue-reaction 203 // 204 //meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id} 205 func (s *ReactionsService) DeleteIssueReaction(ctx context.Context, owner, repo string, issueNumber int, reactionID int64) (*Response, error) { 206 url := fmt.Sprintf("repos/%v/%v/issues/%v/reactions/%v", owner, repo, issueNumber, reactionID) 207 208 return s.deleteReaction(ctx, url) 209 } 210 211 // DeleteIssueReactionByID deletes the reaction to an issue by repository ID. 212 // 213 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-an-issue-reaction 214 // 215 //meta:operation DELETE /repos/{owner}/{repo}/issues/{issue_number}/reactions/{reaction_id} 216 func (s *ReactionsService) DeleteIssueReactionByID(ctx context.Context, repoID, issueNumber int, reactionID int64) (*Response, error) { 217 url := fmt.Sprintf("repositories/%v/issues/%v/reactions/%v", repoID, issueNumber, reactionID) 218 219 return s.deleteReaction(ctx, url) 220 } 221 222 // ListIssueCommentReactions lists the reactions for an issue comment. 223 // 224 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#list-reactions-for-an-issue-comment 225 // 226 //meta:operation GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions 227 func (s *ReactionsService) ListIssueCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*Reaction, *Response, error) { 228 u := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions", owner, repo, id) 229 u, err := addOptions(u, opts) 230 if err != nil { 231 return nil, nil, err 232 } 233 234 req, err := s.client.NewRequest("GET", u, nil) 235 if err != nil { 236 return nil, nil, err 237 } 238 239 // TODO: remove custom Accept headers when APIs fully launch. 240 req.Header.Set("Accept", mediaTypeReactionsPreview) 241 242 var m []*Reaction 243 resp, err := s.client.Do(ctx, req, &m) 244 if err != nil { 245 return nil, resp, err 246 } 247 248 return m, resp, nil 249 } 250 251 // CreateIssueCommentReaction creates a reaction for an issue comment. 252 // Note that if you have already created a reaction of type content, the 253 // previously created reaction will be returned with Status: 200 OK. 254 // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 255 // 256 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-an-issue-comment 257 // 258 //meta:operation POST /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions 259 func (s *ReactionsService) CreateIssueCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { 260 u := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions", owner, repo, id) 261 262 body := &Reaction{Content: Ptr(content)} 263 req, err := s.client.NewRequest("POST", u, body) 264 if err != nil { 265 return nil, nil, err 266 } 267 268 // TODO: remove custom Accept headers when APIs fully launch. 269 req.Header.Set("Accept", mediaTypeReactionsPreview) 270 271 m := &Reaction{} 272 resp, err := s.client.Do(ctx, req, m) 273 if err != nil { 274 return nil, resp, err 275 } 276 277 return m, resp, nil 278 } 279 280 // DeleteIssueCommentReaction deletes the reaction to an issue comment. 281 // 282 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-an-issue-comment-reaction 283 // 284 //meta:operation DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id} 285 func (s *ReactionsService) DeleteIssueCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) { 286 url := fmt.Sprintf("repos/%v/%v/issues/comments/%v/reactions/%v", owner, repo, commentID, reactionID) 287 288 return s.deleteReaction(ctx, url) 289 } 290 291 // DeleteIssueCommentReactionByID deletes the reaction to an issue comment by repository ID. 292 // 293 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-an-issue-comment-reaction 294 // 295 //meta:operation DELETE /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions/{reaction_id} 296 func (s *ReactionsService) DeleteIssueCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) { 297 url := fmt.Sprintf("repositories/%v/issues/comments/%v/reactions/%v", repoID, commentID, reactionID) 298 299 return s.deleteReaction(ctx, url) 300 } 301 302 // ListPullRequestCommentReactions lists the reactions for a pull request review comment. 303 // 304 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-pull-request-review-comment 305 // 306 //meta:operation GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions 307 func (s *ReactionsService) ListPullRequestCommentReactions(ctx context.Context, owner, repo string, id int64, opts *ListOptions) ([]*Reaction, *Response, error) { 308 u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions", owner, repo, id) 309 u, err := addOptions(u, opts) 310 if err != nil { 311 return nil, nil, err 312 } 313 314 req, err := s.client.NewRequest("GET", u, nil) 315 if err != nil { 316 return nil, nil, err 317 } 318 319 // TODO: remove custom Accept headers when APIs fully launch. 320 req.Header.Set("Accept", mediaTypeReactionsPreview) 321 322 var m []*Reaction 323 resp, err := s.client.Do(ctx, req, &m) 324 if err != nil { 325 return nil, resp, err 326 } 327 328 return m, resp, nil 329 } 330 331 // CreatePullRequestCommentReaction creates a reaction for a pull request review comment. 332 // Note that if you have already created a reaction of type content, the 333 // previously created reaction will be returned with Status: 200 OK. 334 // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 335 // 336 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-pull-request-review-comment 337 // 338 //meta:operation POST /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions 339 func (s *ReactionsService) CreatePullRequestCommentReaction(ctx context.Context, owner, repo string, id int64, content string) (*Reaction, *Response, error) { 340 u := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions", owner, repo, id) 341 342 body := &Reaction{Content: Ptr(content)} 343 req, err := s.client.NewRequest("POST", u, body) 344 if err != nil { 345 return nil, nil, err 346 } 347 348 // TODO: remove custom Accept headers when APIs fully launch. 349 req.Header.Set("Accept", mediaTypeReactionsPreview) 350 351 m := &Reaction{} 352 resp, err := s.client.Do(ctx, req, m) 353 if err != nil { 354 return nil, resp, err 355 } 356 357 return m, resp, nil 358 } 359 360 // DeletePullRequestCommentReaction deletes the reaction to a pull request review comment. 361 // 362 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-a-pull-request-comment-reaction 363 // 364 //meta:operation DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id} 365 func (s *ReactionsService) DeletePullRequestCommentReaction(ctx context.Context, owner, repo string, commentID, reactionID int64) (*Response, error) { 366 url := fmt.Sprintf("repos/%v/%v/pulls/comments/%v/reactions/%v", owner, repo, commentID, reactionID) 367 368 return s.deleteReaction(ctx, url) 369 } 370 371 // DeletePullRequestCommentReactionByID deletes the reaction to a pull request review comment by repository ID. 372 // 373 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-a-pull-request-comment-reaction 374 // 375 //meta:operation DELETE /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions/{reaction_id} 376 func (s *ReactionsService) DeletePullRequestCommentReactionByID(ctx context.Context, repoID, commentID, reactionID int64) (*Response, error) { 377 url := fmt.Sprintf("repositories/%v/pulls/comments/%v/reactions/%v", repoID, commentID, reactionID) 378 379 return s.deleteReaction(ctx, url) 380 } 381 382 // ListTeamDiscussionReactions lists the reactions for a team discussion. 383 // 384 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-team-discussion-legacy 385 // 386 //meta:operation GET /teams/{team_id}/discussions/{discussion_number}/reactions 387 func (s *ReactionsService) ListTeamDiscussionReactions(ctx context.Context, teamID int64, discussionNumber int, opts *ListOptions) ([]*Reaction, *Response, error) { 388 u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber) 389 u, err := addOptions(u, opts) 390 if err != nil { 391 return nil, nil, err 392 } 393 394 req, err := s.client.NewRequest("GET", u, nil) 395 if err != nil { 396 return nil, nil, err 397 } 398 399 req.Header.Set("Accept", mediaTypeReactionsPreview) 400 401 var m []*Reaction 402 resp, err := s.client.Do(ctx, req, &m) 403 if err != nil { 404 return nil, resp, err 405 } 406 407 return m, resp, nil 408 } 409 410 // CreateTeamDiscussionReaction creates a reaction for a team discussion. 411 // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 412 // 413 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-team-discussion-legacy 414 // 415 //meta:operation POST /teams/{team_id}/discussions/{discussion_number}/reactions 416 func (s *ReactionsService) CreateTeamDiscussionReaction(ctx context.Context, teamID int64, discussionNumber int, content string) (*Reaction, *Response, error) { 417 u := fmt.Sprintf("teams/%v/discussions/%v/reactions", teamID, discussionNumber) 418 419 body := &Reaction{Content: Ptr(content)} 420 req, err := s.client.NewRequest("POST", u, body) 421 if err != nil { 422 return nil, nil, err 423 } 424 425 req.Header.Set("Accept", mediaTypeReactionsPreview) 426 427 m := &Reaction{} 428 resp, err := s.client.Do(ctx, req, m) 429 if err != nil { 430 return nil, resp, err 431 } 432 433 return m, resp, nil 434 } 435 436 // DeleteTeamDiscussionReaction deletes the reaction to a team discussion. 437 // 438 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-team-discussion-reaction 439 // 440 //meta:operation DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions/{reaction_id} 441 func (s *ReactionsService) DeleteTeamDiscussionReaction(ctx context.Context, org, teamSlug string, discussionNumber int, reactionID int64) (*Response, error) { 442 url := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/reactions/%v", org, teamSlug, discussionNumber, reactionID) 443 444 return s.deleteReaction(ctx, url) 445 } 446 447 // DeleteTeamDiscussionReactionByOrgIDAndTeamID deletes the reaction to a team discussion by organization ID and team ID. 448 // 449 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-team-discussion 450 // 451 //meta:operation POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions 452 func (s *ReactionsService) DeleteTeamDiscussionReactionByOrgIDAndTeamID(ctx context.Context, orgID, teamID, discussionNumber int, reactionID int64) (*Response, error) { 453 url := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/reactions/%v", orgID, teamID, discussionNumber, reactionID) 454 455 return s.deleteReaction(ctx, url) 456 } 457 458 // ListTeamDiscussionCommentReactions lists the reactions for a team discussion comment. 459 // 460 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#list-reactions-for-a-team-discussion-comment-legacy 461 // 462 //meta:operation GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions 463 func (s *ReactionsService) ListTeamDiscussionCommentReactions(ctx context.Context, teamID int64, discussionNumber, commentNumber int, opts *ListOptions) ([]*Reaction, *Response, error) { 464 u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber) 465 u, err := addOptions(u, opts) 466 if err != nil { 467 return nil, nil, err 468 } 469 470 req, err := s.client.NewRequest("GET", u, nil) 471 if err != nil { 472 return nil, nil, err 473 } 474 475 req.Header.Set("Accept", mediaTypeReactionsPreview) 476 477 var m []*Reaction 478 resp, err := s.client.Do(ctx, req, &m) 479 if err != nil { 480 return nil, resp, err 481 } 482 return m, resp, nil 483 } 484 485 // CreateTeamDiscussionCommentReaction creates a reaction for a team discussion comment. 486 // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 487 // 488 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-team-discussion-comment-legacy 489 // 490 //meta:operation POST /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions 491 func (s *ReactionsService) CreateTeamDiscussionCommentReaction(ctx context.Context, teamID int64, discussionNumber, commentNumber int, content string) (*Reaction, *Response, error) { 492 u := fmt.Sprintf("teams/%v/discussions/%v/comments/%v/reactions", teamID, discussionNumber, commentNumber) 493 494 body := &Reaction{Content: Ptr(content)} 495 req, err := s.client.NewRequest("POST", u, body) 496 if err != nil { 497 return nil, nil, err 498 } 499 500 req.Header.Set("Accept", mediaTypeReactionsPreview) 501 502 m := &Reaction{} 503 resp, err := s.client.Do(ctx, req, m) 504 if err != nil { 505 return nil, resp, err 506 } 507 508 return m, resp, nil 509 } 510 511 // DeleteTeamDiscussionCommentReaction deletes the reaction to a team discussion comment. 512 // 513 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#delete-team-discussion-comment-reaction 514 // 515 //meta:operation DELETE /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions/{reaction_id} 516 func (s *ReactionsService) DeleteTeamDiscussionCommentReaction(ctx context.Context, org, teamSlug string, discussionNumber, commentNumber int, reactionID int64) (*Response, error) { 517 url := fmt.Sprintf("orgs/%v/teams/%v/discussions/%v/comments/%v/reactions/%v", org, teamSlug, discussionNumber, commentNumber, reactionID) 518 519 return s.deleteReaction(ctx, url) 520 } 521 522 // DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID deletes the reaction to a team discussion comment by organization ID and team ID. 523 // 524 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-team-discussion-comment 525 // 526 //meta:operation POST /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions 527 func (s *ReactionsService) DeleteTeamDiscussionCommentReactionByOrgIDAndTeamID(ctx context.Context, orgID, teamID, discussionNumber, commentNumber int, reactionID int64) (*Response, error) { 528 url := fmt.Sprintf("organizations/%v/team/%v/discussions/%v/comments/%v/reactions/%v", orgID, teamID, discussionNumber, commentNumber, reactionID) 529 530 return s.deleteReaction(ctx, url) 531 } 532 533 func (s *ReactionsService) deleteReaction(ctx context.Context, url string) (*Response, error) { 534 req, err := s.client.NewRequest(http.MethodDelete, url, nil) 535 if err != nil { 536 return nil, err 537 } 538 539 // TODO: remove custom Accept headers when APIs fully launch. 540 req.Header.Set("Accept", mediaTypeReactionsPreview) 541 542 return s.client.Do(ctx, req, nil) 543 } 544 545 // CreateReleaseReaction creates a reaction to a release. 546 // Note that a response with a Status: 200 OK means that you already 547 // added the reaction type to this release. 548 // The content should have one of the following values: "+1", "-1", "laugh", "confused", "heart", "hooray", "rocket", or "eyes". 549 // 550 // GitHub API docs: https://docs.github.com/rest/reactions/reactions#create-reaction-for-a-release 551 // 552 //meta:operation POST /repos/{owner}/{repo}/releases/{release_id}/reactions 553 func (s *ReactionsService) CreateReleaseReaction(ctx context.Context, owner, repo string, releaseID int64, content string) (*Reaction, *Response, error) { 554 u := fmt.Sprintf("repos/%v/%v/releases/%v/reactions", owner, repo, releaseID) 555 556 body := &Reaction{Content: Ptr(content)} 557 req, err := s.client.NewRequest("POST", u, body) 558 if err != nil { 559 return nil, nil, err 560 } 561 562 req.Header.Set("Accept", mediaTypeReactionsPreview) 563 564 m := &Reaction{} 565 resp, err := s.client.Do(ctx, req, m) 566 if err != nil { 567 return nil, resp, err 568 } 569 570 return m, resp, nil 571 }