class MotoRecall::Client::Isuzu

Public Class Methods

url(vin = nil) click to toggle source
# File lib/moto_recall/client/isuzu.rb, line 3
def self.url(vin = nil)
  "http://www.isuzu.com/index.jsp"
end

Public Instance Methods

fetch(vin) click to toggle source
# File lib/moto_recall/client/isuzu.rb, line 7
def fetch(vin)
  agent = Mechanize.new
  agent.user_agent_alias = "Windows Chrome"

  response = agent.post(url, {
    "vin" => vin
  })

  response.body
end
format(recall) click to toggle source
# File lib/moto_recall/client/isuzu.rb, line 37
def format(recall)
  {
    type: nil,
    nhtsa_number: recall[:nhtsa_number],
    oem_number: recall[:oem_number],
    date: nil,
    title: nil,
    description: recall[:description],
    safety_risk: nil,
    remedy: nil,
    status: recall[:status],
    notes: nil
  }
end
process(response) click to toggle source
# File lib/moto_recall/client/isuzu.rb, line 18
def process(response)
  doc = Nokogiri::HTML(response)
  table = doc.css("#form table table")
  if table.empty?
    []
  else
    table.css("tr").drop(1).reduce([]) do |memo, row|
      cells = row.css("td")
      memo << {
        oem_number: cells[0].text,
        description: cells[1].text,
        nhtsa_number: cells[2].text,
        status: cells[3].text
      }
      memo
    end
  end
end