Merge pull request #1951 from betagouv/more-urls

More urls
This commit is contained in:
Frederic Merizen 2018-05-23 10:49:48 +02:00 committed by GitHub
commit 5b094d8b13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 30 deletions

View file

@ -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)

View file

@ -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

View file

@ -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"

View file

@ -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