Class: VehicleData::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/vehicle_data.rb

Direct Known Subclasses

Makes, Service, Vehicles, Vin

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



24
25
26
27
28
# File 'lib/vehicle_data.rb', line 24

def initialize(options={})
  @app_key = VehicleData.configuration.app_key
  @secret  = VehicleData.configuration.secret
  @data    = options.merge!({ :app => @app_key, :v => 0.2, :t => Time.now.to_i })
end

Instance Attribute Details

#app_keyObject

Returns the value of attribute app_key.



22
23
24
# File 'lib/vehicle_data.rb', line 22

def app_key
  @app_key
end

#dataObject

Returns the value of attribute data.



22
23
24
# File 'lib/vehicle_data.rb', line 22

def data
  @data
end

#optionsObject

Returns the value of attribute options.



22
23
24
# File 'lib/vehicle_data.rb', line 22

def options
  @options
end

#requestObject

Returns the value of attribute request.



22
23
24
# File 'lib/vehicle_data.rb', line 22

def request
  @request
end

#responseObject

Returns the value of attribute response.



22
23
24
# File 'lib/vehicle_data.rb', line 22

def response
  @response
end

#secretObject

Returns the value of attribute secret.



22
23
24
# File 'lib/vehicle_data.rb', line 22

def secret
  @secret
end

Instance Method Details

#send_requestObject



30
31
32
33
# File 'lib/vehicle_data.rb', line 30

def send_request
  response = Typhoeus.get("#{base_uri}/?#{build_params(@data)}&hash=#{calculate_signature}")
  JSON.parse(response.body)
end