mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2026-10-04 01:00:44 -04:00
Added vin decoder
This commit is contained in:
1 parent
b1c0f965f8
commit
9972e18632
1 file changed
+14
@@ -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