class MotoRecall::Client::Ford

Public Class Methods

url(vin = nil) click to toggle source
# 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

Public Instance Methods

format(recall) click to toggle source
# 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) click to toggle source
# 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