2016-10-12 17:22:56 +02:00
|
|
|
module Carto
|
|
|
|
module GeoAPI
|
|
|
|
class Driver
|
|
|
|
def self.regions
|
2018-05-22 19:01:04 +02:00
|
|
|
url = [API_GEO_URL, "regions"].join("/")
|
2018-05-22 17:40:13 +02:00
|
|
|
call(url)
|
2016-10-12 17:22:56 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.departements
|
2018-05-22 19:01:04 +02:00
|
|
|
url = [API_GEO_URL, "departements"].join("/")
|
2018-05-22 17:40:13 +02:00
|
|
|
call(url)
|
2016-10-12 17:22:56 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.pays
|
2016-12-16 10:42:34 +01:00
|
|
|
File.open('app/lib/carto/geo_api/pays.json').read
|
|
|
|
end
|
|
|
|
|
2016-10-12 17:22:56 +02:00
|
|
|
private
|
|
|
|
|
2018-03-20 17:47:37 +01:00
|
|
|
def self.call(api_url)
|
2016-10-12 17:22:56 +02:00
|
|
|
RestClient.get api_url, params: { fields: :nom }
|
|
|
|
rescue RestClient::ServiceUnavailable
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|