Ad requirement 4

I have no idea how this requirement shall be implemented at the end, but at first step, the tiss_crawler.rb lib checks if the search_term is an empty string and returns an error msg if found

otherwise it returns the result, but appended to 'content' key
This commit is contained in:
Pfingstfrosch
2020-05-31 15:48:17 +02:00
parent 72b9f7d7a0
commit cfcbf5acdb
5 changed files with 43 additions and 9 deletions
+8 -3
View File
@@ -10,10 +10,15 @@ class TissCrawler
search_parameter = params[:search_parameter]
search_term = params[:search_term].parameterize(separator: '+')
url = host + api + '?' + search_parameter + '=' + search_term
puts(url)
puts('generated url:', url)
if search_term == ""
{'error': 'Dare you try! Empty searches are not allowed!'}
else
response = HTTParty.get(url)
{'content': JSON.parse(response.body)['results']}
end
response = HTTParty.get(url)
JSON.parse(response.body)['results']
end
def self.get_details(params)