mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Added vin decoder
This commit is contained in:
@@ -15,7 +15,21 @@ class Vehicle < ActiveRecord::Base
|
|||||||
attr_accessible :year, :make, :model, :qbo_customer_id, :notes, :vin
|
attr_accessible :year, :make, :model, :qbo_customer_id, :notes, :vin
|
||||||
validates_presence_of :year, :make, :model, :qbo_customer_id
|
validates_presence_of :year, :make, :model, :qbo_customer_id
|
||||||
|
|
||||||
|
before_save :decode_vin
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
return "#{year} #{make} #{model}"
|
return "#{year} #{make} #{model}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def decode_vin
|
||||||
|
if vin?
|
||||||
|
e = Edmunds::Vin.full(vin)
|
||||||
|
vehicle = JSON.parse(e)
|
||||||
|
year = vehicle[:years][:year]
|
||||||
|
make = vehicle[:make][:name]
|
||||||
|
model = vehicle[:model][:name]
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user