Class: Unitpost::Resources::Emails
- Inherits:
-
Base
- Object
- Base
- Unitpost::Resources::Emails
show all
- Defined in:
- lib/unitpost/resources.rb
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
-
#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
Methods inherited from Base
#initialize
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.
62
63
64
|
# File 'lib/unitpost/resources.rb', line 62
def batch(body, idempotency_key: nil)
@http.request("POST", "/emails/batch", body: body, idempotency_key: idempotency_key || SecureRandom.uuid)
end
|
#cancel_batch(id) ⇒ Object
70
71
72
|
# File 'lib/unitpost/resources.rb', line 70
def cancel_batch(id)
@http.request("POST", "/emails/batches/#{enc(id)}/cancel")
end
|
#get(id) ⇒ Object
82
83
84
|
# File 'lib/unitpost/resources.rb', line 82
def get(id)
@http.request("GET", "/emails/#{enc(id)}")
end
|
#get_batch(id) ⇒ Object
66
67
68
|
# File 'lib/unitpost/resources.rb', line 66
def get_batch(id)
@http.request("GET", "/emails/batches/#{enc(id)}")
end
|
#list(limit: nil, after: nil, before: nil, **filters) ⇒ Object
74
75
76
|
# File 'lib/unitpost/resources.rb', line 74
def list(limit: nil, after: nil, before: nil, **filters)
@http.request("GET", "/emails", query: list_params(limit: limit, after: after, before: before, **filters))
end
|
#list_all(**params) ⇒ Object
78
79
80
|
# File 'lib/unitpost/resources.rb', line 78
def list_all(**params)
paginate("/emails", params)
end
|
#received_attachment_url(id, attachment_id) ⇒ Object
104
105
106
|
# File 'lib/unitpost/resources.rb', line 104
def received_attachment_url(id, attachment_id)
@http.request("GET", "/emails/received/#{enc(id)}/attachments/#{enc(attachment_id)}")
end
|
#received_get(id) ⇒ Object
100
101
102
|
# File 'lib/unitpost/resources.rb', line 100
def received_get(id)
@http.request("GET", "/emails/received/#{enc(id)}")
end
|
#received_list(limit: nil, after: nil, before: nil) ⇒ Object
96
97
98
|
# File 'lib/unitpost/resources.rb', line 96
def received_list(limit: nil, after: nil, before: nil)
@http.request("GET", "/emails/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.
53
54
55
|
# File 'lib/unitpost/resources.rb', line 53
def send(body, idempotency_key: nil)
@http.request("POST", "/emails", 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).
92
93
94
|
# File 'lib/unitpost/resources.rb', line 92
def stats(days: nil)
@http.request("GET", "/emails/stats", query: { days: days })
end
|
#update(id, body) ⇒ Object
86
87
88
|
# File 'lib/unitpost/resources.rb', line 86
def update(id, body)
@http.request("PATCH", "/emails/#{enc(id)}", body: body)
end
|