Sha256: 0565255e913f8744368d44d12c9269bf4b3b676197f5b2ba70cb2653fd2d0752

Contents?: true

Size: 717 Bytes

Versions: 2

Compression:

Stored size: 717 Bytes

Contents

module GoogleCells

  module Fetcher

    BASE_URL = 'https://spreadsheets.google.com/feeds/spreadsheets/private/full'

    def raw(url=nil, params={})
      url ||= BASE_URL
      res = request(:get, url, url_params: params)
      res.body
    end

    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
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
google-cells-0.4.0 lib/google_cells/fetcher.rb
google-cells-0.3.0 lib/google_cells/fetcher.rb