class Nylas::Calendars

Nylas Calendar API

Public Instance Methods

create(identifier:, request_body:) click to toggle source

Create a calendar.

@param identifier [String] Grant ID or email account in which to create the object. @param request_body [Hash] The values to create the calendar with. @return [Array(Hash, String)] The created calendar and API Request ID.

# File lib/nylas/resources/calendars.rb, line 43
def create(identifier:, request_body:)
  post(
    path: "#{api_uri}/v3/grants/#{identifier}/calendars",
    request_body: request_body
  )
end
destroy(identifier:, calendar_id:) click to toggle source

Delete a calendar.

@param identifier [String] Grant ID or email account from which to delete an object. @param calendar_id [String] The id of the calendar to delete.

Use "primary" to refer to the primary calendar associated with grant.

@return [Array(TrueClass, String)] True and the API Request ID for the delete operation.

# File lib/nylas/resources/calendars.rb, line 70
def destroy(identifier:, calendar_id:)
  _, request_id = delete(
    path: "#{api_uri}/v3/grants/#{identifier}/calendars/#{calendar_id}"
  )

  [true, request_id]
end
find(identifier:, calendar_id:) click to toggle source

Return a calendar.

@param identifier [String] Grant ID or email account to query. @param calendar_id [String] The id of the calendar to return.

Use "primary" to refer to the primary calendar associated with grant.

@return [Array(Hash, String)] The calendar and API request ID.

# File lib/nylas/resources/calendars.rb, line 32
def find(identifier:, calendar_id:)
  get(
    path: "#{api_uri}/v3/grants/#{identifier}/calendars/#{calendar_id}"
  )
end
get_availability(request_body:) click to toggle source

Checks multiple calendars to find available time slots for a single meeting.

@param request_body [Hash] Request body to pass to the request. @return [Array(Hash, String)] Availability object and API request ID.

# File lib/nylas/resources/calendars.rb, line 82
def get_availability(request_body:)
  post(
    path: "#{api_uri}/v3/calendars/availability",
    request_body: request_body
  )
end
get_free_busy(identifier:, request_body:) click to toggle source

Get the free/busy schedule for a list of email addresses.

@param identifier [str] The identifier of the grant to act upon. @param request_body [Hash] Request body to pass to the request. @return [Array(Array(Hash), String)] The free/busy response.

# File lib/nylas/resources/calendars.rb, line 94
def get_free_busy(identifier:, request_body:)
  post(
    path: "#{api_uri}/v3/grants/#{identifier}/calendars/free-busy",
    request_body: request_body
  )
end
list(identifier:, query_params: nil) click to toggle source

Return all calendars.

@param identifier [String] Grant ID or email account to query. @param query_params [Hash, nil] Query params to pass to the request. @return [Array(Array(Hash), String, String)] The list of calendars, API Request ID, and next cursor.

# File lib/nylas/resources/calendars.rb, line 19
def list(identifier:, query_params: nil)
  get_list(
    path: "#{api_uri}/v3/grants/#{identifier}/calendars",
    query_params: query_params
  )
end
update(identifier:, calendar_id:, request_body:) click to toggle source

Update a calendar.

@param identifier [String] Grant ID or email account in which to update an object. @param calendar_id [String] The id of the calendar to update.

Use "primary" to refer to the primary calendar associated with grant.

@param request_body [Hash] The values to update the calendar with @return [Array(Hash, String)] The updated calendar and API Request ID.

# File lib/nylas/resources/calendars.rb, line 57
def update(identifier:, calendar_id:, request_body:)
  put(
    path: "#{api_uri}/v3/grants/#{identifier}/calendars/#{calendar_id}",
    request_body: request_body
  )
end