class Uber::Client

Constants

API_LOCATION
API_VERSION

Attributes

bearer_token[RW]
server_token[RW]

Public Class Methods

new(params={}) click to toggle source
# File lib/uber_api/client.rb, line 17
def initialize(params={})
        params.each { |k,v| instance_variable_set("@#{k}", v) }
end

Public Instance Methods

conn() click to toggle source
# File lib/uber_api/client.rb, line 21
def conn
        @conn = Faraday.new API_LOCATION do |conn|
                conn.request :json
                conn.response :json, :content_type => /\bjson$/
                if !@bearer_token then conn.authorization :Token, @server_token else conn.authorization :Bearer , @bearer_token end 
                conn.adapter Faraday.default_adapter
        end
end
get(endpoint, params) click to toggle source
# File lib/uber_api/client.rb, line 30
def get(endpoint, params)
        query_string = API_VERSION + endpoint
        response = conn.get query_string, params
        response_hash = JSON.parse(response.body.to_json)
end
history(offset, limit) click to toggle source
# File lib/uber_api/client.rb, line 56
def history(offset, limit)
        params = {:offset => offset.to_s, :limit => limit.to_s}
        response = get("/history", params)
end
prices(start_latitude, start_longitude, end_latitude, end_longitude) click to toggle source
# File lib/uber_api/client.rb, line 42
def prices(start_latitude, start_longitude, end_latitude, end_longitude)
        params = {:start_latitude => start_latitude.to_s, :start_longitude => start_longitude.to_s,
                                :end_latitude => end_latitude.to_s, :end_longitude => end_longitude.to_s}
        response = get("/estimates/price", params)
        response["prices"]
end
products(latitude, longitude) click to toggle source
# File lib/uber_api/client.rb, line 36
def products(latitude, longitude)
        params = {:latitude => latitude.to_s, :longitude => longitude.to_s}
        response = get("/products", params)
        response["products"]         
end
profile() click to toggle source
# File lib/uber_api/client.rb, line 61
def profile
        params = {}
        response = get("/me", params)
end
times(start_latitude, start_longitude, customer_uuid, product_id) click to toggle source
# File lib/uber_api/client.rb, line 49
def times(start_latitude, start_longitude, customer_uuid, product_id)
        params = {:start_latitude => start_latitude.to_s, :start_longitude => start_longitude.to_s,
                                :customer_uuid => customer_uuid.to_s, :product_id => product_id.to_s}
        response = get("/estimates/time", params)
        response["times"]
end