duva-mail 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +17 -0
- data/lib/duva/client.rb +8 -8
- data/lib/duva/models.rb +3 -2
- data/lib/duva.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ff3f9d91f8190516bc3d949c57d83954a1f456fea118e62b00e1d5bfc1f09881
|
|
4
|
+
data.tar.gz: a65c9b4499fc7f38c629deaaf7064ffea41f792c29f749b56692b9a6aedac833
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '05646580b2e1f7560874564d3a9fb931d16d096f0c757722df907accd73817dbbe574f4803e272df28de536326f8e1f15c808e3d6f052446e8753aa9c9ad9852'
|
|
7
|
+
data.tar.gz: 2ef42a705a35588f967d68d899650fef804e69c3c32712d4ccdd45ff7bd71390a418a77f2d85b44f168351b27bae537f0ae3e5b81ad6f1430ec000d295f71bd5
|
data/README.md
CHANGED
|
@@ -30,6 +30,23 @@ puts message.id, message.status # "queued": always asynchronous
|
|
|
30
30
|
Named `deliver`, not `send`: `Object#send` is a core Ruby method and shadowing it would be
|
|
31
31
|
confusing in a `rescue`/`method_missing`-heavy codebase.
|
|
32
32
|
|
|
33
|
+
### To, Cc and Bcc
|
|
34
|
+
|
|
35
|
+
`to:`, `cc:` and `bcc:` take addresses or `Name <address>`. Every copy shows all the `to` and all the
|
|
36
|
+
`cc`; a `bcc` address appears only on its own copy. The three lists together count against your
|
|
37
|
+
plan's recipient maximum.
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
duva.messages.deliver(
|
|
41
|
+
from: "Example <notifications@example.com>",
|
|
42
|
+
to: ["Jean Tremblay <jean@example.org>"],
|
|
43
|
+
cc: ["accounting@example.org"],
|
|
44
|
+
bcc: ["archive@example.com"],
|
|
45
|
+
subject: "Your order",
|
|
46
|
+
text: "Thank you for your order."
|
|
47
|
+
)
|
|
48
|
+
```
|
|
49
|
+
|
|
33
50
|
## Reading events and pagination
|
|
34
51
|
|
|
35
52
|
```ruby
|
data/lib/duva/client.rb
CHANGED
|
@@ -99,6 +99,10 @@ module Duva
|
|
|
99
99
|
# then never create a duplicate message, but two separate calls each get their own random
|
|
100
100
|
# key, so they are NOT deduplicated against each other; pass your own stable key for that
|
|
101
101
|
# (e.g. an order id).
|
|
102
|
+
#
|
|
103
|
+
# `to:`, `cc:` and `bcc:` take addresses or `Name <address>`; together they count against the plan's
|
|
104
|
+
# recipient maximum. Every copy shows all the `to` and all the `cc`; a `bcc` address appears only
|
|
105
|
+
# on its own copy.
|
|
102
106
|
def deliver(from:, to:, subject:, idempotency_key: nil, **fields)
|
|
103
107
|
body = message_body(from: from, to: to, subject: subject, **fields)
|
|
104
108
|
key = idempotency_key || SecureRandom.uuid
|
|
@@ -119,20 +123,16 @@ module Duva
|
|
|
119
123
|
|
|
120
124
|
private
|
|
121
125
|
|
|
122
|
-
def message_body(from:, to:, subject:,
|
|
123
|
-
headers: nil, metadata: nil, attachments: nil)
|
|
126
|
+
def message_body(from:, to:, subject:, cc: nil, bcc: nil, html: nil, text: nil, tags: nil, tracking: nil,
|
|
127
|
+
reply_to: nil, headers: nil, metadata: nil, attachments: nil)
|
|
124
128
|
Attachments.assert_limits(attachments) if attachments && !attachments.empty?
|
|
125
129
|
body = { "from" => from, "to" => to, "subject" => subject }
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
body["tags"] = tags unless tags.nil?
|
|
130
|
+
{ "cc" => cc, "bcc" => bcc, "html" => html, "text" => text, "tags" => tags, "reply_to" => reply_to,
|
|
131
|
+
"headers" => headers, "metadata" => metadata }.each { |key, value| body[key] = value unless value.nil? }
|
|
129
132
|
unless tracking.nil?
|
|
130
133
|
body["tracking"] =
|
|
131
134
|
{ "opens" => tracking.fetch(:opens, false), "clicks" => tracking.fetch(:clicks, false) }
|
|
132
135
|
end
|
|
133
|
-
body["reply_to"] = reply_to unless reply_to.nil?
|
|
134
|
-
body["headers"] = headers unless headers.nil?
|
|
135
|
-
body["metadata"] = metadata unless metadata.nil?
|
|
136
136
|
body["attachments"] = attachments.map(&:to_h) unless attachments.nil?
|
|
137
137
|
body
|
|
138
138
|
end
|
data/lib/duva/models.rb
CHANGED
|
@@ -24,9 +24,10 @@ module Duva
|
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
|
|
27
|
-
Recipient = Data.define(:email, :status, :updated_at) do
|
|
27
|
+
Recipient = Data.define(:email, :type, :name, :status, :updated_at) do
|
|
28
28
|
def self.from_json_hash(h)
|
|
29
|
-
new(email: h["email"],
|
|
29
|
+
new(email: h["email"], type: h["type"], name: h["name"], status: h["status"],
|
|
30
|
+
updated_at: Models.time(h["updated_at"]))
|
|
30
31
|
end
|
|
31
32
|
end
|
|
32
33
|
|
data/lib/duva.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: duva-mail
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- 9573-4562 Québec inc.
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-
|
|
11
|
+
date: 2026-10-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: base64
|