class Ubr::API
Public Class Methods
new()
click to toggle source
# File lib/ubr/api.rb, line 7 def initialize token = File.read(API.token_path).strip @client = RestClient::Resource.new('https://api.uber.com/v1', headers: { authorization: "Bearer #{token}", content_type: 'application/json' } ) end
parse_response(response)
click to toggle source
# File lib/ubr/api.rb, line 25 def self.parse_response(response) JSON.parse response, symbolize_names: true end
token_path()
click to toggle source
# File lib/ubr/api.rb, line 38 def self.token_path File.expand_path('~/.ubr') end
Public Instance Methods
get(path, params={})
click to toggle source
# File lib/ubr/api.rb, line 16 def get(path, params={}) parse_response @client[path].get(params: params) end
parse_response(response)
click to toggle source
# File lib/ubr/api.rb, line 22 def parse_response(response) API.parse_response(response) end
post(path, params={})
click to toggle source
# File lib/ubr/api.rb, line 19 def post(path, params={}) parse_response @client[path].post(params.to_json) end