Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
require 'json'
require 'open-uri'
require 'uri'
class GoogleProductsSearch
def self.find_all_by_query(query)
file = open("https://www.googleapis.com/shopping/search/v1/public/products?key=#{ENV["GOOGLE_PRODUCTS_API_KEY"]}&country=US&q=#{URI.escape(query)}")
JSON.load(file.read)["items"] || []
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.