2018-10-15 17:26:06 +02:00
|
|
|
class ApiGeo::Driver
|
|
|
|
def self.regions
|
|
|
|
url = [API_GEO_URL, "regions"].join("/")
|
|
|
|
call(url)
|
|
|
|
end
|
2018-10-15 16:30:27 +02:00
|
|
|
|
2018-10-15 17:26:06 +02:00
|
|
|
def self.departements
|
|
|
|
url = [API_GEO_URL, "departements"].join("/")
|
|
|
|
call(url)
|
|
|
|
end
|
2018-10-15 16:30:27 +02:00
|
|
|
|
2018-10-15 17:26:06 +02:00
|
|
|
def self.pays
|
|
|
|
File.open('app/lib/api_geo/pays.json').read
|
|
|
|
end
|
2018-10-15 16:30:27 +02:00
|
|
|
|
2018-10-15 17:26:06 +02:00
|
|
|
private
|
2018-10-15 16:30:27 +02:00
|
|
|
|
2018-10-15 17:26:06 +02:00
|
|
|
def self.call(url)
|
|
|
|
RestClient.get(url, params: { fields: :nom })
|
|
|
|
rescue RestClient::ServiceUnavailable
|
|
|
|
nil
|
2018-10-15 16:30:27 +02:00
|
|
|
end
|
|
|
|
end
|