mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-09 01:14:23 -05:00
Comments
This commit is contained in:
@@ -19,39 +19,47 @@ class Vehicle < ActiveRecord::Base
|
|||||||
before_validation :decode_vin
|
before_validation :decode_vin
|
||||||
after_initialize :get_details
|
after_initialize :get_details
|
||||||
|
|
||||||
|
# returns a human readable string
|
||||||
def to_s
|
def to_s
|
||||||
return "#{self.year} #{self.make} #{self.model}"
|
return "#{self.year} #{self.make} #{self.model}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the raw JSON details from EMUNDS
|
||||||
def details
|
def details
|
||||||
return @details
|
return @details
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the style of the vehicle
|
||||||
def style
|
def style
|
||||||
return @details['years'][0]['styles'][0]['name'] if @details
|
return @details['years'][0]['styles'][0]['name'] if @details
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the drive of the vehicle i.e. 2 wheel, 4 wheel, ect.
|
||||||
def drive
|
def drive
|
||||||
return @details['drivenWheels'] if @details
|
return @details['drivenWheels'] if @details
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the number of doors of the vehicle
|
||||||
def doors
|
def doors
|
||||||
return @details['numOfDoors'] if @details
|
return @details['numOfDoors'] if @details
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
# init method to pull JSON details from Edmunds
|
||||||
def get_details
|
def get_details
|
||||||
if self.vin?
|
if self.vin?
|
||||||
@details = JSON.parse get_decoder.full(self.vin)
|
@details = JSON.parse get_decoder.full(self.vin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# returns the Edmunds decoder service
|
||||||
def get_decoder
|
def get_decoder
|
||||||
#TODO API Code via Settings
|
#TODO API Code via Settings
|
||||||
return decoder = Edmunds::Vin.new('2dheutzvhxs28dzukx5tgu47')
|
return decoder = Edmunds::Vin.new('2dheutzvhxs28dzukx5tgu47')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# decodes a vin and updates self
|
||||||
def decode_vin
|
def decode_vin
|
||||||
if self.vin?
|
if self.vin?
|
||||||
details
|
details
|
||||||
|
|||||||
Reference in New Issue
Block a user