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

33 lines
709 B
Ruby
Raw Normal View History

class CARTO::SGMAP::API
def initialize
end
def self.search_qp(geojson)
endpoint = "/quartiers-prioritaires/search"
call(base_url + endpoint, { geojson: geojson.to_s })
end
def self.search_cadastre(geojson)
endpoint = "/cadastre/geometrie"
call(base_url + endpoint, { 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,
verify_ssl: verify_ssl_mode,
).post params[:geojson], content_type: 'application/json'
rescue RestClient::InternalServerError
raise RestClient::ResourceNotFound
end
def self.base_url
2015-11-30 17:03:36 +01:00
'https://apicarto.sgmap.fr'
end
end