Skip to content

Commit 58f7c7c

Browse files
authored
Merge pull request #21 from octokit-cr/reactions
Reactions
2 parents a1e52fd + dcfd4fd commit 58f7c7c

12 files changed

+227
-6
lines changed

.crystal-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.13.1
1+
1.14.1

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ There are a lot of pieces of the GitHub API to cover. Here are the ones that nee
7676
- [x] [PubSubHubbub](https://octokit-cr.github.io/octokit.cr/Octokit/Client/PubSubHubbub.html)
7777
- [x] [PullRequests](https://octokit-cr.github.io/octokit.cr/Octokit/Client/PullRequests.html)
7878
- [x] [RateLimit](https://octokit-cr.github.io/octokit.cr/Octokit/Client/RateLimit.html)
79-
- [ ] [Reactions]()
79+
- [x] [Reactions](https://octokit-cr.github.io/octokit.cr/Octokit/Client/Reactions.html)
8080
- [ ] [Refs]()
8181
- [x] [Releases](https://octokit-cr.github.io/octokit.cr/Octokit/Client/Releases.html)
8282
- [x] [Repositories](https://octokit-cr.github.io/octokit.cr/Octokit/Client/Repositories.html)

shard.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
name: octokit
2-
version: 0.3.0
2+
version: 0.3.1
33

44
authors:
55
- Grant Birkinbine
66
- Chris Watson <[email protected]>
77

8-
crystal: ">= 1.13.1"
8+
crystal: ">= 1.14.1"
99

1010
license: MIT
1111

@@ -22,4 +22,4 @@ development_dependencies:
2222
version: 0.14.0
2323
ameba:
2424
github: crystal-ameba/ameba
25-
version: ~> 1.6.1
25+
version: == 1.6.1

src/octokit/client.cr

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ module Octokit
114114
include Octokit::Client::Users
115115
include Octokit::Client::RateLimit
116116
include Octokit::Client::Repositories
117+
include Octokit::Client::Reactions
117118
include Octokit::Client::Organizations
118119
include Octokit::Client::Releases
119120
include Octokit::Client::Search

src/octokit/client/reactions.cr

+214
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
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

src/octokit/models/issues.cr

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require "./users"
2+
13
module Octokit
24
module Models
35
struct Issue

src/octokit/models/reactions.cr

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require "./users"
2+
13
module Octokit
24
module Models
35
struct Reaction
@@ -19,6 +21,8 @@ module Octokit
1921
confused: Int32,
2022
heart: Int32,
2123
hooray: Int32,
24+
rocket: Int32,
25+
eyes: Int32,
2226
url: String
2327
)
2428
end

src/octokit/version.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Octokit
2-
VERSION = "0.3.0"
2+
VERSION = "0.3.1"
33
end

vendor/shards/cache/ameba-1.6.1.shard

4.81 MB
Binary file not shown.
3.3 KB
Binary file not shown.
9.67 KB
Binary file not shown.
2.07 KB
Binary file not shown.

0 commit comments

Comments
 (0)