sendgrid-ruby 1.1.6 → 6.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.env_sample +1 -3
- data/.github/ISSUE_TEMPLATE/config.yml +10 -0
- data/.github/workflows/test-and-deploy.yml +120 -0
- data/.gitignore +3 -0
- data/.rubocop.yml +5 -27
- data/.rubocop_todo.yml +127 -0
- data/CHANGELOG.md +417 -1
- data/CODE_OF_CONDUCT.md +73 -0
- data/CONTRIBUTING.md +202 -0
- data/Dockerfile +14 -0
- data/FIRST_TIMERS.md +79 -0
- data/Gemfile +4 -4
- data/ISSUE_TEMPLATE.md +30 -0
- data/LICENSE +21 -0
- data/Makefile +14 -0
- data/PULL_REQUEST_TEMPLATE.md +31 -0
- data/README.md +153 -229
- data/Rakefile +9 -3
- data/TROUBLESHOOTING.md +151 -0
- data/UPGRADE.md +5 -0
- data/USAGE.md +5144 -0
- data/config.ru +4 -0
- data/examples/accesssettings/accesssettings.rb +80 -0
- data/examples/alerts/alerts.rb +59 -0
- data/examples/apikeys/apikeys.rb +81 -0
- data/examples/asm/asm.rb +170 -0
- data/examples/browsers/browsers.rb +13 -0
- data/examples/campaigns/campaigns.rb +150 -0
- data/examples/categories/categories.rb +33 -0
- data/examples/clients/clients.rb +24 -0
- data/examples/contactdb/contactdb.rb +392 -0
- data/examples/devices/devices.rb +13 -0
- data/examples/emailactivity/emailactivity.rb +52 -0
- data/examples/geo/geo.rb +13 -0
- data/examples/helpers/eventwebhook/example.rb +16 -0
- data/examples/helpers/mail/example.rb +158 -0
- data/examples/helpers/settings/example.rb +23 -0
- data/examples/helpers/stats/example.rb +42 -0
- data/examples/ips/ips.rb +164 -0
- data/examples/mail/mail.rb +170 -0
- data/examples/mailboxproviders/mailboxproviders.rb +13 -0
- data/examples/mailsettings/mailsettings.rb +216 -0
- data/examples/partnersettings/partnersettings.rb +36 -0
- data/examples/scopes/scopes.rb +59 -0
- data/examples/senderauthentication/senderauthentication.rb +307 -0
- data/examples/senders/senders.rb +95 -0
- data/examples/stats/stats.rb +13 -0
- data/examples/subusers/subusers.rb +166 -0
- data/examples/suppression/suppression.rb +198 -0
- data/examples/templates/templates.rb +127 -0
- data/examples/trackingsettings/trackingsettings.rb +107 -0
- data/examples/user/user.rb +290 -0
- data/gemfiles/Sinatra_1.gemfile +6 -0
- data/gemfiles/Sinatra_2.gemfile +6 -0
- data/lib/rack/sendgrid_webhook_verification.rb +55 -0
- data/lib/sendgrid/base_interface.rb +40 -0
- data/lib/sendgrid/helpers/eventwebhook/eventwebhook.rb +50 -0
- data/lib/sendgrid/helpers/inbound/README.md +98 -0
- data/lib/sendgrid/helpers/inbound/app.rb +32 -0
- data/lib/sendgrid/helpers/inbound/config.yml +26 -0
- data/lib/sendgrid/helpers/inbound/public/index.html +10 -0
- data/lib/sendgrid/helpers/inbound/sample_data/default_data.txt +58 -0
- data/lib/sendgrid/helpers/inbound/sample_data/raw_data.txt +57 -0
- data/lib/sendgrid/helpers/inbound/sample_data/raw_data_with_attachments.txt +298 -0
- data/lib/sendgrid/helpers/inbound/send.rb +26 -0
- data/lib/sendgrid/helpers/ip_management/ip_management.rb +17 -0
- data/lib/sendgrid/helpers/mail/README.md +14 -0
- data/lib/sendgrid/helpers/mail/asm.rb +19 -0
- data/lib/sendgrid/helpers/mail/attachment.rb +55 -0
- data/lib/sendgrid/helpers/mail/bcc_settings.rb +19 -0
- data/lib/sendgrid/helpers/mail/bypass_list_management.rb +31 -0
- data/lib/sendgrid/helpers/mail/category.rb +18 -0
- data/lib/sendgrid/helpers/mail/click_tracking.rb +19 -0
- data/lib/sendgrid/helpers/mail/content.rb +19 -0
- data/lib/sendgrid/helpers/mail/custom_arg.rb +18 -0
- data/lib/sendgrid/helpers/mail/email.rb +32 -0
- data/lib/sendgrid/helpers/mail/footer.rb +21 -0
- data/lib/sendgrid/helpers/mail/ganalytics.rb +28 -0
- data/lib/sendgrid/helpers/mail/header.rb +18 -0
- data/lib/sendgrid/helpers/mail/mail.rb +122 -0
- data/lib/sendgrid/helpers/mail/mail_settings.rb +45 -0
- data/lib/sendgrid/helpers/mail/open_tracking.rb +19 -0
- data/lib/sendgrid/helpers/mail/personalization.rb +93 -0
- data/lib/sendgrid/helpers/mail/section.rb +18 -0
- data/lib/sendgrid/helpers/mail/spam_check.rb +21 -0
- data/lib/sendgrid/helpers/mail/subscription_tracking.rb +23 -0
- data/lib/sendgrid/helpers/mail/substitution.rb +18 -0
- data/lib/sendgrid/helpers/mail/tracking_settings.rb +39 -0
- data/lib/sendgrid/helpers/permissions/scope.rb +28 -0
- data/lib/sendgrid/helpers/permissions/scopes.yml +309 -0
- data/lib/sendgrid/helpers/settings/README.md +14 -0
- data/lib/sendgrid/helpers/settings/mail_settings_dto.rb +13 -0
- data/lib/sendgrid/helpers/settings/partner_settings_dto.rb +13 -0
- data/lib/sendgrid/helpers/settings/settings.rb +28 -0
- data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +22 -0
- data/lib/sendgrid/helpers/settings/user_settings_dto.rb +13 -0
- data/lib/sendgrid/helpers/stats/email_stats.rb +46 -0
- data/lib/sendgrid/helpers/stats/metrics.rb +33 -0
- data/lib/sendgrid/helpers/stats/stats_response.rb +29 -0
- data/lib/sendgrid/sendgrid.rb +21 -0
- data/lib/sendgrid/twilio_email.rb +21 -0
- data/lib/sendgrid/version.rb +1 -1
- data/lib/sendgrid-ruby.rb +32 -7
- data/mail_helper_v3.md +390 -0
- data/sendgrid-ruby.gemspec +16 -20
- data/spec/fixtures/event_webhook.rb +22 -0
- data/spec/rack/sendgrid_webhook_verification_spec.rb +142 -0
- data/spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb +105 -0
- data/spec/sendgrid/helpers/ip_management/ip_management_spec.rb +12 -0
- data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +32 -0
- data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +24 -0
- data/spec/sendgrid/helpers/settings/settings_spec.rb +25 -0
- data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +27 -0
- data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +24 -0
- data/spec/sendgrid/helpers/stats/email_stats_spec.rb +111 -0
- data/spec/sendgrid/helpers/stats/metrics_spec.rb +45 -0
- data/spec/sendgrid/helpers/stats/stats_response_spec.rb +75 -0
- data/spec/sendgrid/sendgrid_spec.rb +11 -0
- data/spec/sendgrid/twilio_email_spec.rb +11 -0
- data/spec/spec_helper.rb +12 -1
- data/static/img/github-fork.png +0 -0
- data/static/img/github-sign-up.png +0 -0
- data/test/sendgrid/helpers/mail/test_attachment.rb +33 -0
- data/test/sendgrid/helpers/mail/test_category.rb +25 -0
- data/test/sendgrid/helpers/mail/test_email.rb +41 -0
- data/test/sendgrid/helpers/mail/test_mail.rb +260 -0
- data/test/sendgrid/helpers/mail/test_personalizations.rb +214 -0
- data/test/sendgrid/permissions/test_scopes.rb +36 -0
- data/test/sendgrid/test_sendgrid-ruby.rb +2729 -0
- data/twilio_sendgrid_logo.png +0 -0
- data/use-cases/README.md +17 -0
- data/use-cases/domain-authentication.md +5 -0
- data/use-cases/email-statistics.md +52 -0
- data/use-cases/legacy-templates.md +98 -0
- data/use-cases/personalizations.md +34 -0
- data/use-cases/sms.md +39 -0
- data/use-cases/transactional-templates.md +111 -0
- data/use-cases/twilio-email.md +13 -0
- data/use-cases/twilio-setup.md +54 -0
- metadata +187 -112
- data/.rspec +0 -2
- data/.travis.yml +0 -20
- data/FETCH_HEAD +0 -0
- data/Guardfile +0 -10
- data/LICENSE.txt +0 -22
- data/example.rb +0 -41
- data/lib/sendgrid/client.rb +0 -62
- data/lib/sendgrid/exceptions.rb +0 -7
- data/lib/sendgrid/mail.rb +0 -182
- data/lib/sendgrid/recipient.rb +0 -29
- data/lib/sendgrid/response.rb +0 -14
- data/lib/sendgrid/template.rb +0 -26
- data/lib/sendgrid/template_mailer.rb +0 -59
- data/spec/lib/sendgrid/client_spec.rb +0 -87
- data/spec/lib/sendgrid/mail_spec.rb +0 -151
- data/spec/lib/sendgrid/recipient_spec.rb +0 -91
- data/spec/lib/sendgrid/template_mailer_spec.rb +0 -86
- data/spec/lib/sendgrid/template_spec.rb +0 -61
- data/spec/lib/sendgrid_spec.rb +0 -7
@@ -1,86 +0,0 @@
|
|
1
|
-
require_relative '../../../lib/sendgrid/template_mailer'
|
2
|
-
|
3
|
-
module SendGrid
|
4
|
-
describe TemplateMailer do
|
5
|
-
let(:client) { anything }
|
6
|
-
let(:template) { Template.new(anything) }
|
7
|
-
let(:recipients) { [Recipient.new(anything)] }
|
8
|
-
|
9
|
-
describe '#initialize' do
|
10
|
-
let(:client) { anything }
|
11
|
-
let(:template) { Template.new(anything) }
|
12
|
-
let(:recipients) { [anything] }
|
13
|
-
|
14
|
-
subject { described_class.new(client, template, recipients) }
|
15
|
-
|
16
|
-
it 'sets the instance variables' do
|
17
|
-
expect(subject.instance_variable_get(:@client)).to_not be_nil
|
18
|
-
expect(subject.instance_variable_get(:@template)).to_not be_nil
|
19
|
-
expect(subject.instance_variable_get(:@recipients)).to_not be_nil
|
20
|
-
end
|
21
|
-
|
22
|
-
context 'nil variables' do
|
23
|
-
context 'template is nil' do
|
24
|
-
let(:template) { nil }
|
25
|
-
|
26
|
-
it 'raises error' do
|
27
|
-
expect do
|
28
|
-
subject
|
29
|
-
end.to raise_error(InvalidTemplate, 'Template must be present')
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'client is nil' do
|
34
|
-
let(:client) { nil }
|
35
|
-
|
36
|
-
it 'raises error' do
|
37
|
-
expect do
|
38
|
-
subject
|
39
|
-
end.to raise_error(InvalidClient, 'Client must be present')
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'recipients' do
|
45
|
-
let(:first_recipient) { Recipient.new('someone@anything.com') }
|
46
|
-
let(:second_recipient) { Recipient.new('test@test.com') }
|
47
|
-
let(:recipients) { [first_recipient, second_recipient] }
|
48
|
-
|
49
|
-
it 'adds them to the template' do
|
50
|
-
expect(template).to receive(:add_recipient).with(first_recipient)
|
51
|
-
expect(template).to receive(:add_recipient).with(second_recipient)
|
52
|
-
|
53
|
-
subject
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '#mail' do
|
59
|
-
subject { described_class.new(client, template, recipients) }
|
60
|
-
|
61
|
-
let(:mail_params) { {} }
|
62
|
-
let(:mail_to_h) { '' }
|
63
|
-
|
64
|
-
before do
|
65
|
-
allow(subject).to receive(:mail_params) { mail_params }
|
66
|
-
allow_any_instance_of(Mail).to receive(:to_h) { mail_to_h }
|
67
|
-
allow(client).to receive(:send)
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'creates a new mail object' do
|
71
|
-
expect(Mail).to receive(:new).with(mail_params).and_call_original
|
72
|
-
subject.mail
|
73
|
-
end
|
74
|
-
|
75
|
-
it 'adds the template to the mail object' do
|
76
|
-
expect_any_instance_of(Mail).to receive(:template=).with(template)
|
77
|
-
subject.mail
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'calls send on the client with the mail object' do
|
81
|
-
expect(client).to receive(:send).with(mail_to_h)
|
82
|
-
subject.mail
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
require_relative '../../../lib/sendgrid/template'
|
2
|
-
|
3
|
-
module SendGrid
|
4
|
-
describe Template do
|
5
|
-
let(:id) { anything }
|
6
|
-
subject { described_class.new(id) }
|
7
|
-
|
8
|
-
describe '#initialize' do
|
9
|
-
it 'sets the id instance var' do
|
10
|
-
expect(subject.instance_variable_get(:@id)).to_not be_nil
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe '#add_to_smtpapi' do
|
15
|
-
let(:id) { rand(8999) }
|
16
|
-
let(:smtpapi) { Smtpapi::Header.new }
|
17
|
-
|
18
|
-
it 'adds enabled and the templates id' do
|
19
|
-
expect(smtpapi).to receive(:add_filter).with(:templates, :enable, 1)
|
20
|
-
expect(smtpapi).to receive(:add_filter).with(:templates, :template_id, id)
|
21
|
-
subject.add_to_smtpapi(smtpapi)
|
22
|
-
end
|
23
|
-
|
24
|
-
context 'smtpapi is nil' do
|
25
|
-
it 'does not error' do
|
26
|
-
expect do
|
27
|
-
subject.add_to_smtpapi(nil)
|
28
|
-
end.to_not raise_error
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'with recipients' do
|
33
|
-
let(:substitution_key) { :foo }
|
34
|
-
let(:substitution_value) { :bar }
|
35
|
-
let(:recipients) do
|
36
|
-
[].tap do |recipients|
|
37
|
-
3.times.each do
|
38
|
-
r = Recipient.new("test+#{ rand(100) }@example.com")
|
39
|
-
r.add_substitution(substitution_key, substitution_value)
|
40
|
-
recipients << r
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
before do
|
46
|
-
recipients.each do |r|
|
47
|
-
subject.add_recipient(r)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'calls the recipients call to add to smtpapi' do
|
52
|
-
recipients.each do |recipient|
|
53
|
-
expect(recipient).to receive(:add_to_smtpapi).with(smtpapi)
|
54
|
-
end
|
55
|
-
|
56
|
-
subject.add_to_smtpapi(smtpapi)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|