class TissCrawlerController < ApplicationController require 'httparty' $host = 'https://tiss.tuwien.ac.at' def search url = _build_search_url(params) context = _get_context(params) response = HTTParty.get(url) case context when 'People' _search_people_result(response) else flash.now[:alert] = 'Unknown Tiss Crawler Context' end end def _build_search_url(params) if params[:api].blank? flash.now[:alert] = 'No api configured!' return else # get the api ... e.g. /'api/person/v22/psuche' api = params[:api] end if params[:search_parameter].blank? flash.now[:alert] = 'No search_parameter configured!' return else # get the search param ... e.g. 'q' search_parameter = params[:search_parameter] end if params[:search_term].blank? flash.now[:alert] = 'No search_term configured!' return else # get and parameterize search term q, replace whitespaces with + search_term = params[:search_term].parameterize(separator: '+') end # concat and return the api call url ... e.g. https://tiss.tuwien.ac.at/api/person/v22/psuche?q=max+mustermann $host + api + '?' + search_parameter + '=' + search_term end def _get_context(params) if params[:context].blank? flash.now[:alert] = 'No context configured!' else # return the context params[:context] end end def _search_people_result(response) # redirect_to(controller: 'people', :action => 'show', flash: {response: response}) @response = "Test" puts('got here', response) end def details end end