mirror of
https://github.com/rickbarrette/redmine_qbo.git
synced 2025-11-08 17:04:23 -05:00
Merge branch 'master' into nhtsa_vin
This commit is contained in:
@@ -41,7 +41,7 @@ class Vehicle < ActiveRecord::Base
|
|||||||
# returns the style of the vehicle
|
# returns the style of the vehicle
|
||||||
def style
|
def style
|
||||||
begin
|
begin
|
||||||
return @details['years'][0]['styles'][0]['name'] if @details
|
return @details.trim if @details
|
||||||
rescue
|
rescue
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
@@ -49,12 +49,14 @@ class Vehicle < ActiveRecord::Base
|
|||||||
|
|
||||||
# returns the drive of the vehicle i.e. 2 wheel, 4 wheel, ect.
|
# returns the drive of the vehicle i.e. 2 wheel, 4 wheel, ect.
|
||||||
def drive
|
def drive
|
||||||
return @details['drivenWheels'].to_s.upcase if @details
|
#todo fix this
|
||||||
|
#return @details.drive_type if @details
|
||||||
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns the number of doors of the vehicle
|
# returns the number of doors of the vehicle
|
||||||
def doors
|
def doors
|
||||||
return @details['numOfDoors'] if @details
|
return @details.doors if @details
|
||||||
end
|
end
|
||||||
|
|
||||||
# Force Upper Case for VIN numbers
|
# Force Upper Case for VIN numbers
|
||||||
@@ -87,28 +89,23 @@ class Vehicle < ActiveRecord::Base
|
|||||||
def get_details
|
def get_details
|
||||||
if self.vin?
|
if self.vin?
|
||||||
begin
|
begin
|
||||||
@details = JSON.parse get_decoder.full(self.vin)
|
query = NhtsaVin.get(self.vin)
|
||||||
raise @details['message'] if @details['status'].to_s.eql? "NOT_FOUND"
|
raise error if not @details.valid?
|
||||||
raise @details['message'] if @details['status'].to_s.eql? "BAD_REQUEST"
|
@details = query.response = NhtsaVin.get(self.vin)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
errors.add(:vin, e.message)
|
errors.add(:vin, e.message)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# returns the Edmunds decoder service
|
|
||||||
def get_decoder
|
|
||||||
return decoder = Edmunds::Vin.new(Setting.plugin_redmine_qbo['settingsEdmundsAPIKey'])
|
|
||||||
end
|
|
||||||
|
|
||||||
# decodes a vin and updates self
|
# decodes a vin and updates self
|
||||||
def decode_vin
|
def decode_vin
|
||||||
get_details
|
get_details
|
||||||
if @details
|
if @details
|
||||||
begin
|
begin
|
||||||
self.year = @details['years'][0]['year']
|
self.year = @details.year
|
||||||
self.make = @details['make']['name']
|
self.make = @details.make
|
||||||
self.model = @details['model']['name']
|
self.model = @details.model
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
errors.add(:vin, e.message)
|
errors.add(:vin, e.message)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,14 +20,6 @@ intuit.ipp.anywhere.setup({menuProxy: '/path/to/blue-dot', grantUrl: '<%= qbo_au
|
|||||||
|
|
||||||
<table >
|
<table >
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
|
||||||
<th>Edmunds API Key</th>
|
|
||||||
<td>
|
|
||||||
<input type="text" style="width:350px" id="settingsEdmundsAPIKey"
|
|
||||||
value="<%= settings['settingsEdmundsAPIKey'] %>"
|
|
||||||
name="settings[settingsEdmundsAPIKey]" >
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<th>Intuit QBO OAuth Consumer Key</th>
|
<th>Intuit QBO OAuth Consumer Key</th>
|
||||||
|
|||||||
Reference in New Issue
Block a user