Sha256: 0a268d338b450ee05ab5f46726ed07bfbbd6015c2f568df8f7ba192cb29c5b13

Contents?: true

Size: 1.54 KB

Versions: 5

Compression:

Stored size: 1.54 KB

Contents

module Google

  #
  # CalendarList is the main object you use to find Calendars.
  #
  class CalendarList

    attr_reader :connection

    #
    # 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 (https://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. Use 'urn:ietf:wg:oauth:2.0:oob' if you are using an 'application'" 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.
    #
    def initialize(params={}, connection=nil)
      @connection = connection || Connection.factory(params)
    end

    #
    # Find all entries on the user's calendar list. Returns an array of CalendarListEntry objects.
    #
    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

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
google_calendar-0.6.4 lib/google/calendar_list.rb
google_calendar-0.6.2 lib/google/calendar_list.rb
google_calendar-0.6.1 lib/google/calendar_list.rb
google_calendar-0.6.0 lib/google/calendar_list.rb
google_calendar-0.5.2 lib/google/calendar_list.rb