6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/api/giphy.rb', line 6
def search(query)
puts "dans le seeeeaaartch !!!"
query = query.gsub('!gsearch', '').strip
return "Please provide something to search" if query.nil? || query == ""
result = ""
response = HTTParty.get("#{WS_URL}?q=#{URI.encode(query)}&api_key=#{@@api_key}")
if response['data'] && response['data'].count > 0
gif = response['data'].first
result = "Check this : #{gif['url']}"
else
result = 'Nothing found with that parameter.'
end
result
end
|