Class: Nylas::Messages

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

Overview

Nylas Messages API

Instance Method Summary collapse

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Nylas::Resource

Instance Method Details

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

Delete a message.

Parameters:

  • identifier (String)

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

  • message_id (String)

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

Returns:

  • (Array(TrueClass, String))

    True and the API Request ID for the delete operation.



57
58
59
60
61
62
63
# File 'lib/nylas/resources/messages.rb', line 57

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

  [true, request_id]
end

#find(identifier:, message_id:) ⇒ Array(Hash, String)

Return a message.

Parameters:

  • identifier (String)

    Grant ID or email account to query.

  • message_id (String)

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

Returns:

  • (Array(Hash, String))

    The message and API request ID.



31
32
33
34
35
# File 'lib/nylas/resources/messages.rb', line 31

def find(identifier:, message_id:)
  get(
    path: "#{api_uri}/v3/grants/#{identifier}/messages/#{message_id}"
  )
end

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

Return all messages.

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 messages and API Request ID.



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

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

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

Update a message.

Parameters:

  • identifier (String)

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

  • message_id (String)

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

  • request_body (Hash)

    The values to update the message with

Returns:

  • (Array(Hash, String))

    The updated message and API Request ID.



44
45
46
47
48
49
# File 'lib/nylas/resources/messages.rb', line 44

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