mirror of
https://github.com/rickbarrette/redmine_qbo_vehicles.git
synced 2026-11-18 02:40:37 -05:00
Replace nhtsa_vin gem with a built-in NHTSA vPIC client
The nhtsa_vin gem is unmaintained (last release 2019, source repository gone). VinDecoder now calls NHTSA's free vPIC DecodeVinValues endpoint directly with Net::HTTP and JSON from the standard library. - Same fields as before (year, make, model, trim, doors), plus body class, engine and NHTSA's warning text - Sends the year on file as NHTSA's model-year hint - Decodes NHTSA flags with a warning (e.g. wrong check digit) still count as decoded; no make/model is a final failure with NHTSA's explanation - Network errors, timeouts, bad responses and HTTP 403/429/5xx raise TransientError, so the job retries - Makes are title-cased from NHTSA's capitals, keeping short abbreviations (GMC, RAM, BMW) - Removes the gem from the Gemfile Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01BiwYMjhoQvL7XsKKfRz4pM
This commit is contained in:
3 files changed
+134
-18
No files matched your search
@@ -23,7 +23,8 @@ class VehicleVinDecodeJob < ApplicationJob
|
||||
log "Looking up VIN for vehicle ##{vehicle_id}"
|
||||
vehicle = Vehicle.find_by(id: vehicle_id)
|
||||
return unless vehicle&.vin.present?
|
||||
result = VinDecoder.call(vehicle.vin)
|
||||
# The year on file (if someone entered one) helps NHTSA, especially for older vehicles
|
||||
result = VinDecoder.call(vehicle.vin, model_year: vehicle.year)
|
||||
|
||||
unless result.success?
|
||||
log "Failed to decode vin"
|
||||
|
||||
Reference in new issue
Block a user