Module: Millionsend::Emails

Defined in:
lib/millionsend/emails.rb

Overview

Transactional email: send one, look it up, cancel a scheduled one.

Class Method Summary collapse

Class Method Details

.cancel(id) ⇒ Object

POST /emails/:id/cancel — scheduled, unsent emails only.



24
25
26
# File 'lib/millionsend/emails.rb', line 24

def cancel(id)
  Millionsend::Request.new(method: :post, path: "/emails/#{Millionsend::Util.encode(id)}/cancel").perform
end

.get(id) ⇒ Object

GET /emails/:id



19
20
21
# File 'lib/millionsend/emails.rb', line 19

def get(id)
  Millionsend::Request.new(method: :get, path: "/emails/#{Millionsend::Util.encode(id)}").perform
end

.send(params = {}, options = {}) ⇒ Object Also known as: create

POST /emails. Accepts a params hash or bare keywords (Emails.send(from: ..., to: ...)); a trailing options hash carries idempotency_key. No keyword parameters are declared on purpose — Ruby 3 keyword separation would otherwise reject the bare-keyword call shape.



11
12
13
14
15
# File 'lib/millionsend/emails.rb', line 11

def send(params = {}, options = {})
  Millionsend::Request.new(
    method: :post, path: "/emails", body: params, idempotency_key: options[:idempotency_key]
  ).perform
end