Class: Unitpost::Resources::Email
- Defined in:
- lib/unitpost/resources.rb
Instance Attribute Summary collapse
-
#campaigns ⇒ Object
readonly
Returns the value of attribute campaigns.
-
#domains ⇒ Object
readonly
Returns the value of attribute domains.
-
#templates ⇒ Object
readonly
Returns the value of attribute templates.
-
#topics ⇒ Object
readonly
Returns the value of attribute topics.
Instance Method Summary collapse
-
#batch(body, idempotency_key: nil) ⇒ Object
Send up to 100 emails in one request (all-or-nothing validation).
- #cancel_batch(id) ⇒ Object
- #get(id) ⇒ Object
- #get_batch(id) ⇒ Object
-
#initialize(http) ⇒ Email
constructor
A new instance of Email.
- #list(limit: nil, after: nil, before: nil, **filters) ⇒ Object
- #list_all(**params) ⇒ Object
- #received_attachment_url(id, attachment_id) ⇒ Object
- #received_get(id) ⇒ Object
- #received_list(limit: nil, after: nil, before: nil) ⇒ Object
-
#send(body, idempotency_key: nil) ⇒ Object
Send or schedule a transactional email.
-
#stats(days: nil) ⇒ Object
Deliverability/engagement aggregates over a rolling window (days: 1–365, defaults to 30 server-side).
- #update(id, body) ⇒ Object
Constructor Details
Instance Attribute Details
#campaigns ⇒ Object (readonly)
Returns the value of attribute campaigns.
50 51 52 |
# File 'lib/unitpost/resources.rb', line 50 def campaigns @campaigns end |
#domains ⇒ Object (readonly)
Returns the value of attribute domains.
50 51 52 |
# File 'lib/unitpost/resources.rb', line 50 def domains @domains end |
#templates ⇒ Object (readonly)
Returns the value of attribute templates.
50 51 52 |
# File 'lib/unitpost/resources.rb', line 50 def templates @templates end |
#topics ⇒ Object (readonly)
Returns the value of attribute topics.
50 51 52 |
# File 'lib/unitpost/resources.rb', line 50 def topics @topics end |
Instance Method Details
#batch(body, idempotency_key: nil) ⇒ Object
Send up to 100 emails in one request (all-or-nothing validation). Like
send, when no idempotency_key is given the SDK generates one so a
transient retry is safe: the server dedupes the batch on the key and
replays the original result instead of re-sending. Pass your own to
dedupe across separate batch calls.
72 73 74 |
# File 'lib/unitpost/resources.rb', line 72 def batch(body, idempotency_key: nil) @http.request("POST", "/email/batch", body: body, idempotency_key: idempotency_key || SecureRandom.uuid) end |
#cancel_batch(id) ⇒ Object
80 81 82 |
# File 'lib/unitpost/resources.rb', line 80 def cancel_batch(id) @http.request("POST", "/email/batches/#{enc(id)}/cancel") end |
#get(id) ⇒ Object
92 93 94 |
# File 'lib/unitpost/resources.rb', line 92 def get(id) @http.request("GET", "/email/#{enc(id)}") end |
#get_batch(id) ⇒ Object
76 77 78 |
# File 'lib/unitpost/resources.rb', line 76 def get_batch(id) @http.request("GET", "/email/batches/#{enc(id)}") end |
#list(limit: nil, after: nil, before: nil, **filters) ⇒ Object
84 85 86 |
# File 'lib/unitpost/resources.rb', line 84 def list(limit: nil, after: nil, before: nil, **filters) @http.request("GET", "/email", query: list_params(limit: limit, after: after, before: before, **filters)) end |
#list_all(**params) ⇒ Object
88 89 90 |
# File 'lib/unitpost/resources.rb', line 88 def list_all(**params) paginate("/email", params) end |
#received_attachment_url(id, attachment_id) ⇒ Object
114 115 116 |
# File 'lib/unitpost/resources.rb', line 114 def (id, ) @http.request("GET", "/email/received/#{enc(id)}/attachments/#{enc()}") end |
#received_get(id) ⇒ Object
110 111 112 |
# File 'lib/unitpost/resources.rb', line 110 def received_get(id) @http.request("GET", "/email/received/#{enc(id)}") end |
#received_list(limit: nil, after: nil, before: nil) ⇒ Object
106 107 108 |
# File 'lib/unitpost/resources.rb', line 106 def received_list(limit: nil, after: nil, before: nil) @http.request("GET", "/email/received", query: list_params(limit: limit, after: after, before: before)) end |
#send(body, idempotency_key: nil) ⇒ Object
Send or schedule a transactional email. When no idempotency_key is given the SDK generates one so a transient retry can't double-send; pass your own to dedupe across separate send calls.
63 64 65 |
# File 'lib/unitpost/resources.rb', line 63 def send(body, idempotency_key: nil) @http.request("POST", "/email", body: body, idempotency_key: idempotency_key || SecureRandom.uuid) end |
#stats(days: nil) ⇒ Object
Deliverability/engagement aggregates over a rolling window (days: 1–365, defaults to 30 server-side).
102 103 104 |
# File 'lib/unitpost/resources.rb', line 102 def stats(days: nil) @http.request("GET", "/email/stats", query: { days: days }) end |
#update(id, body) ⇒ Object
96 97 98 |
# File 'lib/unitpost/resources.rb', line 96 def update(id, body) @http.request("PATCH", "/email/#{enc(id)}", body: body) end |