class RubyUber::Client
Attributes
client_id[RW]
secret[RW]
server_token[RW]
Public Class Methods
new(options)
click to toggle source
# File lib/ruby_uber/client.rb, line 9 def initialize(options) @server_token = options[:server_token] @client_id = options[:client_id] @secret = options[:secret] if !server_token && !oauthable? raise AuthenticationError, "Must provide either :server_token or :client_id and :secret to initialize Ruber::Client" end end
Public Instance Methods
base_url()
click to toggle source
# File lib/ruby_uber/client.rb, line 24 def base_url "https://#{host}/v1" end
connection()
click to toggle source
# File lib/ruby_uber/client.rb, line 28 def connection @connection ||= Faraday.new(url: base_url) do |conn| conn.request :json conn.response :json conn.adapter Faraday.default_adapter end end
get(url, params)
click to toggle source
# File lib/ruby_uber/client.rb, line 36 def get(url, params) connection.get(url, params) do |req| req.headers['Authorization'] = "Token #{server_token}" end end
host()
click to toggle source
# File lib/ruby_uber/client.rb, line 20 def host 'api.uber.com' end
price_estimates()
click to toggle source
# File lib/ruby_uber/client.rb, line 42 def price_estimates V1::PriceEstimates.new(client: self) end
products()
click to toggle source
# File lib/ruby_uber/client.rb, line 46 def products V1::Products.new(client: self) end
time_estimates()
click to toggle source
# File lib/ruby_uber/client.rb, line 50 def time_estimates V1::TimeEstimates.new(client: self) end
user_activity()
click to toggle source
# File lib/ruby_uber/client.rb, line 54 def user_activity V1::UserActivity.new(client: self) end
user_profile()
click to toggle source
# File lib/ruby_uber/client.rb, line 58 def user_profile V1::UserProfile.new(client: self) end
Private Instance Methods
oauthable?()
click to toggle source
# File lib/ruby_uber/client.rb, line 64 def oauthable? client_id && secret end