sendgrid-ruby 6.5.2 → 6.6.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/CHANGELOG.md +6 -0
- data/examples/helpers/mail/example.rb +1 -1
- data/lib/sendgrid/helpers/mail/personalization.rb +6 -2
- data/lib/sendgrid/version.rb +1 -1
- data/test/sendgrid/helpers/mail/test_personalizations.rb +13 -0
- data/test/sendgrid/test_sendgrid-ruby.rb +1 -1
- data/use-cases/README.md +1 -0
- data/use-cases/personalizations.md +34 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 24757e772b52f0b9e130a824d65bea991c3fe5966f705cd3c2b67fdb8b1ade0e
|
4
|
+
data.tar.gz: 972ea7b52d490fce2ddb97315356965fab0001e1511087834979620cbeb118a9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af9a46c70ff25fadfce7458b64a75e0255063d7f082ff8b9d9f4bbff9f0aa3136969864b717f6f01666ee1c04c354a3bb03afc9dc3620de26ffb4b63e0011002
|
7
|
+
data.tar.gz: 7992f9c04da91c16f76eee4cfd6860df83584046c00cff6a3b3f1b5ac0318e2bde8c8f2ee1329016bc28d0fd7c62a0c92d56bedf71805bfb86a5a6436f85035a
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
# Change Log
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
|
4
|
+
[2021-11-03] Version 6.6.0
|
5
|
+
--------------------------
|
6
|
+
**Library - Feature**
|
7
|
+
- [PR #473](https://github.com/sendgrid/sendgrid-ruby/pull/473): update tests, use-cases, examples and implementation for From personalization. Thanks to [@beebzz](https://github.com/beebzz)!
|
8
|
+
|
9
|
+
|
4
10
|
[2021-10-18] Version 6.5.2
|
5
11
|
--------------------------
|
6
12
|
**Library - Docs**
|
@@ -32,7 +32,7 @@ def kitchen_sink
|
|
32
32
|
personalization.add_bcc(Email.new(email: 'test6@example.com', name: 'Example User'))
|
33
33
|
# Note, the domain of the from email property specified in any personalization must
|
34
34
|
# match the domain of the from email property specified at root level
|
35
|
-
personalization.
|
35
|
+
personalization.add_from(Email.new(email: 'alias@example.com', name: "My alias"))
|
36
36
|
personalization.subject = 'Hello World from the Personalized Twilio SendGrid Ruby Library'
|
37
37
|
personalization.add_header(Header.new(key: 'X-Test', value: 'True'))
|
38
38
|
personalization.add_header(Header.new(key: 'X-Mock', value: 'False'))
|
@@ -2,10 +2,10 @@ require 'json'
|
|
2
2
|
|
3
3
|
module SendGrid
|
4
4
|
class Personalization
|
5
|
-
attr_reader :tos, :ccs, :bccs, :headers, :substitutions, :custom_args,
|
5
|
+
attr_reader :tos, :from, :ccs, :bccs, :headers, :substitutions, :custom_args,
|
6
6
|
:dynamic_template_data
|
7
7
|
|
8
|
-
attr_accessor :send_at, :subject
|
8
|
+
attr_accessor :send_at, :subject
|
9
9
|
|
10
10
|
def initialize
|
11
11
|
@tos = []
|
@@ -26,6 +26,10 @@ module SendGrid
|
|
26
26
|
@tos << to.to_json
|
27
27
|
end
|
28
28
|
|
29
|
+
def add_from(from)
|
30
|
+
@from = from.to_json
|
31
|
+
end
|
32
|
+
|
29
33
|
def add_cc(cc)
|
30
34
|
raise DuplicatePersonalizationError if duplicate?(cc)
|
31
35
|
|
data/lib/sendgrid/version.rb
CHANGED
@@ -45,6 +45,19 @@ class TestPersonalization < Minitest::Test
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def test_add_from
|
49
|
+
@personalization = Personalization.new
|
50
|
+
@personalization.add_from(Email.new(email: 'from1@example.com', name: 'Example Sender'))
|
51
|
+
expected_json = {
|
52
|
+
'from' => {
|
53
|
+
'email' => 'from1@example.com',
|
54
|
+
'name' => 'Example Sender'
|
55
|
+
}
|
56
|
+
}
|
57
|
+
|
58
|
+
assert_equal @personalization.to_json, expected_json
|
59
|
+
end
|
60
|
+
|
48
61
|
def test_add_cc
|
49
62
|
@personalization = Personalization.new
|
50
63
|
@personalization.add_cc(Email.new(email: 'test1@example.com', name: 'Example User'))
|
@@ -33,7 +33,7 @@ class TestAPI < MiniTest::Test
|
|
33
33
|
assert_equal(test_headers, sg.request_headers)
|
34
34
|
assert_equal('v3', sg.version)
|
35
35
|
assert_equal(subuser, sg.impersonate_subuser)
|
36
|
-
assert_equal('6.
|
36
|
+
assert_equal('6.6.0', SendGrid::VERSION)
|
37
37
|
assert_instance_of(SendGrid::Client, sg.client)
|
38
38
|
assert_equal({}, sg.http_options)
|
39
39
|
end
|
data/use-cases/README.md
CHANGED
@@ -5,6 +5,7 @@ Please [open an issue](https://github.com/sendgrid/sendgrid-ruby/issues) or [mak
|
|
5
5
|
# Email Use Cases
|
6
6
|
* [Transactional Templates](transactional-templates.md)
|
7
7
|
* [Legacy Templates](legacy-templates.md)
|
8
|
+
* [Personalizations](personalizations.md)
|
8
9
|
|
9
10
|
# Twilio Use Cases
|
10
11
|
* [Twilio Setup](twilio-setup.md)
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Personalizations
|
2
|
+
|
3
|
+
This example demonstrates how to send multiple emails with personalizations. For further documentation, refer to [the SendGrid docs](https://docs.sendgrid.com/for-developers/sending-email/personalizations).
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
require 'sendgrid-ruby'
|
7
|
+
include SendGrid
|
8
|
+
|
9
|
+
# Note that the domain for all From addresses must match
|
10
|
+
mail = Mail.new
|
11
|
+
mail.from = Email.new(email: 'test@example.com')
|
12
|
+
mail.add_content(Content.new(type: 'text/plain', value: 'Some test text'))
|
13
|
+
mail.subject = 'Personalized Test Email'
|
14
|
+
|
15
|
+
personalization = Personalization.new
|
16
|
+
personalization.add_to(Email.new(email: 'test1@example.com'))
|
17
|
+
mail.add_personalization(personalization)
|
18
|
+
|
19
|
+
personalization2 = Personalization.new
|
20
|
+
personalization2.add_to(Email.new(email: 'test2@example.com'))
|
21
|
+
personalization2.add_from(Email.new(email: 'test3@example.com'))
|
22
|
+
mail.add_personalization(personalization2)
|
23
|
+
|
24
|
+
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])
|
25
|
+
begin
|
26
|
+
response = sg.client.mail._("send").post(request_body: mail.to_json)
|
27
|
+
rescue Exception => e
|
28
|
+
puts e.message
|
29
|
+
end
|
30
|
+
|
31
|
+
puts response.status_code
|
32
|
+
puts response.body
|
33
|
+
puts response.headers
|
34
|
+
```
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendgrid-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elmer Thomas
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2021-
|
13
|
+
date: 2021-11-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: ruby_http_client
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- use-cases/domain-authentication.md
|
301
301
|
- use-cases/email-statistics.md
|
302
302
|
- use-cases/legacy-templates.md
|
303
|
+
- use-cases/personalizations.md
|
303
304
|
- use-cases/sms.md
|
304
305
|
- use-cases/transactional-templates.md
|
305
306
|
- use-cases/twilio-email.md
|