Skip to content

Commit

Permalink
Add release_reactions, create_release_reactions and delete_release_re…
Browse files Browse the repository at this point in the history
…actions
  • Loading branch information
wJoenn committed Oct 6, 2023
1 parent 5d82ffc commit 31f68f2
Show file tree
Hide file tree
Showing 5 changed files with 394 additions and 0 deletions.
49 changes: 49 additions & 0 deletions lib/octokit/client/reactions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,55 @@ def create_pull_request_review_comment_reaction(repo, id, reaction, options = {}
def delete_issue_reaction(repo, issue_id, reaction_id, options = {})
boolean_from_response :delete, "#{Repository.path repo}/issues/#{issue_id}/reactions/#{reaction_id}", options
end

# 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, release_id, options = {})
get "#{Repository.path repo}/releases/#{release_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, release_id, reaction, options = {})
options = options.merge(content: reaction)
post "#{Repository.path repo}/releases/#{release_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
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"http_interactions": [
{
"request": {
"method": "post",
"uri": "https://api.github.com/user/repos",
"body": {
"encoding": "UTF-8",
"base64_string": "eyJhdXRvX2luaXQiOnRydWUsIm5hbWUiOiJhbi1yZXBvIn0=\n"
},
"headers": {
"Accept": [
"application/vnd.github.v3+json"
],
"User-Agent": [
"Octokit Ruby Gem 7.2.0"
],
"Content-Type": [
"application/json"
],
"Authorization": [
"token <<ACCESS_TOKEN>>"
],
"Accept-Encoding": [
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
]
}
},
"response": {
"status": {
"code": 401,
"message": "Unauthorized"
},
"headers": {
"Server": [
"GitHub.com"
],
"Date": [
"Fri, 06 Oct 2023 19:31:44 GMT"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"80"
],
"X-Github-Media-Type": [
"github.v3; format=json"
],
"X-Ratelimit-Limit": [
"60"
],
"X-Ratelimit-Remaining": [
"54"
],
"X-Ratelimit-Reset": [
"1696623381"
],
"X-Ratelimit-Used": [
"6"
],
"X-Ratelimit-Resource": [
"core"
],
"Access-Control-Expose-Headers": [
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"
],
"Access-Control-Allow-Origin": [
"*"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubdomains; preload"
],
"X-Frame-Options": [
"deny"
],
"X-Content-Type-Options": [
"nosniff"
],
"X-Xss-Protection": [
"0"
],
"Referrer-Policy": [
"origin-when-cross-origin, strict-origin-when-cross-origin"
],
"Content-Security-Policy": [
"default-src 'none'"
],
"Vary": [
"Accept-Encoding, Accept, X-Requested-With"
],
"X-Github-Request-Id": [
"EB06:EFB1:18C28C6:18FEB91:652060A0"
]
},
"body": {
"encoding": "UTF-8",
"base64_string": "eyJtZXNzYWdlIjoiQmFkIGNyZWRlbnRpYWxzIiwiZG9jdW1lbnRhdGlvbl91\ncmwiOiJodHRwczovL2RvY3MuZ2l0aHViLmNvbS9yZXN0In0=\n"
}
},
"recorded_at": "Fri, 06 Oct 2023 19:31:44 GMT"
}
],
"recorded_with": "VCR 6.2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"http_interactions": [
{
"request": {
"method": "post",
"uri": "https://api.github.com/user/repos",
"body": {
"encoding": "UTF-8",
"base64_string": "eyJhdXRvX2luaXQiOnRydWUsIm5hbWUiOiJhbi1yZXBvIn0=\n"
},
"headers": {
"Accept": [
"application/vnd.github.v3+json"
],
"User-Agent": [
"Octokit Ruby Gem 7.2.0"
],
"Content-Type": [
"application/json"
],
"Authorization": [
"token <<ACCESS_TOKEN>>"
],
"Accept-Encoding": [
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
]
}
},
"response": {
"status": {
"code": 401,
"message": "Unauthorized"
},
"headers": {
"Server": [
"GitHub.com"
],
"Date": [
"Fri, 06 Oct 2023 19:31:43 GMT"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"80"
],
"X-Github-Media-Type": [
"github.v3; format=json"
],
"X-Ratelimit-Limit": [
"60"
],
"X-Ratelimit-Remaining": [
"56"
],
"X-Ratelimit-Reset": [
"1696623381"
],
"X-Ratelimit-Used": [
"4"
],
"X-Ratelimit-Resource": [
"core"
],
"Access-Control-Expose-Headers": [
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"
],
"Access-Control-Allow-Origin": [
"*"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubdomains; preload"
],
"X-Frame-Options": [
"deny"
],
"X-Content-Type-Options": [
"nosniff"
],
"X-Xss-Protection": [
"0"
],
"Referrer-Policy": [
"origin-when-cross-origin, strict-origin-when-cross-origin"
],
"Content-Security-Policy": [
"default-src 'none'"
],
"Vary": [
"Accept-Encoding, Accept, X-Requested-With"
],
"X-Github-Request-Id": [
"EB02:5F08:1AAEBB1:1AEAE30:6520609F"
]
},
"body": {
"encoding": "UTF-8",
"base64_string": "eyJtZXNzYWdlIjoiQmFkIGNyZWRlbnRpYWxzIiwiZG9jdW1lbnRhdGlvbl91\ncmwiOiJodHRwczovL2RvY3MuZ2l0aHViLmNvbS9yZXN0In0=\n"
}
},
"recorded_at": "Fri, 06 Oct 2023 19:31:44 GMT"
}
],
"recorded_with": "VCR 6.2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
{
"http_interactions": [
{
"request": {
"method": "post",
"uri": "https://api.github.com/user/repos",
"body": {
"encoding": "UTF-8",
"base64_string": "eyJhdXRvX2luaXQiOnRydWUsIm5hbWUiOiJhbi1yZXBvIn0=\n"
},
"headers": {
"Accept": [
"application/vnd.github.v3+json"
],
"User-Agent": [
"Octokit Ruby Gem 7.2.0"
],
"Content-Type": [
"application/json"
],
"Authorization": [
"token <<ACCESS_TOKEN>>"
],
"Accept-Encoding": [
"gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
]
}
},
"response": {
"status": {
"code": 401,
"message": "Unauthorized"
},
"headers": {
"Server": [
"GitHub.com"
],
"Date": [
"Fri, 06 Oct 2023 19:31:44 GMT"
],
"Content-Type": [
"application/json; charset=utf-8"
],
"Content-Length": [
"80"
],
"X-Github-Media-Type": [
"github.v3; format=json"
],
"X-Ratelimit-Limit": [
"60"
],
"X-Ratelimit-Remaining": [
"55"
],
"X-Ratelimit-Reset": [
"1696623381"
],
"X-Ratelimit-Used": [
"5"
],
"X-Ratelimit-Resource": [
"core"
],
"Access-Control-Expose-Headers": [
"ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"
],
"Access-Control-Allow-Origin": [
"*"
],
"Strict-Transport-Security": [
"max-age=31536000; includeSubdomains; preload"
],
"X-Frame-Options": [
"deny"
],
"X-Content-Type-Options": [
"nosniff"
],
"X-Xss-Protection": [
"0"
],
"Referrer-Policy": [
"origin-when-cross-origin, strict-origin-when-cross-origin"
],
"Content-Security-Policy": [
"default-src 'none'"
],
"Vary": [
"Accept-Encoding, Accept, X-Requested-With"
],
"X-Github-Request-Id": [
"EB04:0FCF:186EA04:18AA590:652060A0"
]
},
"body": {
"encoding": "UTF-8",
"base64_string": "eyJtZXNzYWdlIjoiQmFkIGNyZWRlbnRpYWxzIiwiZG9jdW1lbnRhdGlvbl91\ncmwiOiJodHRwczovL2RvY3MuZ2l0aHViLmNvbS9yZXN0In0=\n"
}
},
"recorded_at": "Fri, 06 Oct 2023 19:31:44 GMT"
}
],
"recorded_with": "VCR 6.2.0"
}
Loading

0 comments on commit 31f68f2

Please sign in to comment.