Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing endpoints to Reactions #1637

Merged
merged 2 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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