demarches-normaliennes/app/lib/carto/sgmap/api.rb

29 lines
661 B
Ruby
Raw Normal View History

class CARTO::SGMAP::API
def initialize
end
def self.search_qp(geojson)
2018-05-22 17:38:33 +02:00
url = [API_CARTO_URL, "quartiers-prioritaires", "search"].join("/")
call(url, { geojson: geojson.to_s })
end
def self.search_cadastre(geojson)
2018-05-22 17:38:33 +02:00
url = [API_CARTO_URL, "cadastre", "geometrie"].join("/")
call(url, { geojson: geojson.to_s })
end
private
def self.call(url, params)
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
RestClient::Resource.new(
2017-06-12 13:49:51 +02:00
url,
2018-10-01 14:08:12 +02:00
verify_ssl: verify_ssl_mode
2018-10-15 15:48:01 +02:00
).post(params[:geojson], content_type: 'application/json')
rescue RestClient::InternalServerError
raise RestClient::ResourceNotFound
end
end