Simplify CARTO::SGMAP::API

This commit is contained in:
gregoirenovel 2018-10-15 15:48:46 +02:00
parent 2ed4c1da1c
commit 5df4e3305e

View file

@ -4,23 +4,24 @@ class CARTO::SGMAP::API
def self.search_qp(geojson)
url = [API_CARTO_URL, "quartiers-prioritaires", "search"].join("/")
call(url, { geojson: geojson.to_s })
call(url, geojson)
end
def self.search_cadastre(geojson)
url = [API_CARTO_URL, "cadastre", "geometrie"].join("/")
call(url, { geojson: geojson.to_s })
call(url, geojson)
end
private
def self.call(url, params)
def self.call(url, geojson)
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
params = geojson.to_s
RestClient::Resource.new(
url,
verify_ssl: verify_ssl_mode
).post(params[:geojson], content_type: 'application/json')
).post(params, content_type: 'application/json')
rescue RestClient::InternalServerError
raise RestClient::ResourceNotFound