Class: MotoRecall::Client::Hyundai
Class Method Summary
collapse
Instance Method Summary
collapse
#find, #initialize, #url
Class Method Details
.url(vin = nil) ⇒ Object
6
7
8
|
# File 'lib/moto_recall/client/hyundai.rb', line 6
def self.url(vin = nil)
"https://autoservice.hyundaiusa.com/CampaignHome/?VIN=#{vin}"
end
|
Instance Method Details
#fetch(vin) ⇒ Object
10
11
12
13
14
15
16
17
18
|
# 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
|
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# 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) ⇒ Object
20
21
22
23
24
25
26
27
28
29
|
# 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
|