Module: GoogleCalendarAbilities

Included in:
SkillActions
Defined in:
src/abilities/google_calendar_abilities.rb,
src/abilities/google_calendar_abilities/auth.rb

Defined Under Namespace

Classes: UserCalendar

Instance Method Summary collapse

Instance Method Details

#google_calendar(id: 'primary') ⇒ UserCalendar

Construct a UserCalendar object for a requested Google Calendar instance

The calendar object can be used to query or modify that calendar's events. On the first use for a particular user, that user is asked to give Zayo permission to use their calendar. The token is then scoped to the user and only used if the command originates from them.

This cannot be used for the on_start and on_stop hooks, as there is no active user.

Parameters:

  • id (String)

    The Google Calendar ID. Defaults to 'primary' which is the primary calendar of the user. Can also be an email address for the calendar the user has access to.

Returns:

  • (UserCalendar)

    The calendar API for the provided calendar id.



24
25
26
27
28
29
# File 'src/abilities/google_calendar_abilities.rb', line 24

def google_calendar(id: 'primary')
  raise 'Cannot use google calendar skills in system context' if context.system?

  @_google_calendar ||= {}
  @_google_calendar[[context.user.id, id]] ||= UserCalendar.new(context.user.id, id)
end