mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Fixed vin decoding
This commit is contained in:
@@ -83,15 +83,15 @@ class Vehicle < ActiveRecord::Base
|
|||||||
where("vin LIKE ?", "%#{search}%")
|
where("vin LIKE ?", "%#{search}%")
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# init method to pull JSON details from Edmunds
|
# init method to pull JSON details from Edmunds
|
||||||
def get_details
|
def get_details
|
||||||
if self.vin?
|
if self.vin?
|
||||||
begin
|
begin
|
||||||
query = NhtsaVin.get(self.vin)
|
query = NhtsaVin.get(self.vin)
|
||||||
raise error if not @details.valid?
|
raise RuntimeError, query.error unless query.valid?
|
||||||
@details = query.response = NhtsaVin.get(self.vin)
|
@details = query.response
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
errors.add(:vin, e.message)
|
errors.add(:vin, e.message)
|
||||||
end
|
end
|
||||||
@@ -103,9 +103,9 @@ class Vehicle < ActiveRecord::Base
|
|||||||
get_details
|
get_details
|
||||||
if @details
|
if @details
|
||||||
begin
|
begin
|
||||||
self.year = @details.year
|
self.year = @details.year unless @details.year.nil?
|
||||||
self.make = @details.make
|
self.make = @details.make unless @details.make.nil?
|
||||||
self.model = @details.model
|
self.model = @details.model unless @details.model.nil?
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
errors.add(:vin, e.message)
|
errors.add(:vin, e.message)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user