Class: Nylas::Calendars

Inherits:
Resource show all
Includes:
ApiOperations::Delete, ApiOperations::Get, ApiOperations::Post, ApiOperations::Put
Defined in:
lib/nylas/resources/calendars.rb

Overview

Nylas Calendar API

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Nylas::Resource

Instance Method Details

#create(identifier:, request_body:) ⇒ Array(Hash, String)

Create a calendar.

Parameters:

  • identifier (String)

    Grant ID or email account in which to create the object.

  • request_body (Hash)

    The values to create the calendar with.

Returns:

  • (Array(Hash, String))

    The created calendar and API Request ID.



43
44
45
46
47
48
# 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:) ⇒ Array(TrueClass, String)

Delete a calendar.

Parameters:

  • identifier (String)

    Grant ID or email account from which to delete an object.

  • calendar_id (String)

    The id of the calendar to delete. Use “primary” to refer to the primary calendar associated with grant.

Returns:

  • (Array(TrueClass, String))

    True and the API Request ID for the delete operation.



70
71
72
73
74
75
76
# 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:) ⇒ Array(Hash, String)

Return a calendar.

Parameters:

  • identifier (String)

    Grant ID or email account to query.

  • calendar_id (String)

    The id of the calendar to return. Use “primary” to refer to the primary calendar associated with grant.

Returns:

  • (Array(Hash, String))

    The calendar and API request ID.



32
33
34
35
36
# 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:) ⇒ Array(Hash, String)

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

Parameters:

  • request_body (Hash)

    Request body to pass to the request.

Returns:

  • (Array(Hash, String))

    Availability object and API request ID.



82
83
84
85
86
87
# 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:) ⇒ Array(Array(Hash), String)

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

Parameters:

  • identifier (str)

    The identifier of the grant to act upon.

  • request_body (Hash)

    Request body to pass to the request.

Returns:

  • (Array(Array(Hash), String))

    The free/busy response.



94
95
96
97
98
99
# 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) ⇒ Array(Array(Hash), String)

Return all calendars.

Parameters:

  • identifier (String)

    Grant ID or email account to query.

  • query_params (Hash, nil) (defaults to: nil)

    Query params to pass to the request.

Returns:

  • (Array(Array(Hash), String))

    The list of calendars and API Request ID.



19
20
21
22
23
24
# File 'lib/nylas/resources/calendars.rb', line 19

def list(identifier:, query_params: nil)
  get(
    path: "#{api_uri}/v3/grants/#{identifier}/calendars",
    query_params: query_params
  )
end

#update(identifier:, calendar_id:, request_body:) ⇒ Array(Hash, String)

Update a calendar.

Parameters:

  • identifier (String)

    Grant ID or email account in which to update an object.

  • calendar_id (String)

    The id of the calendar to update. Use “primary” to refer to the primary calendar associated with grant.

  • request_body (Hash)

    The values to update the calendar with

Returns:

  • (Array(Hash, String))

    The updated calendar and API Request ID.



57
58
59
60
61
62
# 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