Class: Nylas::Messages
- Includes:
- ApiOperations::Delete, ApiOperations::Get, ApiOperations::Post, ApiOperations::Put
- Defined in:
- lib/nylas/resources/messages.rb
Overview
Nylas Messages API
Instance Attribute Summary collapse
-
#smart_compose ⇒ Object
readonly
Returns the value of attribute smart_compose.
Instance Method Summary collapse
-
#clean_messages(identifier:, request_body:) ⇒ Array(Hash)
Clean a message.
-
#destroy(identifier:, message_id:) ⇒ Array(TrueClass, String)
Delete a message.
-
#find(identifier:, message_id:, query_params: nil) ⇒ Array(Hash, String)
Return a message.
-
#find_scheduled_messages(identifier:, schedule_id:) ⇒ Array(Hash, String)
Retrieve your scheduled messages.
-
#initialize(sdk_instance) ⇒ Messages
constructor
Initializes the messages resource.
-
#list(identifier:, query_params: nil) ⇒ Array(Array(Hash), String, String)
Return all messages.
-
#list_scheduled_messages(identifier:) ⇒ Array(Array(Hash), String)
Retrieve your scheduled messages.
-
#send(identifier:, request_body:) ⇒ Array(Hash, String)
Send a message.
-
#stop_scheduled_messages(identifier:, schedule_id:) ⇒ Array(Hash, String)
Stop a scheduled message.
-
#update(identifier:, message_id:, request_body:, query_params: nil) ⇒ Array(Hash, String)
Update a message.
Constructor Details
#initialize(sdk_instance) ⇒ Messages
Initializes the messages resource.
20 21 22 23 |
# File 'lib/nylas/resources/messages.rb', line 20 def initialize(sdk_instance) super(sdk_instance) @smart_compose = SmartCompose.new(sdk_instance) end |
Instance Attribute Details
#smart_compose ⇒ Object (readonly)
Returns the value of attribute smart_compose.
16 17 18 |
# File 'lib/nylas/resources/messages.rb', line 16 def smart_compose @smart_compose end |
Instance Method Details
#clean_messages(identifier:, request_body:) ⇒ Array(Hash)
Clean a message.
83 84 85 86 87 88 |
# File 'lib/nylas/resources/messages.rb', line 83 def (identifier:, request_body:) put( path: "#{api_uri}/v3/grants/#{identifier}/messages/clean", request_body: request_body ) end |
#destroy(identifier:, message_id:) ⇒ Array(TrueClass, String)
Delete a message.
70 71 72 73 74 75 76 |
# File 'lib/nylas/resources/messages.rb', line 70 def destroy(identifier:, message_id:) _, request_id = delete( path: "#{api_uri}/v3/grants/#{identifier}/messages/#{}" ) [true, request_id] end |
#find(identifier:, message_id:, query_params: nil) ⇒ Array(Hash, String)
Return a message.
43 44 45 46 47 48 |
# File 'lib/nylas/resources/messages.rb', line 43 def find(identifier:, message_id:, query_params: nil) get( path: "#{api_uri}/v3/grants/#{identifier}/messages/#{}", query_params: query_params ) end |
#find_scheduled_messages(identifier:, schedule_id:) ⇒ Array(Hash, String)
Retrieve your scheduled messages.
134 135 136 137 138 |
# File 'lib/nylas/resources/messages.rb', line 134 def (identifier:, schedule_id:) get( path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules/#{schedule_id}" ) end |
#list(identifier:, query_params: nil) ⇒ Array(Array(Hash), String, String)
Return all messages.
30 31 32 33 34 35 |
# File 'lib/nylas/resources/messages.rb', line 30 def list(identifier:, query_params: nil) get_list( path: "#{api_uri}/v3/grants/#{identifier}/messages", query_params: query_params ) end |
#list_scheduled_messages(identifier:) ⇒ Array(Array(Hash), String)
Retrieve your scheduled messages.
123 124 125 126 127 |
# File 'lib/nylas/resources/messages.rb', line 123 def (identifier:) get( path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules" ) end |
#send(identifier:, request_body:) ⇒ Array(Hash, String)
Send a message.
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/nylas/resources/messages.rb', line 97 def send(identifier:, request_body:) payload = request_body opened_files = [] # Use form data only if the attachment size is greater than 3mb = request_body[:attachments] || request_body["attachments"] || [] = &.sum { || [:size] || 0 } || 0 if >= FileUtils::FORM_DATA_ATTACHMENT_SIZE payload, opened_files = FileUtils.build_form_request(request_body) end response = post( path: "#{api_uri}/v3/grants/#{identifier}/messages/send", request_body: payload ) opened_files.each(&:close) response end |
#stop_scheduled_messages(identifier:, schedule_id:) ⇒ Array(Hash, String)
Stop a scheduled message.
145 146 147 148 149 |
# File 'lib/nylas/resources/messages.rb', line 145 def (identifier:, schedule_id:) delete( path: "#{api_uri}/v3/grants/#{identifier}/messages/schedules/#{schedule_id}" ) end |
#update(identifier:, message_id:, request_body:, query_params: nil) ⇒ Array(Hash, String)
Update a message.
57 58 59 60 61 62 63 |
# File 'lib/nylas/resources/messages.rb', line 57 def update(identifier:, message_id:, request_body:, query_params: nil) put( path: "#{api_uri}/v3/grants/#{identifier}/messages/#{}", request_body: request_body, query_params: query_params ) end |