Skip to content

Commit

Permalink
Add missing endpoints to Reactions (#1637)
Browse files Browse the repository at this point in the history
* Add release_reactions, create_release_reactions and delete_release_reactions

* fix tests
  • Loading branch information
wJoenn authored Oct 27, 2023
1 parent 8e5d848 commit 0ffe565
Show file tree
Hide file tree
Showing 5 changed files with 2,714 additions and 0 deletions.
49 changes: 49 additions & 0 deletions lib/octokit/client/reactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,55 @@ def create_pull_request_review_comment_reaction(repo, id, reaction, options = {}
def delete_issue_reaction(repo, issue_id, reaction_id, options = {})
boolean_from_response :delete, "#{Repository.path repo}/issues/#{issue_id}/reactions/#{reaction_id}", options
end

# List reactions for a release
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The Release id
#
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-release
#
# @example
# @client.release_reactions("octokit/octokit.rb", 1)
#
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
def release_reactions(repo, release_id, options = {})
get "#{Repository.path repo}/releases/#{release_id}/reactions", options
end

# Create reaction for a release
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The Release id
# @param reaction [String] The Reaction
#
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-release
# @see https://developer.github.com/v3/reactions/#reaction-types
#
# @example
# @client.create_release_reaction("octokit/octokit.rb", 1)
#
# @return [<Sawyer::Resource>] Hash representing the reaction.
def create_release_reaction(repo, release_id, reaction, options = {})
options = options.merge(content: reaction)
post "#{Repository.path repo}/releases/#{release_id}/reactions", options
end

# Delete a reaction for a release
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param issue_id [Integer] The Release id
# @param reaction_id [Integer] The Reaction id
#
# @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#delete-a-release-reaction
#
# @example
# @client.delete_release_reaction("octokit/octokit.rb", 1, 2)
#
# @return [Boolean] Return true if reaction was deleted, false otherwise.
def delete_release_reaction(repo, release_id, reaction_id, options = {})
boolean_from_response :delete, "#{Repository.path repo}/releases/#{release_id}/reactions/#{reaction_id}", options
end
end
end
end
Loading

0 comments on commit 0ffe565

Please sign in to comment.