Class: MotoRecall::Client::GenericClient
- Inherits:
-
Object
- Object
- MotoRecall::Client::GenericClient
show all
- Defined in:
- lib/moto_recall/client/generic_client.rb
Direct Known Subclasses
Acura, Audi, Bmw, Chrysler, Ford, GeneralMotors, Honda, Hyundai, Infiniti, Isuzu, Jaguar, Kia, Mazda, Mitsubishi, Nissan, Subaru, Volkswagen, Volvo
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of GenericClient.
11
12
|
# File 'lib/moto_recall/client/generic_client.rb', line 11
def initialize
end
|
Class Method Details
.url(vin = nil) ⇒ Object
18
19
20
|
# File 'lib/moto_recall/client/generic_client.rb', line 18
def self.url(vin = nil)
raise NotImplementedError
end
|
Instance Method Details
#fetch(vin) ⇒ Object
31
32
33
34
|
# File 'lib/moto_recall/client/generic_client.rb', line 31
def fetch(vin)
url_with_vin = url(vin)
Net::HTTP.get(URI(url_with_vin))
end
|
#find(vin) ⇒ Object
22
23
24
25
26
27
28
29
|
# File 'lib/moto_recall/client/generic_client.rb', line 22
def find(vin)
response = fetch(vin)
raw_recalls = process(response) || []
recalls = raw_recalls.map { |recall| MotoRecall::Recall.new(format(recall)) }
MotoRecall::RecallSet.new(recalls, {
original_response: response
})
end
|
36
37
38
|
# File 'lib/moto_recall/client/generic_client.rb', line 36
def format(recall)
raise NotImplementedError
end
|
#process(response) ⇒ Object
40
41
42
|
# File 'lib/moto_recall/client/generic_client.rb', line 40
def process(response)
raise NotImplementedError
end
|
#url(vin = nil) ⇒ Object
14
15
16
|
# File 'lib/moto_recall/client/generic_client.rb', line 14
def url(vin = nil)
self.class.url(vin)
end
|