Class: GitHubApp

Inherits:
Object
  • Object
show all
Defined in:
lib/issue_db/utils/github_app.rb

Constant Summary collapse

TOKEN_EXPIRATION_TIME =

45 minutes

2700
JWT_EXPIRATION_TIME =

10 minutes

600

Instance Method Summary collapse

Constructor Details

#initializeGitHubApp

Returns a new instance of GitHubApp.



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/issue_db/utils/github_app.rb', line 19

def initialize
  # app ids are found on the App's settings page
  @app_id = fetch_env_var("ISSUE_DB_GITHUB_APP_ID").to_i

  # installation ids look like this:
  # https://github.com/organizations/<org>/settings/installations/<8_digit_id>
  @installation_id = fetch_env_var("ISSUE_DB_GITHUB_APP_INSTALLATION_ID").to_i

  # app keys are found on the App's settings page and can be downloaded
  # format: "-----BEGIN...key\n...END-----\n"
  # make sure this key in your env is a single line string with newlines as "\n"
  @app_key = fetch_env_var("ISSUE_DB_GITHUB_APP_KEY").gsub(/\\+n/, "\n")

  @client = nil
  @token_refresh_time = nil
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object (private)

This method is called when a method is called on the GitHub class that does not exist. It delegates the method call to the Octokit client.

Parameters:

  • method (Symbol)

    The name of the method being called.

  • args (Array)

    The arguments passed to the method.

  • block (Proc)

    An optional block passed to the method.

Returns:

  • (Object)

    The result of the method call on the Octokit client.



96
97
98
# File 'lib/issue_db/utils/github_app.rb', line 96

def method_missing(method, *args, &block)
  client.send(method, *args, &block)
end