class CodecovApi::Api::Base

Protected Instance Methods

base_path() click to toggle source
# File lib/codecov_api/api/base.rb, line 13
def base_path
  raise 'base_path method not defined'
end
get_request(path) click to toggle source
# File lib/codecov_api/api/base.rb, line 9
def get_request(path)
  response(base_url + base_path + path)
end

Private Instance Methods

auth_token() click to toggle source
# File lib/codecov_api/api/base.rb, line 19
def auth_token
  raise 'CODECOV_AUTH_TOKEN ENV VAR not defined' if ENV['CODECOV_AUTH_TOKEN'].nil?
  ENV['CODECOV_AUTH_TOKEN']
end
base_url() click to toggle source
# File lib/codecov_api/api/base.rb, line 24
def base_url
  'https://codecov.io/api/gh'
end
response(url, method: :get) click to toggle source
# File lib/codecov_api/api/base.rb, line 28
def response(url, method: :get)
  puts "#{method.to_s.upcase} #{url}"
  RestClient::Request.new(
    method: method,
    url: url,
    headers: { Authorization: 'token ' + auth_token }
  ).execute
end