Skip to content

Commit

Permalink
adding more apps endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
GrantBirki committed Jul 30, 2024
1 parent ea9066b commit 21001ad
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/octokit/client.cr
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ module Octokit
include Octokit::Client::Statuses
include Octokit::Client::Say
include Octokit::Client::Deployments
include Octokit::Client::Apps

CONVENIENCE_HEADERS = Set{"accept", "content_type"}

Expand Down
65 changes: 65 additions & 0 deletions src/octokit/client/apps.cr
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
require "../models/apps"

module Octokit
class Client
# Methods for the Apps API
module Apps
# :nodoc:
alias App = Models::App

# Get the authenticated App
#
# @param options [Hash] A customizable set of options
#
# @see https://developer.github.com/v3/apps/#get-the-authenticated-app
#
# **Example:**
# ```
# @client = Octokit.client(bearer_token: <jwt>)
# @client.app
# ```
def app(**options)
get("app", options)
end

# Find all installations that belong to an App
#
# @param options [Hash] A customizable set of options
#
# @see https://developer.github.com/v3/apps/#list-installations
#
# @return the total_count and an array of installations
def find_app_installations(**options) : Paginator(Octokit::Models::Installation)
paginate(
Octokit::Models::Installation,
"app/installations",
start_page: options[:page]?,
per_page: options[:per_page]?,
options: options
)
end

# alias for `find_app_installations`
def find_installations(**options) : Paginator(Octokit::Models::Installation)
find_app_installations(**options)
end

# Create a new installation token
#
# @param installation [Integer] The id of a GitHub App Installation
# @param options [Hash] A customizable set of options
#
# @see https://developer.github.com/v3/apps/#create-a-new-installation-token
#
# @return [<Sawyer::Resource>] An installation token
def create_app_installation_access_token(installation : Int32, **options)
post("app/installations/#{installation}/access_tokens", options)
end

# alias for `create_app_installation_access_token`
def create_installation_access_token(installation : Int32, **options)
create_app_installation_access_token(installation, **options)
end
end
end
end

0 comments on commit 21001ad

Please sign in to comment.