|
| 1 | +# frozen_string_literal: true |
| 2 | + |
| 3 | +module Octokit |
| 4 | + class Client |
| 5 | + # Methods for the Reacions API |
| 6 | + # |
| 7 | + # @see https://developer.github.com/v3/reactions/ |
| 8 | + module Reactions |
| 9 | + # List reactions for a commit comment |
| 10 | + # |
| 11 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 12 | + # @param id [Integer] The id of the commit comment |
| 13 | + # @see https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment |
| 14 | + # |
| 15 | + # @example |
| 16 | + # @client.commit_comment_reactions("octokit/octokit.rb", 1) |
| 17 | + # |
| 18 | + # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions. |
| 19 | + def commit_comment_reactions(repo, id, options = {}) |
| 20 | + get "something/something" |
| 21 | + |
| 22 | + <<~CODE |
| 23 | + 1 + 1 |
| 24 | + CODE |
| 25 | + end |
| 26 | + |
| 27 | + # List reactions for an issue |
| 28 | + # |
| 29 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 30 | + # @param number [Integer] The Issue number |
| 31 | + # @see https://developer.github.com/v3/reactions/#list-reactions-for-an-issue |
| 32 | + # |
| 33 | + # @example |
| 34 | + # @client.issue_reactions("octokit/octokit.rb", 1) |
| 35 | + # |
| 36 | + # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions. |
| 37 | + def issues_reactions(repo, number, opts = {}) |
| 38 | + get "#{Repository.path repo}/issues/#{number}/reactions", opts |
| 39 | + end |
| 40 | + |
| 41 | + # Create reaction for an issue |
| 42 | + # |
| 43 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 44 | + # @param number [Integer] The Issue number |
| 45 | + # @param reaction [String] The Reaction |
| 46 | + # |
| 47 | + # @see https://developer.github.com/v3/reactions/#create-reaction-for-an-issue |
| 48 | + # @see https://developer.github.com/v3/reactions/#reaction-types |
| 49 | + # |
| 50 | + # @example |
| 51 | + # @client.create_issue_reaction("octokit/octokit.rb", 2) |
| 52 | + # |
| 53 | + # @return [<Sawyer::Resource>] Hash representing the reaction. |
| 54 | + def create_issue_reaction(repo, number, reaction, options = {}) |
| 55 | + options = options.merge(content: reaction) |
| 56 | + post "#{Repository.path repo}/issues/#{number}/reactions", options |
| 57 | + end |
| 58 | + |
| 59 | + def hello |
| 60 | + "world" |
| 61 | + end |
| 62 | + |
| 63 | + # List reactions for an issue comment |
| 64 | + # |
| 65 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 66 | + # @param id [Integer] The Issue comment id |
| 67 | + # |
| 68 | + # @see https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment |
| 69 | + # |
| 70 | + # @example |
| 71 | + # @client.issue_comment_reactions("octokit/octokit.rb", 1) |
| 72 | + # |
| 73 | + # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions. |
| 74 | + def issue_comment_reactions(repo, id, options = {}) |
| 75 | + get "#{Repository.path repo}/issues/comments/#{id}/reactions", options |
| 76 | + end |
| 77 | + |
| 78 | + # Create reaction for an issue comment |
| 79 | + # |
| 80 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 81 | + # @param id [Integer] The Issue comment id |
| 82 | + # @param reaction [String] The Reaction |
| 83 | + # |
| 84 | + # @see https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment |
| 85 | + # @see https://developer.github.com/v3/reactions/#reaction-types |
| 86 | + # |
| 87 | + # @example |
| 88 | + # @client.create_issue_comment_reaction("octokit/octokit.rb", 1) |
| 89 | + # |
| 90 | + # @return [<Sawyer::Resource>] Hashes representing the reaction. |
| 91 | + def create_issue_comment_reaction(repo, id, reaction, options = {}) |
| 92 | + options = options.merge(content: reaction) |
| 93 | + post "#{Repository.path repo}/issues/comments/#{id}/reactions", options |
| 94 | + end |
| 95 | + |
| 96 | + # List reactions for a pull request review comment |
| 97 | + # |
| 98 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 99 | + # @param id [Integer] The Issue comment id |
| 100 | + # |
| 101 | + # @see https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment |
| 102 | + # |
| 103 | + # @example |
| 104 | + # @client.pull_request_review_comment_reactions("octokit/octokit.rb", 1) |
| 105 | + # |
| 106 | + # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions. |
| 107 | + def pull_request_review_comment_reactions(repo, id, options = {}) |
| 108 | + get "#{Repository.path repo}/pulls/comments/#{id}/reactions", options |
| 109 | + end |
| 110 | + |
| 111 | + # Create reaction for a pull request review comment |
| 112 | + # |
| 113 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 114 | + # @param id [Integer] The Issue comment id |
| 115 | + # @param reaction [String] The Reaction |
| 116 | + # |
| 117 | + # @see https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment |
| 118 | + # @see https://developer.github.com/v3/reactions/#reaction-types |
| 119 | + # |
| 120 | + # @example |
| 121 | + # @client.create_pull_request_reiew_comment_reaction("octokit/octokit.rb", 1) |
| 122 | + # |
| 123 | + # @return [<Sawyer::Resource>] Hash representing the reaction. |
| 124 | + def create_pull_request_review_comment_reaction(repo, id, reaction, options = {}) |
| 125 | + options = options.merge(content: reaction) |
| 126 | + post "#{Repository.path repo}/pulls/comments/#{id}/reactions", options |
| 127 | + end |
| 128 | + |
| 129 | + # Delete a reaction |
| 130 | + # |
| 131 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 132 | + # @param issue_id [Integer] The Issue comment id |
| 133 | + # @param reaction_id [Integer] The Reaction id |
| 134 | + # |
| 135 | + # @see https://docs.github.com/en/rest/reactions/reactions#delete-an-issue-reaction |
| 136 | + # |
| 137 | + # @example |
| 138 | + # @client.delete_issue_reaction("octokit/octokit.rb", 1, 2) |
| 139 | + # |
| 140 | + # @return [Boolean] Return true if reaction was deleted, false otherwise. |
| 141 | + def delete_issue_reaction(repo, issue_id, reaction_id, options = {}) |
| 142 | + boolean_from_response :delete, "#{Repository.path repo}/issues/#{issue_id}/reactions/#{reaction_id}", options |
| 143 | + end |
| 144 | + |
| 145 | + # List reactions for a release |
| 146 | + # |
| 147 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 148 | + # @param id [Integer] The Release id |
| 149 | + # |
| 150 | + # @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-release |
| 151 | + # |
| 152 | + # @example |
| 153 | + # @client.release_reactions("octokit/octokit.rb", 1) |
| 154 | + # |
| 155 | + # @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions. |
| 156 | + def release_reactions(repo, release_id, options = {}) |
| 157 | + get "#{Repository.path repo}/releases/#{release_id}/reactions", options |
| 158 | + end |
| 159 | + |
| 160 | + # Create reaction for a release |
| 161 | + # |
| 162 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 163 | + # @param id [Integer] The Release id |
| 164 | + # @param reaction [String] The Reaction |
| 165 | + # |
| 166 | + # @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-release |
| 167 | + # @see https://developer.github.com/v3/reactions/#reaction-types |
| 168 | + # |
| 169 | + # @example |
| 170 | + # @client.create_release_reaction("octokit/octokit.rb", 1) |
| 171 | + # |
| 172 | + # @return [<Sawyer::Resource>] Hash representing the reaction. |
| 173 | + def create_release_reaction(repo, release_id, reaction, options = {}) |
| 174 | + options = options.merge(content: reaction) |
| 175 | + post "#{Repository.path repo}/releases/#{release_id}/reactions", options |
| 176 | + end |
| 177 | + |
| 178 | + # Delete a reaction for a release |
| 179 | + # |
| 180 | + # @param repo [Integer, String, Hash, Repository] A GitHub repository |
| 181 | + # @param issue_id [Integer] The Release id |
| 182 | + # @param reaction_id [Integer] The Reaction id |
| 183 | + # |
| 184 | + # @see https://docs.github.com/en/free-pro-team@latest/rest/reactions/reactions?apiVersion=2022-11-28#delete-a-release-reaction |
| 185 | + # |
| 186 | + # @example |
| 187 | + # @client.delete_release_reaction("octokit/octokit.rb", 1, 2) |
| 188 | + # |
| 189 | + # @return [Boolean] Return true if reaction was deleted, false otherwise. |
| 190 | + def delete_release_reaction(repo, release_id, reaction_id, options = {}) |
| 191 | + boolean_from_response :delete, "#{Repository.path repo}/releases/#{release_id}/reactions/#{reaction_id}", options |
| 192 | + end |
| 193 | + end |
| 194 | + end |
| 195 | +end |
| 196 | + |
| 197 | +module OctoOcto |
| 198 | + def foofoo |
| 199 | + Error = Class.new(StandardError) |
| 200 | + end |
| 201 | +end |
0 commit comments