Class: Nylas::Folders

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

Overview

Nylas Folder 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 folder.

Parameters:

  • identifier (String)

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

  • request_body (Hash)

    The values to create the folder with.

Returns:

  • (Array(Hash, String))

    The created folder and API Request ID.



49
50
51
52
53
54
# File 'lib/nylas/resources/folders.rb', line 49

def create(identifier:, request_body:)
  post(
    path: "#{api_uri}/v3/grants/#{identifier}/folders",
    request_body: request_body
  )
end

#destroy(identifier:, folder_id:) ⇒ Array(TrueClass, String)

Delete a folder.

Parameters:

  • identifier (String)

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

  • folder_id (String)

    The id of the folder to delete.

Returns:

  • (Array(TrueClass, String))

    True and the API Request ID for the delete operation.



74
75
76
77
78
79
80
# File 'lib/nylas/resources/folders.rb', line 74

def destroy(identifier:, folder_id:)
  _, request_id = delete(
    path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}"
  )

  [true, request_id]
end

#find(identifier:, folder_id:, query_params: nil) ⇒ Array(Hash, String)

Return a folder.

Parameters:

  • identifier (String)

    Grant ID or email account to query.

  • folder_id (String)

    The id of the folder to return.

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

    Query params to pass to the request.

Returns:

  • (Array(Hash, String))

    The folder and API request ID.



37
38
39
40
41
42
# File 'lib/nylas/resources/folders.rb', line 37

def find(identifier:, folder_id:, query_params: nil)
  get(
    path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}",
    query_params: query_params
  )
end

#list(identifier:, query_params: nil) ⇒ Array(Array(Hash), String, String)

Return all folders.

Parameters:

  • identifier (String)

    Grant ID or email account to query.

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

    Query params to pass to the request. Supported parameters include:

    • single_level: (Boolean) For Microsoft accounts only. If true, retrieves folders from a single-level hierarchy only. If false (default), retrieves folders across a multi-level hierarchy.

    • include_hidden_folders [Boolean] (Microsoft only) When true, includes hidden folders.

Returns:

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

    The list of folders, API Request ID, and next cursor.



24
25
26
27
28
29
# File 'lib/nylas/resources/folders.rb', line 24

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

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

Update a folder.

Parameters:

  • identifier (String)

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

  • folder_id (String)

    The id of the folder to update.

  • request_body (Hash)

    The values to update the folder with

Returns:

  • (Array(Hash, String))

    The updated folder and API Request ID.



62
63
64
65
66
67
# File 'lib/nylas/resources/folders.rb', line 62

def update(identifier:, folder_id:, request_body:)
  put(
    path: "#{api_uri}/v3/grants/#{identifier}/folders/#{folder_id}",
    request_body: request_body
  )
end