commit
5b094d8b13
4 changed files with 12 additions and 30 deletions
|
@ -2,25 +2,19 @@ module Carto
|
|||
module GeoAPI
|
||||
class Driver
|
||||
def self.regions
|
||||
call regions_url
|
||||
url = [API_GEO_URL, "regions"].join("/")
|
||||
call(url)
|
||||
end
|
||||
|
||||
def self.departements
|
||||
call departements_url
|
||||
url = [API_GEO_URL, "departements"].join("/")
|
||||
call(url)
|
||||
end
|
||||
|
||||
def self.pays
|
||||
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'
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self.call(api_url)
|
||||
|
|
|
@ -3,13 +3,13 @@ class CARTO::SGMAP::API
|
|||
end
|
||||
|
||||
def self.search_qp(geojson)
|
||||
endpoint = "/quartiers-prioritaires/search"
|
||||
call(base_url + endpoint, { geojson: geojson.to_s })
|
||||
url = [API_CARTO_URL, "quartiers-prioritaires", "search"].join("/")
|
||||
call(url, { geojson: geojson.to_s })
|
||||
end
|
||||
|
||||
def self.search_cadastre(geojson)
|
||||
endpoint = "/cadastre/geometrie"
|
||||
call(base_url + endpoint, { geojson: geojson.to_s })
|
||||
url = [API_CARTO_URL, "cadastre", "geometrie"].join("/")
|
||||
call(url, { geojson: geojson.to_s })
|
||||
end
|
||||
|
||||
private
|
||||
|
@ -25,8 +25,4 @@ class CARTO::SGMAP::API
|
|||
rescue RestClient::InternalServerError
|
||||
raise RestClient::ResourceNotFound
|
||||
end
|
||||
|
||||
def self.base_url
|
||||
'https://apicarto.sgmap.fr'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
API_CARTO_URL = "https://apicarto.sgmap.fr"
|
||||
|
||||
API_ENTREPRISE_URL = 'https://entreprise.api.gouv.fr/v2'
|
||||
|
||||
API_GEO_URL = "https://geo.api.gouv.fr"
|
||||
|
||||
PIPEDRIVE_API_URL = 'https://api.pipedrive.com/v1'
|
||||
|
||||
DOC_URL = "https://doc.demarches-simplifiees.fr"
|
||||
|
|
|
@ -18,16 +18,4 @@ describe Carto::GeoAPI::Driver do
|
|||
|
||||
it { is_expected.to eq File.open('app/lib/carto/geo_api/pays.json').read }
|
||||
end
|
||||
|
||||
describe '.departements_url' do
|
||||
subject { described_class.departements_url }
|
||||
|
||||
it { is_expected.to eq 'https://geo.api.gouv.fr/departements' }
|
||||
end
|
||||
|
||||
describe '.regions_url' do
|
||||
subject { described_class.regions_url }
|
||||
|
||||
it { is_expected.to eq 'https://geo.api.gouv.fr/regions' }
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue