sendgrid-ruby 6.3.4 → 6.3.9
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/.rubocop.yml +7 -5
- data/.rubocop_todo.yml +109 -0
- data/.travis.yml +1 -2
- data/CHANGELOG.md +43 -1
- data/CONTRIBUTING.md +2 -5
- data/FIRST_TIMERS.md +7 -7
- data/{LICENSE.md → LICENSE} +1 -1
- data/Makefile +1 -0
- data/PULL_REQUEST_TEMPLATE.md +4 -4
- data/README.md +3 -9
- data/Rakefile +2 -3
- data/USAGE.md +111 -3
- data/examples/accesssettings/accesssettings.rb +9 -12
- data/examples/alerts/alerts.rb +8 -11
- data/examples/apikeys/apikeys.rb +12 -15
- data/examples/asm/asm.rb +27 -30
- data/examples/browsers/browsers.rb +0 -3
- data/examples/campaigns/campaigns.rb +29 -32
- data/examples/categories/categories.rb +0 -3
- data/examples/clients/clients.rb +1 -4
- data/examples/contactdb/contactdb.rb +63 -66
- data/examples/devices/devices.rb +0 -3
- data/examples/emailactivity/emailactivity.rb +52 -0
- data/examples/geo/geo.rb +0 -3
- data/examples/helpers/eventwebhook/example.rb +4 -4
- data/examples/helpers/mail/example.rb +9 -10
- data/examples/helpers/settings/example.rb +1 -1
- data/examples/helpers/stats/example.rb +4 -4
- data/examples/ips/ips.rb +19 -22
- data/examples/mail/mail.rb +72 -75
- data/examples/mailboxproviders/mailboxproviders.rb +0 -3
- data/examples/mailsettings/mailsettings.rb +21 -24
- data/examples/partnersettings/partnersettings.rb +3 -6
- data/examples/scopes/scopes.rb +8 -10
- data/examples/senderauthentication/senderauthentication.rb +41 -44
- data/examples/senders/senders.rb +28 -31
- data/examples/stats/stats.rb +0 -3
- data/examples/subusers/subusers.rb +17 -20
- data/examples/suppression/suppression.rb +15 -18
- data/examples/templates/templates.rb +29 -31
- data/examples/trackingsettings/trackingsettings.rb +14 -17
- data/examples/user/user.rb +41 -44
- data/lib/rack/sendgrid_webhook_verification.rb +5 -2
- data/lib/sendgrid/base_interface.rb +2 -1
- data/lib/sendgrid/helpers/eventwebhook/eventwebhook.rb +4 -6
- data/lib/sendgrid/helpers/inbound/app.rb +2 -2
- data/lib/sendgrid/helpers/inbound/send.rb +3 -3
- data/lib/sendgrid/helpers/ip_management/ip_management.rb +1 -1
- data/lib/sendgrid/helpers/mail/asm.rb +6 -18
- data/lib/sendgrid/helpers/mail/attachment.rb +12 -42
- data/lib/sendgrid/helpers/mail/bcc_settings.rb +6 -18
- data/lib/sendgrid/helpers/mail/bypass_list_management.rb +8 -18
- data/lib/sendgrid/helpers/mail/category.rb +2 -2
- data/lib/sendgrid/helpers/mail/click_tracking.rb +6 -18
- data/lib/sendgrid/helpers/mail/content.rb +4 -3
- data/lib/sendgrid/helpers/mail/custom_arg.rb +6 -10
- data/lib/sendgrid/helpers/mail/email.rb +10 -5
- data/lib/sendgrid/helpers/mail/footer.rb +7 -27
- data/lib/sendgrid/helpers/mail/ganalytics.rb +10 -54
- data/lib/sendgrid/helpers/mail/header.rb +6 -10
- data/lib/sendgrid/helpers/mail/mail.rb +32 -48
- data/lib/sendgrid/helpers/mail/mail_settings.rb +9 -25
- data/lib/sendgrid/helpers/mail/open_tracking.rb +6 -18
- data/lib/sendgrid/helpers/mail/personalization.rb +34 -27
- data/lib/sendgrid/helpers/mail/section.rb +6 -10
- data/lib/sendgrid/helpers/mail/spam_check.rb +7 -27
- data/lib/sendgrid/helpers/mail/subscription_tracking.rb +8 -36
- data/lib/sendgrid/helpers/mail/substitution.rb +6 -10
- data/lib/sendgrid/helpers/mail/tracking_settings.rb +8 -20
- data/lib/sendgrid/helpers/permissions/scope.rb +2 -2
- data/lib/sendgrid/helpers/settings/settings.rb +1 -1
- data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +3 -5
- data/lib/sendgrid/helpers/stats/metrics.rb +5 -5
- data/lib/sendgrid/sendgrid.rb +1 -1
- data/lib/sendgrid/twilio_email.rb +1 -1
- data/lib/sendgrid/version.rb +1 -1
- data/mail_helper_v3.md +3 -3
- data/sendgrid-ruby.gemspec +7 -8
- data/spec/fixtures/event_webhook.rb +17 -11
- data/spec/rack/sendgrid_webhook_verification_spec.rb +30 -4
- data/spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb +38 -36
- data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +1 -1
- data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +1 -1
- data/spec/sendgrid/helpers/settings/settings_spec.rb +2 -2
- data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +1 -1
- data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +1 -1
- data/spec/sendgrid/helpers/stats/email_stats_spec.rb +22 -23
- data/spec/sendgrid/helpers/stats/metrics_spec.rb +19 -20
- data/spec/sendgrid/helpers/stats/stats_response_spec.rb +22 -23
- data/spec/spec_helper.rb +1 -1
- data/test/sendgrid/helpers/mail/test_attachment.rb +4 -6
- data/test/sendgrid/helpers/mail/test_category.rb +0 -2
- data/test/sendgrid/helpers/mail/test_email.rb +17 -10
- data/test/sendgrid/helpers/mail/test_mail.rb +101 -102
- data/test/sendgrid/helpers/mail/test_personalizations.rb +133 -93
- data/test/sendgrid/permissions/test_scopes.rb +1 -3
- data/test/sendgrid/test_sendgrid-ruby.rb +1947 -1948
- data/use-cases/legacy-templates.md +1 -1
- data/use-cases/transactional-templates.md +1 -1
- metadata +39 -37
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
module SendGrid
|
|
2
2
|
class Metrics
|
|
3
3
|
attr_reader :blocks, :bounce_drops,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
:bounces, :clicks, :deferred, :delivered,
|
|
5
|
+
:invalid_emails, :opens, :processed, :requests,
|
|
6
|
+
:spam_report_drops, :spam_reports, :unique_clicks,
|
|
7
|
+
:unique_opens, :unsubscribe_drops, :unsubscribes
|
|
8
8
|
|
|
9
|
-
def initialize(args={})
|
|
9
|
+
def initialize(args = {})
|
|
10
10
|
@date = args['date']
|
|
11
11
|
@blocks = args['blocks']
|
|
12
12
|
@bounce_drops = args['bounce_drops']
|
data/lib/sendgrid/sendgrid.rb
CHANGED
|
@@ -12,7 +12,7 @@ module SendGrid
|
|
|
12
12
|
#
|
|
13
13
|
def initialize(api_key:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil)
|
|
14
14
|
auth = "Bearer #{api_key}"
|
|
15
|
-
host
|
|
15
|
+
host ||= 'https://api.sendgrid.com'
|
|
16
16
|
|
|
17
17
|
super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser)
|
|
18
18
|
end
|
|
@@ -13,7 +13,7 @@ module TwilioEmail
|
|
|
13
13
|
#
|
|
14
14
|
def initialize(username:, password:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil)
|
|
15
15
|
auth = "Basic #{Base64.strict_encode64("#{username}:#{password}")}"
|
|
16
|
-
host
|
|
16
|
+
host ||= 'https://email.twilio.com'
|
|
17
17
|
|
|
18
18
|
super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser)
|
|
19
19
|
end
|
data/lib/sendgrid/version.rb
CHANGED
data/mail_helper_v3.md
CHANGED
|
@@ -263,7 +263,7 @@ attachments = [
|
|
|
263
263
|
'base64 encoded content',
|
|
264
264
|
'image/png',
|
|
265
265
|
'inline',
|
|
266
|
-
'Banner 2'),
|
|
266
|
+
'Banner 2'),
|
|
267
267
|
]
|
|
268
268
|
msg.add_attachments(attachments)
|
|
269
269
|
|
|
@@ -279,7 +279,7 @@ msg.set_global_headers(global_headers)
|
|
|
279
279
|
msg.add_section('%section1%', 'Substitution for Section 1 Tag')
|
|
280
280
|
sections = [
|
|
281
281
|
'%section2%' => 'Substitution for Section 2 Tag',
|
|
282
|
-
'%section3%' => 'Substitution for Section 3 Tag'
|
|
282
|
+
'%section3%' => 'Substitution for Section 3 Tag'
|
|
283
283
|
]
|
|
284
284
|
msg.add_sections(sections)
|
|
285
285
|
|
|
@@ -328,7 +328,7 @@ puts response.headers
|
|
|
328
328
|
|
|
329
329
|
The following code assumes you are storing the API key in an [environment variable (recommended)](TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key). If you don't have your key stored in an environment variable, you can assign it directly to `api_key` for testing purposes.
|
|
330
330
|
|
|
331
|
-
For this example, we assume you have created a [transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html). Following is the template content we used for testing.
|
|
331
|
+
For this example, we assume you have created a [legacy transactional template](https://sendgrid.com/docs/User_Guide/Transactional_Templates/index.html) in the UI or via the API. Following is the template content we used for testing.
|
|
332
332
|
|
|
333
333
|
Template ID (replace with your own):
|
|
334
334
|
|
data/sendgrid-ruby.gemspec
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
3
|
require 'sendgrid/version'
|
|
5
4
|
|
|
@@ -14,19 +13,19 @@ Gem::Specification.new do |spec|
|
|
|
14
13
|
|
|
15
14
|
spec.required_ruby_version = '>= 2.2'
|
|
16
15
|
|
|
17
|
-
spec.license
|
|
16
|
+
spec.license = 'MIT'
|
|
18
17
|
spec.files = `git ls-files -z`.split("\x0")
|
|
19
18
|
spec.executables = spec.files.grep(/^bin/) { |f| File.basename(f) }
|
|
20
19
|
spec.test_files = spec.files.grep(/^(test|spec|features)/)
|
|
21
20
|
spec.require_paths = ['lib']
|
|
22
21
|
spec.add_dependency 'ruby_http_client', '~> 3.4'
|
|
23
|
-
spec.add_development_dependency 'sinatra', '>= 1.4.7', '< 3'
|
|
24
|
-
spec.add_development_dependency 'rake', '~> 13.0'
|
|
25
|
-
spec.add_development_dependency 'rspec'
|
|
26
|
-
spec.add_development_dependency 'pry'
|
|
27
22
|
spec.add_development_dependency 'faker'
|
|
28
|
-
spec.add_development_dependency 'rubocop'
|
|
29
23
|
spec.add_development_dependency 'minitest', '~> 5.9'
|
|
24
|
+
spec.add_development_dependency 'pry'
|
|
30
25
|
spec.add_development_dependency 'rack'
|
|
26
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
|
27
|
+
spec.add_development_dependency 'rspec'
|
|
28
|
+
spec.add_development_dependency 'rubocop'
|
|
31
29
|
spec.add_development_dependency 'simplecov', '~> 0.18.5'
|
|
30
|
+
spec.add_development_dependency 'sinatra', '>= 1.4.7', '< 3'
|
|
32
31
|
end
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
require "json"
|
|
1
|
+
require "json"
|
|
2
2
|
|
|
3
3
|
module Fixtures
|
|
4
4
|
module EventWebhook
|
|
5
|
-
PUBLIC_KEY = '
|
|
6
|
-
FAILING_PUBLIC_KEY = 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqTxd43gyp8IOEto2LdIfjRQrIbsd4SXZkLW6jDutdhXSJCWHw8REntlo7aNDthvj+y7GjUuFDb/R1NGe1OPzpA=='
|
|
7
|
-
SIGNATURE = '
|
|
8
|
-
FAILING_SIGNATURE = 'MEUCIQCtIHJeH93Y+qpYeWrySphQgpNGNr/U+UyUlBkU6n7RAwIgJTz2C+8a8xonZGi6BpSzoQsbVRamr2nlxFDWYNH3j/0='
|
|
9
|
-
TIMESTAMP = '
|
|
10
|
-
PAYLOAD = {
|
|
11
|
-
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
|
|
5
|
+
PUBLIC_KEY = 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAE83T4O/n84iotIvIW4mdBgQ/7dAfSmpqIM8kF9mN1flpVKS3GRqe62gw+2fNNRaINXvVpiglSI8eNEc6wEA3F+g=='.freeze
|
|
6
|
+
FAILING_PUBLIC_KEY = 'MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEqTxd43gyp8IOEto2LdIfjRQrIbsd4SXZkLW6jDutdhXSJCWHw8REntlo7aNDthvj+y7GjUuFDb/R1NGe1OPzpA=='.freeze
|
|
7
|
+
SIGNATURE = 'MEUCIGHQVtGj+Y3LkG9fLcxf3qfI10QysgDWmMOVmxG0u6ZUAiEAyBiXDWzM+uOe5W0JuG+luQAbPIqHh89M15TluLtEZtM='.freeze
|
|
8
|
+
FAILING_SIGNATURE = 'MEUCIQCtIHJeH93Y+qpYeWrySphQgpNGNr/U+UyUlBkU6n7RAwIgJTz2C+8a8xonZGi6BpSzoQsbVRamr2nlxFDWYNH3j/0='.freeze
|
|
9
|
+
TIMESTAMP = '1600112502'.freeze
|
|
10
|
+
PAYLOAD = "#{[
|
|
11
|
+
{
|
|
12
|
+
email: 'hello@world.com',
|
|
13
|
+
event: 'dropped',
|
|
14
|
+
reason: 'Bounced Address',
|
|
15
|
+
sg_event_id: 'ZHJvcC0xMDk5NDkxOS1MUnpYbF9OSFN0T0doUTRrb2ZTbV9BLTA',
|
|
16
|
+
sg_message_id: 'LRzXl_NHStOGhQ4kofSm_A.filterdrecv-p3mdw1-756b745b58-kmzbl-18-5F5FC76C-9.0',
|
|
17
|
+
'smtp-id': '<LRzXl_NHStOGhQ4kofSm_A@ismtpd0039p1iad1.sendgrid.net>',
|
|
18
|
+
timestamp: 1_600_112_492
|
|
19
|
+
}
|
|
20
|
+
].to_json}\r\n".freeze # Be sure to include the trailing carriage return and newline!
|
|
15
21
|
end
|
|
16
22
|
end
|
|
@@ -12,19 +12,19 @@ unless RUBY_PLATFORM == 'java'
|
|
|
12
12
|
describe 'new' do
|
|
13
13
|
it 'should initialize with an app, public key and a path' do
|
|
14
14
|
expect do
|
|
15
|
-
Rack::SendGridWebhookVerification.new(@app, 'ABC',
|
|
15
|
+
Rack::SendGridWebhookVerification.new(@app, 'ABC', %r{/email})
|
|
16
16
|
end.not_to raise_error
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
it 'should initialize with an app, public key and paths' do
|
|
20
20
|
expect do
|
|
21
|
-
Rack::SendGridWebhookVerification.new(@app, 'ABC',
|
|
21
|
+
Rack::SendGridWebhookVerification.new(@app, 'ABC', %r{/email}, %r{/event})
|
|
22
22
|
end.not_to raise_error
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
|
|
26
26
|
describe 'calling against one path' do
|
|
27
|
-
let(:middleware) { Rack::SendGridWebhookVerification.new(@app, public_key,
|
|
27
|
+
let(:middleware) { Rack::SendGridWebhookVerification.new(@app, public_key, %r{/email}) }
|
|
28
28
|
|
|
29
29
|
it "should not intercept when the path doesn't match" do
|
|
30
30
|
expect(SendGrid::EventWebhook).to_not receive(:new)
|
|
@@ -81,7 +81,7 @@ unless RUBY_PLATFORM == 'java'
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
describe 'calling with multiple paths' do
|
|
84
|
-
let(:middleware) { Rack::SendGridWebhookVerification.new(@app, public_key,
|
|
84
|
+
let(:middleware) { Rack::SendGridWebhookVerification.new(@app, public_key, %r{/email}, %r{/events}) }
|
|
85
85
|
|
|
86
86
|
it "should not intercept when the path doesn't match" do
|
|
87
87
|
expect(SendGrid::EventWebhook).to_not receive(:new)
|
|
@@ -112,5 +112,31 @@ unless RUBY_PLATFORM == 'java'
|
|
|
112
112
|
expect(status).to eq(403)
|
|
113
113
|
end
|
|
114
114
|
end
|
|
115
|
+
|
|
116
|
+
describe 'request body which passed to an app' do
|
|
117
|
+
before do
|
|
118
|
+
@payload = nil
|
|
119
|
+
@spy_app = lambda do |env|
|
|
120
|
+
@payload = Rack::Request.new(env).body
|
|
121
|
+
[200, { 'Content-Type' => 'text/plain' }, ['Hello']]
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
let(:middleware) { Rack::SendGridWebhookVerification.new(@spy_app, public_key, %r{/email}) }
|
|
126
|
+
|
|
127
|
+
it 'keeps orignal reading position' do
|
|
128
|
+
options = {
|
|
129
|
+
:input => Fixtures::EventWebhook::PAYLOAD,
|
|
130
|
+
'Content-Type' => "application/json"
|
|
131
|
+
}
|
|
132
|
+
options[SendGrid::EventWebhookHeader::SIGNATURE] = Fixtures::EventWebhook::SIGNATURE
|
|
133
|
+
options[SendGrid::EventWebhookHeader::TIMESTAMP] = Fixtures::EventWebhook::TIMESTAMP
|
|
134
|
+
request = Rack::MockRequest.env_for('/email', options)
|
|
135
|
+
status, headers, body = middleware.call(request)
|
|
136
|
+
expect(status).to eq(200)
|
|
137
|
+
expect(@payload).not_to be_nil
|
|
138
|
+
expect(@payload.pos).to be_zero
|
|
139
|
+
end
|
|
140
|
+
end
|
|
115
141
|
end
|
|
116
142
|
end
|
|
@@ -6,77 +6,79 @@ describe SendGrid::EventWebhook do
|
|
|
6
6
|
it 'verifies a valid signature' do
|
|
7
7
|
unless skip_jruby
|
|
8
8
|
expect(verify(
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
Fixtures::EventWebhook::PUBLIC_KEY,
|
|
10
|
+
Fixtures::EventWebhook::PAYLOAD,
|
|
11
|
+
Fixtures::EventWebhook::SIGNATURE,
|
|
12
|
+
Fixtures::EventWebhook::TIMESTAMP
|
|
13
|
+
)).to be true
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
16
|
|
|
17
17
|
it 'rejects a bad key' do
|
|
18
18
|
unless skip_jruby
|
|
19
19
|
expect(verify(
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
Fixtures::EventWebhook::FAILING_PUBLIC_KEY,
|
|
21
|
+
Fixtures::EventWebhook::PAYLOAD,
|
|
22
|
+
Fixtures::EventWebhook::SIGNATURE,
|
|
23
|
+
Fixtures::EventWebhook::TIMESTAMP
|
|
24
|
+
)).to be false
|
|
25
25
|
end
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
it 'rejects a bad payload' do
|
|
29
29
|
unless skip_jruby
|
|
30
30
|
expect(verify(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
Fixtures::EventWebhook::PUBLIC_KEY,
|
|
32
|
+
'payload',
|
|
33
|
+
Fixtures::EventWebhook::SIGNATURE,
|
|
34
|
+
Fixtures::EventWebhook::TIMESTAMP
|
|
35
|
+
)).to be false
|
|
36
36
|
end
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
it 'rejects a bad signature' do
|
|
40
40
|
unless skip_jruby
|
|
41
41
|
expect(verify(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
Fixtures::EventWebhook::PUBLIC_KEY,
|
|
43
|
+
Fixtures::EventWebhook::PAYLOAD,
|
|
44
|
+
Fixtures::EventWebhook::FAILING_SIGNATURE,
|
|
45
|
+
Fixtures::EventWebhook::TIMESTAMP
|
|
46
|
+
)).to be false
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
it 'rejects a bad timestamp' do
|
|
51
51
|
unless skip_jruby
|
|
52
52
|
expect(verify(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
Fixtures::EventWebhook::PUBLIC_KEY,
|
|
54
|
+
Fixtures::EventWebhook::PAYLOAD,
|
|
55
|
+
Fixtures::EventWebhook::SIGNATURE,
|
|
56
|
+
'timestamp'
|
|
57
|
+
)).to be false
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
it 'rejects a missing signature' do
|
|
62
62
|
unless skip_jruby
|
|
63
63
|
expect(verify(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
Fixtures::EventWebhook::PUBLIC_KEY,
|
|
65
|
+
Fixtures::EventWebhook::PAYLOAD,
|
|
66
|
+
nil,
|
|
67
|
+
Fixtures::EventWebhook::TIMESTAMP
|
|
68
|
+
)).to be false
|
|
69
69
|
end
|
|
70
70
|
end
|
|
71
71
|
|
|
72
72
|
it 'throws an error when using jruby' do
|
|
73
73
|
if skip_jruby
|
|
74
|
-
expect
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
expect do
|
|
75
|
+
verify(
|
|
76
|
+
Fixtures::EventWebhook::PUBLIC_KEY,
|
|
77
|
+
Fixtures::EventWebhook::PAYLOAD,
|
|
78
|
+
Fixtures::EventWebhook::SIGNATURE,
|
|
79
|
+
Fixtures::EventWebhook::TIMESTAMP
|
|
80
|
+
)
|
|
81
|
+
end.to raise_error(SendGrid::EventWebhook::NotSupportedError)
|
|
80
82
|
end
|
|
81
83
|
end
|
|
82
84
|
end
|
|
@@ -4,7 +4,7 @@ describe SendGrid::MailSettingsDto do
|
|
|
4
4
|
let(:sendgrid_client) { SendGrid::API.new(api_key: 'fake_key').client }
|
|
5
5
|
let(:mail_settings) { SendGrid::MailSettingsDto }
|
|
6
6
|
let(:setting_name) { 'bcc' }
|
|
7
|
-
let(:setting_params) { {email: Faker::Internet.email, enabled: rand(1..100).even?} }
|
|
7
|
+
let(:setting_params) { { email: Faker::Internet.email, enabled: rand(1..100).even? } }
|
|
8
8
|
|
|
9
9
|
it { should respond_to :bcc }
|
|
10
10
|
it { should respond_to :address_whitelist }
|
|
@@ -4,7 +4,7 @@ describe SendGrid::PartnerSettingsDto do
|
|
|
4
4
|
let(:sendgrid_client) { SendGrid::API.new(api_key: 'fake_key').client }
|
|
5
5
|
let(:partner_settings) { SendGrid::PartnerSettingsDto }
|
|
6
6
|
let(:setting_name) { 'new_relic' }
|
|
7
|
-
let(:setting_params) { {license_key: 'key', enabled: rand(1..100).even?} }
|
|
7
|
+
let(:setting_params) { { license_key: 'key', enabled: rand(1..100).even? } }
|
|
8
8
|
|
|
9
9
|
it { should respond_to :new_relic }
|
|
10
10
|
|
|
@@ -18,8 +18,8 @@ describe SendGrid::Settings do
|
|
|
18
18
|
|
|
19
19
|
describe '.update_bcc' do
|
|
20
20
|
it 'updates bcc' do
|
|
21
|
-
bcc_response = settings.update_bcc(enabled: true, email:
|
|
21
|
+
bcc_response = settings.update_bcc(enabled: true, email: 'email@example.com')
|
|
22
22
|
expect(bcc_response).to be_a SendGrid::Response
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
|
-
end
|
|
25
|
+
end
|
|
@@ -4,7 +4,7 @@ describe SendGrid::TrackingSettingsDto do
|
|
|
4
4
|
let(:sendgrid_client) { SendGrid::API.new(api_key: 'fake_key').client }
|
|
5
5
|
let(:tracking_settings) { SendGrid::TrackingSettingsDto }
|
|
6
6
|
let(:setting_name) { 'open_tracking' }
|
|
7
|
-
let(:setting_params) { {enabled: rand(1..100).even?} }
|
|
7
|
+
let(:setting_params) { { enabled: rand(1..100).even? } }
|
|
8
8
|
|
|
9
9
|
it { should respond_to :open_tracking }
|
|
10
10
|
it { should respond_to :click_tracking }
|
|
@@ -4,7 +4,7 @@ describe SendGrid::UserSettingsDto do
|
|
|
4
4
|
let(:sendgrid_client) { SendGrid::API.new(api_key: 'fake_key').client }
|
|
5
5
|
let(:user_settings) { SendGrid::UserSettingsDto }
|
|
6
6
|
let(:setting_name) { 'enforced_tls' }
|
|
7
|
-
let(:setting_params) { {require_tls: rand(1..100).even?} }
|
|
7
|
+
let(:setting_params) { { require_tls: rand(1..100).even? } }
|
|
8
8
|
|
|
9
9
|
it { should respond_to :enforced_tls }
|
|
10
10
|
|
|
@@ -7,37 +7,36 @@ describe SendGrid::EmailStats do
|
|
|
7
7
|
|
|
8
8
|
let(:sample_response) do
|
|
9
9
|
[{
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
{
|
|
10
|
+
'date' => '2017-10-01',
|
|
11
|
+
'stats' => [
|
|
12
|
+
{ 'metrics' =>
|
|
13
13
|
{
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
}
|
|
14
|
+
'blocks' => 101,
|
|
15
|
+
'bounce_drops' => 102,
|
|
16
|
+
'bounces' => 103,
|
|
17
|
+
'clicks' => 104,
|
|
18
|
+
'deferred' => 105,
|
|
19
|
+
'delivered' => 106,
|
|
20
|
+
'invalid_emails' => 107,
|
|
21
|
+
'opens' => 108,
|
|
22
|
+
'processed' => 109,
|
|
23
|
+
'requests' => 110,
|
|
24
|
+
'spam_report_drops' => 111,
|
|
25
|
+
'spam_reports' => 112,
|
|
26
|
+
'unique_clicks' => 113,
|
|
27
|
+
'unique_opens' => 114,
|
|
28
|
+
'unsubscribe_drops' => 115,
|
|
29
|
+
'unsubscribes' => 116
|
|
30
|
+
} }
|
|
32
31
|
]
|
|
33
32
|
}]
|
|
34
33
|
end
|
|
35
34
|
|
|
36
35
|
let(:error_response) do
|
|
37
36
|
{
|
|
38
|
-
|
|
37
|
+
'errors' => [
|
|
39
38
|
{
|
|
40
|
-
|
|
39
|
+
'message' => 'end_date should be a YYYY-MM-DD formatted date'
|
|
41
40
|
}
|
|
42
41
|
]
|
|
43
42
|
}
|
|
@@ -3,23 +3,23 @@ require 'spec_helper'
|
|
|
3
3
|
describe SendGrid::Metrics do
|
|
4
4
|
let(:params) do
|
|
5
5
|
{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
'date' => '2017-10-01',
|
|
7
|
+
'blocks' => 101,
|
|
8
|
+
'bounce_drops' => 102,
|
|
9
|
+
'bounces' => 103,
|
|
10
|
+
'clicks' => 104,
|
|
11
|
+
'deferred' => 105,
|
|
12
|
+
'delivered' => 106,
|
|
13
|
+
'invalid_emails' => 107,
|
|
14
|
+
'opens' => 108,
|
|
15
|
+
'processed' => 109,
|
|
16
|
+
'requests' => 110,
|
|
17
|
+
'spam_report_drops' => 111,
|
|
18
|
+
'spam_reports' => 112,
|
|
19
|
+
'unique_clicks' => 113,
|
|
20
|
+
'unique_opens' => 114,
|
|
21
|
+
'unsubscribe_drops' => 115,
|
|
22
|
+
'unsubscribes' => 116
|
|
23
23
|
}
|
|
24
24
|
end
|
|
25
25
|
|
|
@@ -33,14 +33,13 @@ describe SendGrid::Metrics do
|
|
|
33
33
|
expect(subject.date).to be_a Date
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
-
%w
|
|
36
|
+
%w[
|
|
37
37
|
blocks bounce_drops bounces clicks deferred delivered invalid_emails
|
|
38
38
|
opens processed requests spam_report_drops spam_reports unique_clicks
|
|
39
39
|
unique_opens unsubscribe_drops unsubscribes
|
|
40
|
-
|
|
40
|
+
].each do |attribute|
|
|
41
41
|
it "responds to #{attribute}" do
|
|
42
42
|
expect(subject).to respond_to(attribute.to_sym)
|
|
43
43
|
end
|
|
44
44
|
end
|
|
45
|
-
|
|
46
45
|
end
|