Class: MotoRecall::Client::Ford

Inherits:
GenericClient show all
Defined in:
lib/moto_recall/client/ford.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GenericClient

#fetch, #find, #initialize, #url

Constructor Details

This class inherits a constructor from MotoRecall::Client::GenericClient

Class Method Details

.url(vin = nil) ⇒ Object



5
6
7
# File 'lib/moto_recall/client/ford.rb', line 5

def self.url(vin = nil)
  "https://owner.ford.com/sharedServices/recalls/query.do?country=USA&language=EN&vin=#{vin}"
end

Instance Method Details

#format(recall) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/moto_recall/client/ford.rb', line 15

def format(recall)
  # ford returns two different kinds of recalls, each with
  # different attributes. if the recall has a key called
  # "local_fsa_r" then it is a fd specific recall and we
  # need to treat it slightly differently.
  if recall.has_key?("local_fsa_r")
    {
      type: nil,
      nhtsa_number: nil,
      oem_number: recall["local_fsa_r"],
      date: nil,
      title: recall["description_eng"],
      description: nil,
      safety_risk: nil,
      remedy: nil,
      status: nil,
      notes: nil
    }
  else
    {
      type: nil,
      nhtsa_number: recall["nhtsa_recall_number"],
      oem_number: recall["mfr_recall_number"],
      date: recall["recall_date"],
      title: recall["description_eng"],
      description: recall["recall_description"],
      safety_risk: recall["safety_risk_description"],
      remedy: recall["remedy_description"],
      status: recall["mfr_recall_status"],
      notes: recall["mfr_notes"]
    }
  end
end

#process(response) ⇒ Object



9
10
11
12
13
# File 'lib/moto_recall/client/ford.rb', line 9

def process(response)
  parsed_response = JSON.parse(response)
  recalls = parsed_response["recalls"] || {}
  ([recalls["nhtsa_recall_item"]] + [recalls["fsa_item"]]).flatten.compact
end