Class: Nylas::CalendarCollection

Inherits:
Collection show all
Defined in:
lib/nylas/calendar_collection.rb

Overview

Additional methods for some of Calendar's other functionality

Instance Attribute Summary

Attributes inherited from Collection

#api, #constraints, #model

Instance Method Summary collapse

Methods inherited from Collection

#count, #create, #each, #execute, #expanded, #find, #find_each, #find_model, #find_raw, #ids, #initialize, #limit, #more_pages?, #new, #next_page, #offset, #raw, #resources_path, #search, #to_be_executed, #where

Constructor Details

This class inherits a constructor from Nylas::Collection

Instance Method Details

#availability(duration_minutes:, interval_minutes:, start_time:, end_time:, emails: [], buffer: nil, round_robin: nil, free_busy: [], open_hours: [], calendars: []) ⇒ Hash

Check multiple calendars to find available time slots for a single meeting

Parameters:

  • duration_minutes (Integer)

    The total number of minutes the event should last

  • interval_minutes (Integer)

    How many minutes it should check for availability

  • start_time (Integer)

    The timestamp for the beginning of the event

  • end_time (Integer)

    The timestamp for the end of the event

  • emails (Array<String>) (defaults to: [])

    Emails on the same domain to check

  • buffer (Integer) (defaults to: nil)

    The amount of buffer time in minutes that you want around existing meetings

  • round_robin (String) (defaults to: nil)

    Finds available meeting times in a round-robin style

  • free_busy (Array<Nylas::FreeBusy>) (defaults to: [])

    A list of free-busy data for users not in your organization

  • open_hours (Array<Nylas::OpenHours>) (defaults to: [])

    Additional times email accounts are available

  • calendars (Array) (defaults to: [])

    Check account and calendar IDs for free/busy status

Returns:

  • (Hash)

    The availability information; a list of time slots where all participants are available



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/nylas/calendar_collection.rb', line 19

def availability(duration_minutes:,
                 interval_minutes:,
                 start_time:,
                 end_time:,
                 emails: [],
                 buffer: nil,
                 round_robin: nil,
                 free_busy: [],
                 open_hours: [],
                 calendars: [])
  validate_calendars_or_emails(calendars, emails)
  validate_open_hours(emails, free_busy, open_hours) unless open_hours.empty?

  execute_availability("/calendars/availability",
                       duration_minutes: duration_minutes,
                       interval_minutes: interval_minutes,
                       start_time: start_time,
                       end_time: end_time,
                       emails: emails,
                       buffer: buffer,
                       round_robin: round_robin,
                       free_busy: free_busy.map(&:to_h),
                       open_hours: open_hours.map(&:to_h),
                       calendars: calendars)
end

#consecutive_availability(duration_minutes:, interval_minutes:, start_time:, end_time:, emails: [], buffer: nil, free_busy: [], open_hours: [], calendars: []) ⇒ Hash

Check multiple calendars to find availability for multiple meetings with several participants

Parameters:

  • duration_minutes (Integer)

    The total number of minutes the event should last

  • interval_minutes (Integer)

    How many minutes it should check for availability

  • start_time (Integer)

    The timestamp for the beginning of the event

  • end_time (Integer)

    The timestamp for the end of the event

  • emails (Array<Array<String>>) (defaults to: [])

    Emails on the same domain to check

  • buffer (Integer) (defaults to: nil)

    The amount of buffer time in minutes that you want around existing meetings

  • free_busy (Array<Nylas::FreeBusy>) (defaults to: [])

    A list of free-busy data for users not in your organization

  • open_hours (Array<Nylas::OpenHours>) (defaults to: [])

    Additional times email accounts are available

  • calendars (Array) (defaults to: [])

    Check account and calendar IDs for free/busy status

Returns:

  • (Hash)

    The availability information; a list of all possible groupings that share time slots



56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/nylas/calendar_collection.rb', line 56

def consecutive_availability(duration_minutes:,
                             interval_minutes:,
                             start_time:,
                             end_time:,
                             emails: [],
                             buffer: nil,
                             free_busy: [],
                             open_hours: [],
                             calendars: [])
  validate_calendars_or_emails(emails, calendars)
  validate_open_hours(emails, free_busy, open_hours) unless open_hours.empty?

  execute_availability("/calendars/availability/consecutive",
                       duration_minutes: duration_minutes,
                       interval_minutes: interval_minutes,
                       start_time: start_time,
                       end_time: end_time,
                       emails: emails,
                       buffer: buffer,
                       free_busy: free_busy.map(&:to_h),
                       open_hours: open_hours.map(&:to_h),
                       calendars: calendars)
end