class MotoRecall::Client::Hyundai

Public Class Methods

url(vin = nil) click to toggle source
# File lib/moto_recall/client/hyundai.rb, line 6
def self.url(vin = nil)
  "https://autoservice.hyundaiusa.com/CampaignHome/?VIN=#{vin}"
end

Public Instance Methods

fetch(vin) click to toggle source
# File lib/moto_recall/client/hyundai.rb, line 10
def fetch(vin)
  agent = Mechanize.new

  data = { txtVIN: vin }

  response = agent.post(url(vin), data)

  response.body
end
format(recall) click to toggle source
# File lib/moto_recall/client/hyundai.rb, line 31
def format(recall)
  {
    type: recall["Campaign Type"],
    nhtsa_number: nil,
    oem_number: recall["Campaign#"],
    date: recall["Campaign Date"],
    title: nil,
    description: recall["Campaign Description"],
    safety_risk: nil,
    remedy: recall["Customer Action"],
    status: nil,
    notes: nil
  }
end
process(response) click to toggle source
# File lib/moto_recall/client/hyundai.rb, line 20
def process(response)
  doc = Nokogiri::HTML(response)
  table = doc.css("#open-campaign-table")
  table.css("tr.campaign-individual").map do |tr|
    tr.css("td").reduce({}) do |memo, td|
      memo[td.attr("data-label")] = td.text.sub(/\s+:/, "").strip
      memo
    end
  end
end