class Onfleet::API
Constants
- API_RESOURCES
Attributes
api_endpoint[RW]
api_key[RW]
logger[RW]
max_try_count[RW]
retry_if_fails[RW]
throws_exceptions[RW]
timeout[RW]
api_endpoint[RW]
api_key[RW]
throws_exceptions[RW]
timeout[RW]
Public Class Methods
method_missing(sym, *args, &block)
click to toggle source
Calls superclass method
# File lib/onfleet/api.rb, line 35 def method_missing(sym, *args, &block) if API_RESOURCES.include?(sym.to_s) new(self.api_key, {:api_endpoint => self.api_endpoint, :timeout => self.timeout, :throws_exceptions => self.throws_exceptions}).send(sym, *args, &block) else super end end
new(api_key=nil, default_parameters={})
click to toggle source
# File lib/onfleet/api.rb, line 7 def initialize(api_key=nil, default_parameters={}) @api_key = api_key || self.class.api_key || ENV['ONFLEET_API_KEY'] @api_key = @api_key.strip if @api_key @api_endpoint = default_parameters.delete(:api_endpoint) || self.class.api_endpoint @timeout = default_parameters.delete(:timeout) || self.class.timeout @throws_exceptions = default_parameters.has_key?(:throws_exceptions) ? default_parameters.delete(:throws_exceptions) : self.class.throws_exceptions @default_params = default_parameters end
Public Instance Methods
method_missing(method, *args)
click to toggle source
Calls superclass method
# File lib/onfleet/api.rb, line 18 def method_missing(method, *args) if API_RESOURCES.include?(method.to_s) api = APICategory.new(method.to_s, @api_key, @timeout, @throws_exceptions, @api_endpoint, @default_params) api.api_endpoint = @api_endpoint if @api_endpoint api else super end end