Class: Notisend::Message

Inherits:
OpenStruct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/notisend/message.rb

Overview

Class for interaction with messages

Class Method Summary collapse

Class Method Details

.deliver(opts = {}) ⇒ Object

Sends an email message


12
13
14
15
16
17
# File 'lib/notisend/message.rb', line 12

def deliver(opts = {})
  options = OpenStruct.new(opts)
  params = params_from(options)
  response = client.post(path, params, attachments: options.attachments).parsed_body
  new(response)
end

.deliver_template(template_id:, to:, params: {}) ⇒ Object

Sends an email message using a template


26
27
28
29
30
# File 'lib/notisend/message.rb', line 26

def deliver_template(template_id:, to:, params: {})
  url = "templates/#{template_id}/#{path}"
  response = client.post(url, to: to, params: params).parsed_body
  new(response)
end

.get(id:) ⇒ Object

Gets a message by id


20
21
22
23
# File 'lib/notisend/message.rb', line 20

def get(id:)
  response = client.get(path(id)).parsed_body
  new(response)
end