lib/underway/api.rb in underway-1.0.1 vs lib/underway/api.rb in underway-1.1.0

- old
+ new

@@ -26,10 +26,24 @@ rescue Octokit::Error => e { error: e.to_s } end end + def self.client_for(installation_id: nil, access_token: nil) + token = access_token + if !installation_id.nil? + token = installation_token(id: installation_id) + end + + return if token.nil? + + client = Octokit::Client.new( + api_endpoint: Underway::Settings.config.raw["github_api_host"], + access_token: token + ) + end + def self.generate_jwt payload = { # Issued at time: iat: Time.now.to_i, # JWT expiration time (10 minute maximum) @@ -47,10 +61,10 @@ log("token cache: hit") return token else log("token cache: miss") res = invoke( - "/app/installations/#{id}/access_tokens", + "app/installations/#{id}/access_tokens", method: :post ) if error = res[:error] raise ArgumentError.new(error)