2016-10-12 17:22:56 +02:00
|
|
|
module Carto
|
|
|
|
module GeoAPI
|
|
|
|
class Driver
|
|
|
|
def self.regions
|
|
|
|
call regions_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.departements
|
|
|
|
call departements_url
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.pays
|
2016-12-16 10:42:34 +01:00
|
|
|
File.open('app/lib/carto/geo_api/pays.json').read
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.departements_url
|
|
|
|
'https://geo.api.gouv.fr/departements'
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.regions_url
|
|
|
|
'https://geo.api.gouv.fr/regions'
|
2016-10-12 17:22:56 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def self.call api_url
|
|
|
|
RestClient.get api_url, params: { fields: :nom }
|
|
|
|
rescue RestClient::ServiceUnavailable
|
|
|
|
nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|