Skip to content

Instantly share code, notes, and snippets.

@priyankamk
Last active March 31, 2019 01:18
Show Gist options
  • Save priyankamk/b259e35ac5d9c104754c51772c60f740 to your computer and use it in GitHub Desktop.
Save priyankamk/b259e35ac5d9c104754c51772c60f740 to your computer and use it in GitHub Desktop.
sample giphy client
require 'httparty'
module Api
class Giphy
def self.fetch(query:)
response = HTTParty.get(
"http://giphyapi.com?q=#{query}&api_key=#{ENV['GIPHY_API_KEY']}&limit=15&offset=2"
)
return response['data'].map do |gif|
{
'slug': gif['slug'],
'original_url': gif.dig('images', 'original', 'url')
}
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment