demarches-normaliennes/app/lib/api_carto/api.rb

23 lines
651 B
Ruby
Raw Normal View History

2018-10-15 16:54:38 +02:00
class ApiCarto::API
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)
params = geojson.to_s
RestClient.post(url, params, content_type: 'application/json')
rescue RestClient::InternalServerError, RestClient::BadGateway, RestClient::GatewayTimeout, RestClient::ServiceUnavailable => e
Rails.logger.error "[ApiCarto] Error on #{url}: #{e}"
raise RestClient::ResourceNotFound
end
end