2016-01-12 17:24:42 +01:00
|
|
|
class CARTO::SGMAP::API
|
2015-11-23 18:41:24 +01:00
|
|
|
def initialize
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.search_qp(geojson)
|
|
|
|
endpoint = "/quartiers-prioritaires/search"
|
|
|
|
call(base_url + endpoint, {geojson: geojson.to_s})
|
|
|
|
end
|
|
|
|
|
2016-01-12 17:24:42 +01:00
|
|
|
def self.search_cadastre(geojson)
|
|
|
|
endpoint = "/cadastre/geometrie"
|
|
|
|
call(base_url + endpoint, {geojson: geojson.to_s})
|
|
|
|
end
|
|
|
|
|
2015-11-23 18:41:24 +01:00
|
|
|
private
|
|
|
|
|
|
|
|
def self.call(url, params = {})
|
|
|
|
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
|
|
|
|
|
|
|
|
RestClient::Resource.new(
|
|
|
|
url,
|
|
|
|
verify_ssl: verify_ssl_mode,
|
|
|
|
).post params[:geojson], content_type: 'application/json'
|
2016-12-20 12:27:53 +01:00
|
|
|
|
|
|
|
rescue RestClient::InternalServerError
|
|
|
|
raise RestClient::ResourceNotFound
|
2015-11-23 18:41:24 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.base_url
|
2015-11-30 17:03:36 +01:00
|
|
|
'https://apicarto.sgmap.fr'
|
2015-11-23 18:41:24 +01:00
|
|
|
end
|
|
|
|
end
|