sendgrid-actionmailer 2.0.1 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/sendgrid_actionmailer/version.rb +1 -1
- data/lib/sendgrid_actionmailer.rb +5 -0
- data/sendgrid-actionmailer.gemspec +1 -1
- data/spec/lib/sendgrid_actionmailer_spec.rb +11 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d255eeab037f499229ba0e4d50e5882db6aa90a
|
4
|
+
data.tar.gz: d380795abfc9a200f86ac81d860f2cafd6c7c16f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc7162c1e60fa03360e80a18e4d84a676b38b1593eef4b3b2e3671fda72b13cd67ea9ae227758bfdd69b81f67fbe1562587141ad7bf5e27b810a7cfcc65ca5e2
|
7
|
+
data.tar.gz: 28913dbd6e4f0d375e34d3341c2e44b51483c5025bd427e722278acc36185e78def4bcc8057bfe96d7de80b9f7872fa292dde1576c575c969d26565c1db2e92d
|
data/README.md
CHANGED
@@ -6,7 +6,7 @@ An ActionMailer adapter to send email using SendGrid's HTTPS Web API (instead of
|
|
6
6
|
|
7
7
|
Add this line to your application's Gemfile:
|
8
8
|
|
9
|
-
gem 'sendgrid-actionmailer'
|
9
|
+
gem 'sendgrid-actionmailer'
|
10
10
|
|
11
11
|
## Usage
|
12
12
|
|
@@ -215,6 +215,12 @@ The name of the campaign.
|
|
215
215
|
|
216
216
|
```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', tracking_settings:{ enable: true, utm_source: 'some source', utm_medium: 'some medium', utm_term: 'some term', utm_content: 'some content', utm_campaign: 'some campaign' }})```
|
217
217
|
|
218
|
+
### dynamic_template_data (json)
|
219
|
+
|
220
|
+
Data to provide for feeding the new dynamic templates in Sendgrid with valueable data. This also disables the following Unsubscribe links because of deprecation of substitutions in the new template implementaiton.
|
221
|
+
|
222
|
+
```mail(to: 'example@email.com', subject: 'email subject', body: 'email body', dynamic_template_data:{ variable_1: 'foo', variable_2: 'bar'})```
|
223
|
+
|
218
224
|
### Unsubscribe Links
|
219
225
|
|
220
226
|
Sendgrid unfortunately uses <% %> for their default substitution syntax, which makes it incompatible with Rails templates. Their proposed solution is to use Personalization Substitutions with the v3 Mail Send Endpoint. This gem makes that modification to make the following Rails friendly unsubscribe urls.
|
@@ -34,6 +34,7 @@ module SendGridActionMailer
|
|
34
34
|
add_mail_settings(sendgrid_mail, mail)
|
35
35
|
add_tracking_settings(sendgrid_mail, mail)
|
36
36
|
|
37
|
+
|
37
38
|
response = perform_send_request(sendgrid_mail)
|
38
39
|
|
39
40
|
settings[:return_response] ? response : self
|
@@ -79,6 +80,10 @@ module SendGridActionMailer
|
|
79
80
|
to_emails(mail.to).each { |to| p.add_to(to) }
|
80
81
|
to_emails(mail.cc).each { |cc| p.add_cc(cc) }
|
81
82
|
to_emails(mail.bcc).each { |bcc| p.add_bcc(bcc) }
|
83
|
+
|
84
|
+
if mail['dynamic_template_data']
|
85
|
+
p.add_dynamic_template_data(json_parse(mail['dynamic_template_data'].value))
|
86
|
+
end
|
82
87
|
p.add_substitution(Substitution.new(key: "%asm_group_unsubscribe_raw_url%", value: "<%asm_group_unsubscribe_raw_url%>"))
|
83
88
|
p.add_substitution(Substitution.new(key: "%asm_global_unsubscribe_raw_url%", value: "<%asm_global_unsubscribe_raw_url%>"))
|
84
89
|
p.add_substitution(Substitution.new(key: "%asm_preferences_raw_url%", value: "<%asm_preferences_raw_url%>"))
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_dependency 'mail', '~> 2.5'
|
23
|
-
spec.add_dependency 'sendgrid-ruby', '~> 5.
|
23
|
+
spec.add_dependency 'sendgrid-ruby', '~> 5.3.0'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'appraisal', '~> 2.1.0'
|
26
26
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
@@ -384,6 +384,15 @@ module SendGridActionMailer
|
|
384
384
|
expect(client.sent_mail['tracking_settings']).to eq(tracking)
|
385
385
|
end
|
386
386
|
end
|
387
|
+
|
388
|
+
context 'dynamic template data' do
|
389
|
+
it 'sets dynamic_template_data' do
|
390
|
+
template_data = { variable_1: '1', variable_2: '2' }
|
391
|
+
mail['dynamic_template_data'] = template_data
|
392
|
+
mailer.deliver!(mail)
|
393
|
+
expect(client.sent_mail['personalizations'].first['dynamic_template_data']).to eq(template_data)
|
394
|
+
end
|
395
|
+
end
|
387
396
|
end
|
388
397
|
|
389
398
|
context 'multipart/alternative' do
|
@@ -443,7 +452,7 @@ module SendGridActionMailer
|
|
443
452
|
end
|
444
453
|
|
445
454
|
it 'adds the attachment' do
|
446
|
-
expect(mail.attachments.first.read).to
|
455
|
+
expect(mail.attachments.first.read).to include("it 'adds the attachment' do")
|
447
456
|
mailer.deliver!(mail)
|
448
457
|
attachment = client.sent_mail['attachments'].first
|
449
458
|
expect(attachment['filename']).to eq('specs.rb')
|
@@ -480,7 +489,7 @@ module SendGridActionMailer
|
|
480
489
|
end
|
481
490
|
|
482
491
|
it 'adds the inline attachment' do
|
483
|
-
expect(mail.attachments.first.read).to
|
492
|
+
expect(mail.attachments.first.read).to include("it 'adds the inline attachment' do")
|
484
493
|
mailer.deliver!(mail)
|
485
494
|
content = client.sent_mail['attachments'].first
|
486
495
|
expect(content['filename']).to eq('specs.rb')
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sendgrid-actionmailer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eddie Zaneski
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-11-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: mail
|
@@ -32,14 +32,14 @@ dependencies:
|
|
32
32
|
requirements:
|
33
33
|
- - "~>"
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version:
|
35
|
+
version: 5.3.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 5.3.0
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: appraisal
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|