Class: Google::CalendarList

Inherits:
Object
  • Object
show all
Defined in:
lib/google/calendar_list.rb

Overview

CalendarList is the main object you use to find Calendars.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}, connection = nil) ⇒ CalendarList

Setup and connect to the user’s list of Google Calendars.

The params parameter accepts

  • :client_id => the client ID that you received from Google after registering your application with them (console.developers.google.com/). REQUIRED

  • :client_secret => the client secret you received from Google after registering your application with them. REQUIRED

  • :redirect_url => the url where your users will be redirected to after they have successfully permitted access to their calendars. REQUIRED

  • :refresh_token => if a user has already given you access to their calendars, you can specify their refresh token here and you will be ‘logged on’ automatically (i.e. they don’t need to authorize access again). OPTIONAL

See Readme.rdoc or readme_code.rb for an explication on the OAuth2 authorization process.



21
22
23
# File 'lib/google/calendar_list.rb', line 21

def initialize(params={}, connection=nil)
  @connection = connection || Connection.factory(params)
end

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



8
9
10
# File 'lib/google/calendar_list.rb', line 8

def connection
  @connection
end

Instance Method Details

#fetch_entriesObject

Find all entries on the user’s calendar list. Returns an array of CalendarListEntry objects.



28
29
30
31
32
33
34
# File 'lib/google/calendar_list.rb', line 28

def fetch_entries
  response = @connection.send("/users/me/calendarList", :get)

  return nil if response.status != 200 || response.body.empty?

  CalendarListEntry.build_from_google_feed(JSON.parse(response.body), @connection)
end