Class: Sevk::Resources::Emails
- Defined in:
- lib/sevk/resources/emails.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#get(id) ⇒ Hash
Get an email by ID.
-
#send(to:, subject:, html:, from:, from_name: nil, reply_to: nil, text: nil, headers: nil, tags: nil, attachments: nil) ⇒ Hash
Send an email with optional attachments.
-
#send_bulk(emails) ⇒ Hash
Send multiple emails in bulk.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Sevk::Resources::Base
Instance Method Details
#get(id) ⇒ Hash
Get an email by ID
50 51 52 |
# File 'lib/sevk/resources/emails.rb', line 50 def get(id) client.get("/emails/#{id}") end |
#send(to:, subject:, html:, from:, from_name: nil, reply_to: nil, text: nil, headers: nil, tags: nil, attachments: nil) ⇒ Hash
Send an email with optional attachments
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/sevk/resources/emails.rb', line 22 def send(to:, subject:, html:, from:, from_name: nil, reply_to: nil, text: nil, headers: nil, tags: nil, attachments: nil) body = { to: to, subject: subject, html: html, from: from } body[:fromName] = from_name if from_name body[:replyTo] = reply_to if reply_to body[:text] = text if text body[:headers] = headers if headers body[:tags] = if body[:attachments] = if client.post("emails", body) end |
#send_bulk(emails) ⇒ Hash
Send multiple emails in bulk
42 43 44 |
# File 'lib/sevk/resources/emails.rb', line 42 def send_bulk(emails) client.post("emails/bulk", { emails: emails }) end |