octokit / octokit.rb

Ruby toolkit for the GitHub API
http://octokit.github.io/octokit.rb/
MIT License
3.84k stars 1.13k forks source link

[FEAT]: add missing endpoints #1633

Closed wJoenn closed 11 months ago

wJoenn commented 1 year ago

Describe the need

Hey I've noticed some endpoints are missing from Octokit, specifically I've had a need to list, create and delete a release's reactions.

From what I can see it should be as easy as adding this to client/reactions.rb and throw in a couple tests which I'd be willing to do if you're open to the idea.

module Octokit
  class Client
    module Reactions
      # 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, id, options = {})
        get "#{Repository.path repo}/releases/#{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, id, reaction, options = {})
        options = options.merge(content: reaction)
        post "#{Repository.path repo}/releases/#{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

SDK Version

No response

API Version

2022-11-28

Relevant log output

No response

Code of Conduct

github-actions[bot] commented 1 year ago

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

nickfloyd commented 1 year ago

Hey thank you for highlighting these missing APIs. You are correct, until we can get to generative SDKs, the SDKs have to be added manually.

I am going to assign the labels hacktoberfest and Up for Grabs to signal to the community that this is something that has been verified and can be worked. It looks like you'd be up for this so please feel free to pick the issue up! Thank you again for all that you do for this community :heart: !