demarches-normaliennes/app/lib/api_carto/api.rb
2019-01-28 18:22:55 +01:00

22 lines
619 B
Ruby

class ApiCarto::API
def self.search_qp(geojson)
url = [API_CARTO_URL, "quartiers-prioritaires", "search"].join("/")
call(url, geojson)
end
def self.search_cadastre(geojson)
url = [API_CARTO_URL, "cadastre", "geometrie"].join("/")
call(url, geojson)
end
private
def self.call(url, geojson)
params = geojson.to_s
RestClient.post(url, params, content_type: 'application/json')
rescue RestClient::InternalServerError, RestClient::BadGateway, RestClient::GatewayTimeout => e
Rails.logger.error "[ApiCarto] Error on #{url}: #{e}"
raise RestClient::ResourceNotFound
end
end