Add http class for api token requests

This commit is contained in:
Brian Cain 2015-09-14 22:50:01 -07:00
parent e194f04ea9
commit eee7aab760
2 changed files with 32 additions and 13 deletions

View file

@ -36,4 +36,25 @@ class Http
return conn
end
def self.get_conn_with_token(verbose, url, token)
if url.nil?
STDERR.puts "The url you provided was empty"
exit 1
end
if token.nil?
STDERR.puts "The token you provided was empty"
exit 1
end
conn = Faraday.new(:url => url) do |faraday|
faraday.request :url_encoded
faraday.request :token_auth, token
faraday.response :logger if verbose
faraday.adapter Faraday.default_adapter
end
return conn
end
end