-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathoctokit_before.rb
More file actions
155 lines (146 loc) · 6.42 KB
/
octokit_before.rb
File metadata and controls
155 lines (146 loc) · 6.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# frozen_string_literal: true
module Octokit
class Client
# Methods for the Reacions API
#
# @see https://developer.github.com/v3/reactions/
module Reactions
# List reactions for a commit comment
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The id of the commit comment
# @see https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment
#
# @example
# @client.commit_comment_reactions("octokit/octokit.rb", 1)
#
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
def commit_comment_reactions(repo, id, options = {})
get "#{Repository.path repo}/comments/#{id}/reactions", options
end
# Create a reaction for a commit comment
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The id of the commit comment
# @param reaction [String] The Reaction
# @see https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment
# @see https://developer.github.com/v3/reactions/#reaction-types
#
# @example
# @client.create_commit_comment_reactions("octokit/octokit.rb", 1)
#
# @return [<Sawyer::Resource>] Hash representing the reaction
def create_commit_comment_reaction(repo, id, reaction, options = {})
options = options.merge(content: reaction)
post "#{Repository.path repo}/comments/#{id}/reactions", options
end
# List reactions for an issue
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param number [Integer] The Issue number
# @see https://developer.github.com/v3/reactions/#list-reactions-for-an-issue
#
# @example
# @client.issue_reactions("octokit/octokit.rb", 1)
#
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
def issue_reactions(repo, number, options = {})
get "#{Repository.path repo}/issues/#{number}/reactions", options
end
# Create reaction for an issue
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param number [Integer] The Issue number
# @param reaction [String] The Reaction
#
# @see https://developer.github.com/v3/reactions/#create-reaction-for-an-issue
# @see https://developer.github.com/v3/reactions/#reaction-types
#
# @example
# @client.create_issue_reaction("octokit/octokit.rb", 1)
#
# @return [<Sawyer::Resource>] Hash representing the reaction.
def create_issue_reaction(repo, number, reaction, options = {})
options = options.merge(content: reaction)
post "#{Repository.path repo}/issues/#{number}/reactions", options
end
# List reactions for an issue comment
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The Issue comment id
#
# @see https://developer.github.com/v3/reactions/#list-reactions-for-an-issue-comment
#
# @example
# @client.issue_comment_reactions("octokit/octokit.rb", 1)
#
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
def issue_comment_reactions(repo, id, options = {})
get "#{Repository.path repo}/issues/comments/#{id}/reactions", options
end
# Create reaction for an issue comment
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The Issue comment id
# @param reaction [String] The Reaction
#
# @see https://developer.github.com/v3/reactions/#create-reaction-for-an-issue-comment
# @see https://developer.github.com/v3/reactions/#reaction-types
#
# @example
# @client.create_issue_comment_reaction("octokit/octokit.rb", 1)
#
# @return [<Sawyer::Resource>] Hashes representing the reaction.
def create_issue_comment_reaction(repo, id, reaction, options = {})
options = options.merge(content: reaction)
post "#{Repository.path repo}/issues/comments/#{id}/reactions", options
end
# List reactions for a pull request review comment
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The Issue comment id
#
# @see https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
#
# @example
# @client.pull_request_review_comment_reactions("octokit/octokit.rb", 1)
#
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reactions.
def pull_request_review_comment_reactions(repo, id, options = {})
get "#{Repository.path repo}/pulls/comments/#{id}/reactions", options
end
# Create reaction for a pull request review comment
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The Issue comment id
# @param reaction [String] The Reaction
#
# @see https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment
# @see https://developer.github.com/v3/reactions/#reaction-types
#
# @example
# @client.create_pull_request_reiew_comment_reaction("octokit/octokit.rb", 1)
#
# @return [<Sawyer::Resource>] Hash representing the reaction.
def create_pull_request_review_comment_reaction(repo, id, reaction, options = {})
options = options.merge(content: reaction)
post "#{Repository.path repo}/pulls/comments/#{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