module GoogleCells::Fetcher

Constants

BASE_URL

Public Instance Methods

raw(url=nil, params={}) click to toggle source
# File lib/google_cells/fetcher.rb, line 7
def raw(url=nil, params={})
  url ||= BASE_URL
  res = request(:get, url, url_params: params)
  res.body
end
request(method, url, params={}) click to toggle source
# File lib/google_cells/fetcher.rb, line 13
def request(method, url, params={})
  if params[:url_params] && !params[:url_params].empty?
    url << '?' unless url[-1] == "?"
    url << params[:url_params].to_a.map{|k,v| "#{k}=#{v}"}.join('&')
  end
  GoogleCells.client.authorization.fetch_access_token!
  GoogleCells.client.execute!(
    :http_method => method,
    :uri => url,
    :headers => params[:headers],
    :body => params[:body]
  ) 
end