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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b62be0aef438ad137fa4db07aae85263042d924b2db6c50d70347301f62f2737
4
- data.tar.gz: 231d12564797d902d3398972da4809b2e3c8b1488f9a6e7750efa2ad15bca89a
3
+ metadata.gz: ff3f9d91f8190516bc3d949c57d83954a1f456fea118e62b00e1d5bfc1f09881
4
+ data.tar.gz: a65c9b4499fc7f38c629deaaf7064ffea41f792c29f749b56692b9a6aedac833
5
5
  SHA512:
6
- metadata.gz: 4133719861683e4084116674223885e0e1a3cf1eede3352725f6e492e5ec9c29665806a82fa552a0096cb775e6d4018961551b132061125f947db14f7adb381f
7
- data.tar.gz: dac5abbdcf145b0f4d25258d69c478bf083adfee8e19f2f9bf8549bd6630420599cfb29cc1b5ab8b40136461c9b4ddb30e83f212f4b8a29640bd1b2a5298c97b
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:, html: nil, text: nil, tags: nil, tracking: nil, reply_to: nil,
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
- body["html"] = html unless html.nil?
127
- body["text"] = text unless text.nil?
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"], status: h["status"], updated_at: Models.time(h["updated_at"]))
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
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Duva
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
6
6
 
7
7
  require_relative "duva/errors"
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.1.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-09-27 00:00:00.000000000 Z
11
+ date: 2026-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: base64