|
| 1 | +require "uri" |
| 2 | +require "../models/repos" |
| 3 | +require "../models/reactions" |
| 4 | + |
| 5 | +module Octokit |
| 6 | + class Client |
| 7 | + # Methods for the Reactions API |
| 8 | + # |
| 9 | + # All "repo" params are constructed in the format of `<organization>/<repository>` |
| 10 | + # |
| 11 | + # **See Also:** |
| 12 | + # - [https://docs.github.com/en/rest/reactions/reactions](https://docs.github.com/en/rest/reactions/reactions) |
| 13 | + |
| 14 | + module Reactions |
| 15 | + # :nodoc: |
| 16 | + alias Repository = Models::Repository |
| 17 | + |
| 18 | + # :nodoc: |
| 19 | + alias Reaction = Models::Reaction |
| 20 | + |
| 21 | + # :nodoc: |
| 22 | + alias Reactions = Models::Reactions |
| 23 | + |
| 24 | + # List reactions for a commit comment |
| 25 | + # |
| 26 | + # **See Also:** |
| 27 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-commit-comment](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-commit-comment) |
| 28 | + # |
| 29 | + # **Examples:** |
| 30 | + # |
| 31 | + # List all the reactions for a commit comment |
| 32 | + # |
| 33 | + # ``` |
| 34 | + # Octokit.commit_comment_reactions("monsalisa/app", 123456) |
| 35 | + # ``` |
| 36 | + def commit_comment_reactions(repo : String, id : Int64, **options) |
| 37 | + get("#{Repository.path(repo)}/comments/#{id}/reactions", options) |
| 38 | + end |
| 39 | + |
| 40 | + # Create a reaction for a commit comment |
| 41 | + # |
| 42 | + # **See Also:** |
| 43 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-commit-comment](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-commit-comment) |
| 44 | + # |
| 45 | + # **Examples:** |
| 46 | + # |
| 47 | + # ``` |
| 48 | + # Octokit.create_commit_comment_reaction("monsalisa/app", 123456, "+1") |
| 49 | + # ``` |
| 50 | + def create_commit_comment_reaction(repo : String, id : Int64, reaction : String, **options) |
| 51 | + options = options.merge({json: {content: reaction}}) |
| 52 | + Reaction.from_json(post("#{Repository.path(repo)}/comments/#{id}/reactions", options)) |
| 53 | + end |
| 54 | + |
| 55 | + # List reactions for an issue |
| 56 | + # |
| 57 | + # **See Also:** |
| 58 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-an-issue](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-an-issue) |
| 59 | + # |
| 60 | + # **Examples:** |
| 61 | + # |
| 62 | + # ``` |
| 63 | + # Octokit.issue_reactions("monsalisa/app", 123456) |
| 64 | + # ``` |
| 65 | + def issue_reactions(repo : String, number : Int64, **options) |
| 66 | + get("#{Repository.path(repo)}/issues/#{number}/reactions", options) |
| 67 | + end |
| 68 | + |
| 69 | + # Create reaction for an issue |
| 70 | + # |
| 71 | + # **See Also:** |
| 72 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-an-issue](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-an-issue) |
| 73 | + # |
| 74 | + # **Examples:** |
| 75 | + # |
| 76 | + # ``` |
| 77 | + # Octokit.create_issue_reaction("monsalisa/app", 123456, "heart") |
| 78 | + # ``` |
| 79 | + def create_issue_reaction(repo : String, number : Int64, reaction : String, **options) |
| 80 | + options = options.merge({json: {content: reaction}}) |
| 81 | + Reaction.from_json(post("#{Repository.path(repo)}/issues/#{number}/reactions", options)) |
| 82 | + end |
| 83 | + |
| 84 | + # List reactions for an issue comment |
| 85 | + # |
| 86 | + # **See Also:** |
| 87 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-an-issue-comment](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-an-issue-comment) |
| 88 | + # |
| 89 | + # **Examples:** |
| 90 | + # |
| 91 | + # ``` |
| 92 | + # Octokit.issue_comment_reactions("monsalisa/app", 987654) |
| 93 | + # ``` |
| 94 | + def issue_comment_reactions(repo : String, id : Int64, **options) |
| 95 | + get("#{Repository.path(repo)}/issues/comments/#{id}/reactions", options) |
| 96 | + end |
| 97 | + |
| 98 | + # Create reaction for an issue comment |
| 99 | + # |
| 100 | + # **See Also:** |
| 101 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-an-issue-comment](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-an-issue-comment) |
| 102 | + # |
| 103 | + # **Examples:** |
| 104 | + # |
| 105 | + # ``` |
| 106 | + # Octokit.create_issue_comment_reaction("monsalisa/app", 987654, "laugh") |
| 107 | + # ``` |
| 108 | + def create_issue_comment_reaction(repo : String, id : Int64, reaction : String, **options) : Reaction |
| 109 | + options = options.merge({json: {content: reaction}}) |
| 110 | + Reaction.from_json(post("#{Repository.path(repo)}/issues/comments/#{id}/reactions", options)) |
| 111 | + end |
| 112 | + |
| 113 | + # Delete a reaction from an issue comment |
| 114 | + # |
| 115 | + # **See Also:** |
| 116 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-an-issue-comment-reaction](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-an-issue-comment-reaction) |
| 117 | + # |
| 118 | + # **Examples:** |
| 119 | + # |
| 120 | + # ``` |
| 121 | + # Octokit.delete_issue_comment_reaction("monsalisa/app", 987654, 123) |
| 122 | + # ``` |
| 123 | + def delete_issue_comment_reaction(repo : String, comment_id : Int64, reaction_id : Int64, **options) |
| 124 | + boolean_from_response(:delete, "#{Repository.path(repo)}/issues/comments/#{comment_id}/reactions/#{reaction_id}", options) |
| 125 | + end |
| 126 | + |
| 127 | + # List reactions for a pull request review comment |
| 128 | + # |
| 129 | + # **See Also:** |
| 130 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-pull-request-review-comment](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-pull-request-review-comment) |
| 131 | + # |
| 132 | + # **Examples:** |
| 133 | + # |
| 134 | + # ``` |
| 135 | + # Octokit.pull_request_review_comment_reactions("monsalisa/app", 555111) |
| 136 | + # ``` |
| 137 | + def pull_request_review_comment_reactions(repo : String, id : Int64, **options) |
| 138 | + get("#{Repository.path(repo)}/pulls/comments/#{id}/reactions", options) |
| 139 | + end |
| 140 | + |
| 141 | + # Create reaction for a pull request review comment |
| 142 | + # |
| 143 | + # **See Also:** |
| 144 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-pull-request-review-comment](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-pull-request-review-comment) |
| 145 | + # |
| 146 | + # **Examples:** |
| 147 | + # |
| 148 | + # ``` |
| 149 | + # Octokit.create_pull_request_review_comment_reaction("monsalisa/app", 555111, "hooray") |
| 150 | + # ``` |
| 151 | + def create_pull_request_review_comment_reaction(repo : String, id : Int64, reaction : String, **options) |
| 152 | + options = options.merge({json: {content: reaction}}) |
| 153 | + Reaction.from_json(post("#{Repository.path(repo)}/pulls/comments/#{id}/reactions", options)) |
| 154 | + end |
| 155 | + |
| 156 | + # Delete a reaction |
| 157 | + # |
| 158 | + # **See Also:** |
| 159 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-an-issue-reaction](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-an-issue-reaction) |
| 160 | + # |
| 161 | + # **Examples:** |
| 162 | + # |
| 163 | + # ``` |
| 164 | + # Octokit.delete_issue_reaction("monsalisa/app", 987654, 123) |
| 165 | + # ``` |
| 166 | + def delete_issue_reaction(repo : String, issue_id : Int64, reaction_id : Int64, **options) |
| 167 | + boolean_from_response(:delete, "#{Repository.path(repo)}/issues/#{issue_id}/reactions/#{reaction_id}", options) |
| 168 | + end |
| 169 | + |
| 170 | + # List reactions for a release |
| 171 | + # |
| 172 | + # **See Also:** |
| 173 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-release](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#list-reactions-for-a-release) |
| 174 | + # |
| 175 | + # **Examples:** |
| 176 | + # |
| 177 | + # ``` |
| 178 | + # Octokit.release_reactions("monsalisa/app", 987654) |
| 179 | + # ``` |
| 180 | + def release_reactions(repo : String, release_id : Int64, **options) |
| 181 | + get("#{Repository.path(repo)}/releases/#{release_id}/reactions", options) |
| 182 | + end |
| 183 | + |
| 184 | + # Create reaction for a release |
| 185 | + # |
| 186 | + # **See Also:** |
| 187 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-release](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#create-reaction-for-a-release) |
| 188 | + # |
| 189 | + # **Examples:** |
| 190 | + # |
| 191 | + # ``` |
| 192 | + # Octokit.create_release_reaction("monsalisa/app", 987654, "heart") |
| 193 | + # ``` |
| 194 | + def create_release_reaction(repo : String, release_id : Int64, reaction : String, **options) |
| 195 | + options = options.merge({json: {content: reaction}}) |
| 196 | + Reaction.from_json(post("#{Repository.path(repo)}/releases/#{release_id}/reactions", options)) |
| 197 | + end |
| 198 | + |
| 199 | + # Delete a reaction for a release |
| 200 | + # |
| 201 | + # **See Also:** |
| 202 | + # - [https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-a-release-reaction](https://docs.github.com/en/rest/reactions/reactions?apiVersion=2022-11-28#delete-a-release-reaction) |
| 203 | + # |
| 204 | + # **Examples:** |
| 205 | + # |
| 206 | + # ``` |
| 207 | + # Octokit.delete_release_reaction("monsalisa/app", 987654, 123) |
| 208 | + # ``` |
| 209 | + def delete_release_reaction(repo : String, release_id : Int64, reaction_id : Int64, **options) |
| 210 | + boolean_from_response(:delete, "#{Repository.path(repo)}/releases/#{release_id}/reactions/#{reaction_id}", options) |
| 211 | + end |
| 212 | + end |
| 213 | + end |
| 214 | +end |
0 commit comments