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

28 lines
644 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("/")
2018-10-15 15:48:46 +02:00
call(url, geojson)
end
def self.search_cadastre(geojson)
2018-05-22 17:38:33 +02:00
url = [API_CARTO_URL, "cadastre", "geometrie"].join("/")
2018-10-15 15:48:46 +02:00
call(url, geojson)
end
private
2018-10-15 15:48:46 +02:00
def self.call(url, geojson)
verify_ssl_mode = OpenSSL::SSL::VERIFY_NONE
2018-10-15 15:48:46 +02:00
params = geojson.to_s
2018-10-15 15:50:23 +02:00
client = RestClient::Resource.new(url, verify_ssl: verify_ssl_mode)
client.post(params, content_type: 'application/json')
rescue RestClient::InternalServerError
raise RestClient::ResourceNotFound
end
end