Class: Google::Freebusy

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

Overview

Freebusy returns free/busy information for a set of calendars

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Setup and query the free/busy status of a collection of 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.



24
25
26
# File 'lib/google/freebusy.rb', line 24

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

Instance Attribute Details

#connectionObject (readonly)

Returns the value of attribute connection.



11
12
13
# File 'lib/google/freebusy.rb', line 11

def connection
  @connection
end

Instance Method Details

#query(calendar_ids, start_time, end_time) ⇒ Object

Find the busy times of the supplied calendar IDs, within the boundaries of the supplied start_time and end_time

The arguments supplied are

  • calendar_ids => array of Google calendar IDs as strings

  • start_time => a Time object, the start of the interval for the query.

  • end_time => a Time object, the end of the interval for the query.



37
38
39
40
41
42
43
44
# File 'lib/google/freebusy.rb', line 37

def query(calendar_ids, start_time, end_time)
  query_content = json_for_query(calendar_ids, start_time, end_time)
  response = @connection.send("/freeBusy", :post, query_content)

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

  parse_freebusy_response(response.body)
end