class Smartcar::Base
The Base
class for all of the other class. Let other classes inherit from here and put common methods here.
Constants
- BASIC
Constant for Basic auth type
- REQUEST_TIMEOUT
Number of seconds to wait for response
Attributes
auth_type[RW]
error[RW]
token[RW]
unit_system[RW]
version[RW]
Public Instance Methods
fetch(path:, query_params: {})
click to toggle source
This requires a proc 'PATH' to be defined in the class @param path [String] resource path @param query_params [Hash] query params @param auth [String] type of auth
@return [Object]
# File lib/smartcar/base.rb, line 52 def fetch(path:, query_params: {}) path += "?#{URI.encode_www_form(query_params)}" unless query_params.empty? get(path) end
Private Instance Methods
service()
click to toggle source
gets a smartcar API service/client
@return [OAuth2::AccessToken] An initialized AccessToken instance that acts as service client
# File lib/smartcar/base.rb, line 62 def service @service ||= Faraday.new(url: ENV['SMARTCAR_API_ORIGIN'] || API_ORIGIN, request: { timeout: REQUEST_TIMEOUT }) end