Skip to content

Instantly share code, notes, and snippets.

@sferik
Forked from dingeuwen/gsuberror.rb
Last active December 16, 2015 05:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sferik/5384353 to your computer and use it in GitHub Desktop.
Save sferik/5384353 to your computer and use it in GitHub Desktop.
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