class MotoRecall::Client::Chrysler
Public Class Methods
url(vin)
click to toggle source
# File lib/moto_recall/client/chrysler.rb, line 3 def self.url(vin) "https://www.moparownerconnect.com/oc/us/en-us/sub/Pages/RecallsResults.aspx?Vin=#{vin}" end
Public Instance Methods
format(recall)
click to toggle source
# File lib/moto_recall/client/chrysler.rb, line 36 def format(recall) { type: nil, nhtsa_number: recall["NHTSA Recall #"], oem_number: recall["Chrysler Recall #"], date: recall["Recall Date"], title: nil, description: recall["Repair Description"], safety_risk: recall["Safety Defect/Non Compliance Description and Safety Risk"], remedy: nil, status: recall["Recall Status"], notes: nil } end
process(response)
click to toggle source
# File lib/moto_recall/client/chrysler.rb, line 7 def process(response) doc = Nokogiri::HTML(response) content = doc.css("#centerbodyContentWrp") recalls = [] unless content.text.include?("No Outstanding Recalls or Customer Satisfaction Notifications Exist") # Chrysler's response has two tables, one for "Safety Recalls" # which is at this selector (`#divSafetyRecallsTable table`) # and one for "Campaigns" (`#divCampaignTable table`). # `2C4RC1BG9ER209216` shows an example of a "Safety Recall" # but I haven't yet seen an example of a "Campaign." We will # want to make sure that we return content from both tables. tables = doc.css("#divSafetyRecallsTable table, #divCampaignTable table") tables.each do |table| headers = table.css("tr:first-child th").map { |th| th.text } recalls << table.css("tr:not(:first-child)").map do |tr| recall = {} tr.css("td").each_with_index do |td, i| recall[headers[i]] = td.text.strip end recall end end end recalls.flatten end