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, event_collection_id: 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

  • event_collection_id (String) (defaults to: nil)

    Unique identifier for a collection of events that are created

  • 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



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

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

  payload = {
    duration_minutes: duration_minutes,
    interval_minutes: interval_minutes,
    start_time: start_time,
    end_time: end_time,
    emails: emails,
    free_busy: free_busy.map(&:to_h),
    open_hours: open_hours.map(&:to_h),
    calendars: calendars
  }
  payload[:buffer] = buffer if buffer
  payload[:round_robin] = round_robin if round_robin
  payload[:event_collection_id] = event_collection_id if event_collection_id

  execute_availability("/calendars/availability", **payload)
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



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/nylas/calendar_collection.rb', line 62

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?

  payload = {
    duration_minutes: duration_minutes,
    interval_minutes: interval_minutes,
    start_time: start_time,
    end_time: end_time,
    emails: emails,
    free_busy: free_busy.map(&:to_h),
    open_hours: open_hours.map(&:to_h),
    calendars: calendars
  }
  payload[:buffer] = buffer if buffer

  execute_availability("/calendars/availability/consecutive", **payload)
end