Class: Nylas::NewMessage

Inherits:
Object
  • Object
show all
Includes:
Model
Defined in:
lib/nylas/new_message.rb

Overview

Data structure for sending a message via the Nylas API

Instance Attribute Summary

Attributes included from Model

#api

Instance Method Summary collapse

Methods included from Model

#auth_method, #create, #destroy, #execute, included, #model_class, #persisted?, #reload, #resource_path, #resources_path, #save, #save_all_attributes, #to_json, #update, #update_all_attributes

Instance Method Details

#send!Message

Sends the new message

Returns:

Raises:

  • (RuntimeError)

    if the API response data was not a hash



32
33
34
35
36
37
# File 'lib/nylas/new_message.rb', line 32

def send!
  message_data = api.execute(method: :post, path: "/send", payload: to_json)
  raise "Unexpected response from the server, data received not a Message" unless message_data.is_a?(Hash)

  Message.from_hash(message_data, api: api)
end