Class Google::Base
In: lib/google/base.rb
Parent: Object

Methods

Attributes

sid  [RW]  Session id returned from google login request

Public Class methods

Returns the current connection

Changes the current connection to the one provided. If in an app you store the connection in a session, you can reuse it instead of establishing a new connection with each request.

Usage:

  Google::Base.connection = session[:connection] # => or whatever

Given an email and password it creates a new connection which will be used for this class and all sub classes.

Raises Google::LoginError if login fails or if, god forbid, google is having issues.

Makes a get request to a google service using the session id from the connection‘s session

Usage:

  get('http://google.com/some/thing')
  get('http://google.com/some/thing', :query_hash => {:q => 'test', :second => 'another'})
    # makes request to http://google.com/some/thing?q=test&second=another
  get('http://google.com/some/thing?ha=poo', :query_hash => {:q => 'test', :second => 'another'}, :qsi => '&')
    # makes request to http://google.com/some/thing?ha=poo&q=test&second=another

Creates a new instance of the connection class using the given email and password and attempts to login

Makes a post request to a google service using the session id from the connection‘s session

Usage:

  post('http://google.com/some/thing', :form_data => {:one => '1', :two => '2'})
    # makes a post request to http://google.com/some/thing with the form data set to one=1&two=2

Public Instance methods

Outputs the headers that are needed to make an authenticated request

Returns true or false based on whether or not the session id is set

Makes authentication request to google and sets the sid to be passed in a cookie with each authenticated request.

Raises Google::LoginError if login is unsuccessful

[Validate]