class Fasterer::Github::ApiWrapper

Constants

BASE_URI

Attributes

access_token[R]
client_id[R]
client_secret[R]
owner[R]
path[R]
repo[R]

Public Class Methods

new(owner, repo) click to toggle source
# File lib/fasterer/github/api_wrapper.rb, line 8
def initialize(owner, repo)
  @owner = owner
  @repo = repo
  @access_token = Fasterer::Github.configuration.access_token.to_s
  @client_id = Fasterer::Github.configuration.client_id.to_s
  @client_secret = Fasterer::Github.configuration.client_secret.to_s
end

Public Instance Methods

contents(path) click to toggle source
# File lib/fasterer/github/api_wrapper.rb, line 16
def contents(path)
  HTTParty.get(build_uri(path), query: authorization_params)
end

Private Instance Methods

access_token_hash() click to toggle source
# File lib/fasterer/github/api_wrapper.rb, line 33
def access_token_hash
  { 'access_token' => access_token }
end
authorization_params() click to toggle source
# File lib/fasterer/github/api_wrapper.rb, line 28
def authorization_params
  return access_token_hash unless access_token.empty?
  return client_id_secret_hash unless client_id.empty? && client_secret.empty?
end
build_uri(path) click to toggle source
# File lib/fasterer/github/api_wrapper.rb, line 24
def build_uri(path)
  URI.escape(BASE_URI + "/repos/#{owner}/#{repo}/contents/#{path}")
end
client_id_secret_hash() click to toggle source
# File lib/fasterer/github/api_wrapper.rb, line 37
def client_id_secret_hash
  { 'client_id' => client_id, 'client_secret' => client_secret }
end