sendgrid-ruby 6.3.9 → 6.5.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf21bd306727e384a838c428f07f5866f9108ab03f41160b8dfe429d3116537b
4
- data.tar.gz: b73d7dfbb09c9d817096762a882e85e1eeb77bd2abd3397d45923fcf4f81b4cc
3
+ metadata.gz: e9ae3c96f2f17a8c259ea3f8e369e19c37bb8764074abe57a2cbf9af9e14879e
4
+ data.tar.gz: 2bd8adf75c2e77b81c5c8d5f6c3e01cb4d8a52ea25252bdea2e24b8cbb9dbaa2
5
5
  SHA512:
6
- metadata.gz: 52f3285d9ff1f54c4fd46372118de4847fb7508e8c28720362d66aebde5f67decb780a51a9fdaa295d4a67c38bae70ae484ab17ec53e80b38aa8a614de7a0083
7
- data.tar.gz: 21b3545263c927498194e31f628d91ded1d6ba39da5e81865a3368729a804338be697f6cb9ca9c89ddeb0dcebca7635b4c8a1a7c99516cf3b8c4425c2bca8688
6
+ metadata.gz: 5e6c60136a7aac529987dc16543daa49da5ad7f65120ab994e41f66f00a86665e68aeea7990089893d39f43161d4601ebc08df37f05264b9dc967a169f3fdb7b
7
+ data.tar.gz: f940ee99e5254db6ae88e5bc6297ec16f941ad6bf2f1e619c1cefc1605cf9577c8a838ce0423e2ba8dc7e58f875f88aedb287a1ef50e59e4676491cc0e1011d6
@@ -0,0 +1,10 @@
1
+ contact_links:
2
+ - name: Twilio SendGrid Support
3
+ url: https://support.sendgrid.com
4
+ about: Get Support
5
+ - name: Stack Overflow
6
+ url: https://stackoverflow.com/questions/tagged/sendgrid-ruby+or+sendgrid+ruby
7
+ about: Ask questions on Stack Overflow
8
+ - name: Documentation
9
+ url: https://sendgrid.com/docs/for-developers/
10
+ about: View Reference Documentation
data/.rubocop_todo.yml CHANGED
@@ -34,6 +34,8 @@ Metrics/BlockLength:
34
34
  # Configuration parameters: CountComments, CountAsOne.
35
35
  Metrics/ClassLength:
36
36
  Max: 2006
37
+ Exclude:
38
+ - 'test/sendgrid/test_sendgrid-ruby.rb'
37
39
 
38
40
  # Offense count: 41
39
41
  # Configuration parameters: CountComments, CountAsOne, ExcludedMethods.
data/.travis.yml CHANGED
@@ -1,25 +1,26 @@
1
1
  language: ruby
2
2
  env:
3
- - version=ruby:2.7
4
- - version=ruby:2.6
5
- - version=ruby:2.5
6
- - version=ruby:2.4
7
- - version=jruby:9.2
8
-
3
+ - version=ruby:3.0
4
+ - version=ruby:2.7
5
+ - version=ruby:2.6
6
+ - version=ruby:2.5
7
+ - version=ruby:2.4
8
+ - version=jruby:9.2
9
9
  gemfile:
10
- - gemfiles/Sinatra_1.gemfile
11
- - gemfiles/Sinatra_2.gemfile
12
-
13
- script: make test-docker
14
-
10
+ - gemfiles/Sinatra_1.gemfile
11
+ - gemfiles/Sinatra_2.gemfile
12
+ script:
13
+ - if [[ "$TRAVIS_BRANCH" == "main" || "$TRAVIS_BRANCH" == "travis" ]] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
14
+ echo "${DOCKER_PASSWORD}" | docker login -u "${DOCKER_USERNAME}" --password-stdin;
15
+ fi
16
+ - make test-docker
15
17
  deploy:
16
18
  provider: rubygems
17
- api_key: $RUBYGEMS_API_KEY
19
+ api_key: "$RUBYGEMS_API_KEY"
18
20
  gem: sendgrid-ruby
19
21
  on:
20
22
  tags: true
21
23
  condition: $version = ruby:2.4 && $BUNDLE_GEMFILE = *"gemfiles/Sinatra_1.gemfile"
22
-
23
24
  notifications:
24
25
  slack:
25
26
  if: branch = main
@@ -27,4 +28,4 @@ notifications:
27
28
  on_success: never
28
29
  on_failure: change
29
30
  rooms:
30
- - secure: QwoVrGveeA1bo/26fO2A+OQHmUX69NLaC214qd18C1Z8ztYMHkd05/9+k9HFb+PSdPkGLSeYOPWAKJUqJWB7HfGINNGpRGIPFcmfB7vhvvLFnhud/SAdQPRZ+SCeZPdpZcjpVRLYENKv259ucGPBCPFXh1HfJF92R0IrKeW5CII=
31
+ secure: oSeohwM+ernyiRYSRLpNlICk0wgj0lku3y5LuouJLRHs45tCAzLZLbgxsor18wCSJkmhfn2vg4Rn969VnskFuj70OhJSLBKL4UXBnR1Ji0ClpfJlGojcbY/5Z8N/eGDrvf5ofA0Jc+L/ut+oSCMXnstEGbx4wBpPTajHuRtvb34=
data/CHANGELOG.md CHANGED
@@ -1,6 +1,30 @@
1
1
  # Change Log
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ [2021-10-18] Version 6.5.2
5
+ --------------------------
6
+ **Library - Docs**
7
+ - [PR #472](https://github.com/sendgrid/sendgrid-ruby/pull/472): improve signed webhook event validation docs. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
8
+
9
+
10
+ [2021-09-08] Version 6.5.1
11
+ --------------------------
12
+ **Library - Chore**
13
+ - [PR #470](https://github.com/sendgrid/sendgrid-ruby/pull/470): add support for ruby 3.0. Thanks to [@shwetha-manvinkurke](https://github.com/shwetha-manvinkurke)!
14
+
15
+
16
+ [2021-08-11] Version 6.5.0
17
+ --------------------------
18
+ **Library - Feature**
19
+ - [PR #466](https://github.com/sendgrid/sendgrid-ruby/pull/466): Add From address to personalization. Thanks to [@grin](https://github.com/grin)!
20
+
21
+
22
+ [2021-02-10] Version 6.4.0
23
+ --------------------------
24
+ **Library - Feature**
25
+ - [PR #455](https://github.com/sendgrid/sendgrid-ruby/pull/455): Add http_options as a param in the SendGrid::API's constructor. Thanks to [@hoangtuanictvn](https://github.com/hoangtuanictvn)!
26
+
27
+
4
28
  [2021-01-27] Version 6.3.9
5
29
  --------------------------
6
30
  **Library - Fix**
data/README.md CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  [![Travis Badge](https://travis-ci.com/sendgrid/sendgrid-ruby.svg?branch=main)](https://travis-ci.com/sendgrid/sendgrid-ruby)
4
4
  [![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)
5
- [![Email Notifications Badge](https://dx.sendgrid.com/badge/ruby)](https://dx.sendgrid.com/newsletter/ruby)
6
5
  [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
7
6
  [![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
8
7
  [![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-ruby.svg)](https://github.com/sendgrid/sendgrid-ruby/graphs/contributors)
data/TROUBLESHOOTING.md CHANGED
@@ -17,6 +17,7 @@ If you can't find a solution below, please open an [issue](https://github.com/se
17
17
  * [Rails Specifics](#rails-specifics)
18
18
  * [Ruby Versions](#ruby-versions)
19
19
  * [Viewing the Request Body](#viewing-the-request-body)
20
+ * [Verifying Event Webhooks](#signed-webhooks)
20
21
 
21
22
  <a name="migrating"></a>
22
23
  ## Migrating from v2 to v3
@@ -137,3 +138,14 @@ You can do this before `response = sg.client.mail._('send').post(request_body: m
137
138
  ```ruby
138
139
  puts mail.to_json
139
140
  ```
141
+
142
+ <a name="signed-webhooks"></a>
143
+ ## Signed Webhook Verification
144
+
145
+ Twilio SendGrid's Event Webhook will notify a URL via HTTP POST with information about events that occur as your mail is processed. [This](https://docs.sendgrid.com/for-developers/tracking-events/getting-started-event-webhook-security-features) article covers all you need to know to secure the Event Webhook, allowing you to verify that incoming requests originate from Twilio SendGrid. The sendgrid-ruby library can help you verify these Signed Event Webhooks.
146
+
147
+ You can find the usage example [here](examples/helpers/eventwebhook/example.rb) and the tests [here](spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb).
148
+ If you are still having trouble getting the validation to work, follow the following instructions:
149
+ - Be sure to use the *raw* payload for validation
150
+ - Be sure to include a trailing carriage return and newline in your payload
151
+ - In case of multi-event webhooks, make sure you include the trailing newline and carriage return after *each* event
@@ -18,6 +18,7 @@ def hello_world
18
18
  puts response.headers
19
19
  end
20
20
 
21
+ # rubocop:disable Metrics/AbcSize
21
22
  def kitchen_sink
22
23
  mail = SendGrid::Mail.new
23
24
  mail.from = Email.new(email: 'test@example.com')
@@ -29,6 +30,9 @@ def kitchen_sink
29
30
  personalization.add_cc(Email.new(email: 'test4@example.com', name: 'Example User'))
30
31
  personalization.add_bcc(Email.new(email: 'test5@example.com', name: 'Example User'))
31
32
  personalization.add_bcc(Email.new(email: 'test6@example.com', name: 'Example User'))
33
+ # Note, the domain of the from email property specified in any personalization must
34
+ # match the domain of the from email property specified at root level
35
+ personalization.from = Email.new(email: 'alias@example.com', name: "My alias")
32
36
  personalization.subject = 'Hello World from the Personalized Twilio SendGrid Ruby Library'
33
37
  personalization.add_header(Header.new(key: 'X-Test', value: 'True'))
34
38
  personalization.add_header(Header.new(key: 'X-Mock', value: 'False'))
@@ -124,6 +128,7 @@ def kitchen_sink
124
128
  puts response.body
125
129
  puts response.headers
126
130
  end
131
+ # rubocop:enable Metrics/AbcSize
127
132
 
128
133
  def dynamic_template_data_hello_world
129
134
  mail = Mail.new
@@ -4,7 +4,7 @@ require_relative 'version'
4
4
  # Initialize the HTTP client
5
5
  class BaseInterface
6
6
  attr_accessor :client
7
- attr_reader :request_headers, :host, :version, :impersonate_subuser
7
+ attr_reader :request_headers, :host, :version, :impersonate_subuser, :http_options
8
8
 
9
9
  # * *Args* :
10
10
  # - +auth+ -> authorization header value
@@ -14,8 +14,9 @@ class BaseInterface
14
14
  # currently only "v3" is supported
15
15
  # - +impersonate_subuser+ -> the subuser to impersonate, will be passed
16
16
  # in the "On-Behalf-Of" header
17
+ # - +http_options+ -> http options that you want to be globally applied to each request
17
18
  #
18
- def initialize(auth:, host:, request_headers: nil, version: nil, impersonate_subuser: nil)
19
+ def initialize(auth:, host:, request_headers: nil, version: nil, impersonate_subuser: nil, http_options: {})
19
20
  @auth = auth
20
21
  @host = host
21
22
  @version = version || 'v3'
@@ -31,7 +32,9 @@ class BaseInterface
31
32
  @request_headers['On-Behalf-Of'] = @impersonate_subuser if @impersonate_subuser
32
33
 
33
34
  @request_headers = @request_headers.merge(request_headers) if request_headers
35
+ @http_options = http_options
34
36
  @client = SendGrid::Client.new(host: "#{@host}/#{@version}",
35
- request_headers: @request_headers)
37
+ request_headers: @request_headers,
38
+ http_options: @http_options)
36
39
  end
37
40
  end
@@ -5,10 +5,11 @@ module SendGrid
5
5
  attr_reader :tos, :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, :from
9
9
 
10
10
  def initialize
11
11
  @tos = []
12
+ @from = nil
12
13
  @ccs = []
13
14
  @bccs = []
14
15
  @subject = nil
@@ -59,6 +60,7 @@ module SendGrid
59
60
  def to_json(*)
60
61
  {
61
62
  'to' => tos,
63
+ 'from' => from,
62
64
  'cc' => ccs,
63
65
  'bcc' => bccs,
64
66
  'subject' => subject,
@@ -9,12 +9,13 @@ module SendGrid
9
9
  # currently only "v3" is supported
10
10
  # - +impersonate_subuser+ -> the subuser to impersonate, will be passed
11
11
  # in the "On-Behalf-Of" header
12
+ # - +http_options+ -> http options that you want to be globally applied to each request
12
13
  #
13
- def initialize(api_key:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil)
14
+ def initialize(api_key:, host: nil, request_headers: nil, version: nil, impersonate_subuser: nil, http_options: {})
14
15
  auth = "Bearer #{api_key}"
15
16
  host ||= 'https://api.sendgrid.com'
16
17
 
17
- super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser)
18
+ super(auth: auth, host: host, request_headers: request_headers, version: version, impersonate_subuser: impersonate_subuser, http_options: http_options)
18
19
  end
19
20
  end
20
21
  end
@@ -1,3 +1,3 @@
1
1
  module SendGrid
2
- VERSION = '6.3.9'.freeze
2
+ VERSION = '6.5.2'.freeze
3
3
  end
@@ -19,14 +19,14 @@ describe SendGrid::MailSettingsDto do
19
19
  describe '.fetch' do
20
20
  it 'calls get on sendgrid_client' do
21
21
  args = { sendgrid_client: sendgrid_client, name: setting_name, query_params: {} }
22
- expect(mail_settings.fetch(args)).to be_a SendGrid::Response
22
+ expect(mail_settings.fetch(**args)).to be_a SendGrid::Response
23
23
  end
24
24
  end
25
25
 
26
26
  describe '.update' do
27
27
  it 'calls patch on sendgrid_client' do
28
28
  args = { sendgrid_client: sendgrid_client, name: setting_name, request_body: setting_params }
29
- expect(mail_settings.update(args)).to be_a SendGrid::Response
29
+ expect(mail_settings.update(**args)).to be_a SendGrid::Response
30
30
  end
31
31
  end
32
32
  end
@@ -11,14 +11,14 @@ describe SendGrid::PartnerSettingsDto do
11
11
  describe '.fetch' do
12
12
  it 'calls get on sendgrid_client' do
13
13
  args = { sendgrid_client: sendgrid_client, name: setting_name, query_params: {} }
14
- expect(partner_settings.fetch(args)).to be_a SendGrid::Response
14
+ expect(partner_settings.fetch(**args)).to be_a SendGrid::Response
15
15
  end
16
16
  end
17
17
 
18
18
  describe '.update' do
19
19
  it 'calls patch on sendgrid_client' do
20
20
  args = { sendgrid_client: sendgrid_client, name: setting_name, request_body: setting_params }
21
- expect(partner_settings.update(args)).to be_a SendGrid::Response
21
+ expect(partner_settings.update(**args)).to be_a SendGrid::Response
22
22
  end
23
23
  end
24
24
  end
@@ -14,14 +14,14 @@ describe SendGrid::TrackingSettingsDto do
14
14
  describe '.fetch' do
15
15
  it 'calls get on sendgrid_client' do
16
16
  args = { sendgrid_client: sendgrid_client, name: setting_name, query_params: {} }
17
- expect(tracking_settings.fetch(args)).to be_a SendGrid::Response
17
+ expect(tracking_settings.fetch(**args)).to be_a SendGrid::Response
18
18
  end
19
19
  end
20
20
 
21
21
  describe '.update' do
22
22
  it 'calls patch on sendgrid_client' do
23
23
  args = { sendgrid_client: sendgrid_client, name: setting_name, request_body: setting_params }
24
- expect(tracking_settings.update(args)).to be_a SendGrid::Response
24
+ expect(tracking_settings.update(**args)).to be_a SendGrid::Response
25
25
  end
26
26
  end
27
27
  end
@@ -11,14 +11,14 @@ describe SendGrid::UserSettingsDto do
11
11
  describe '.fetch' do
12
12
  it 'calls get on sendgrid_client' do
13
13
  args = { sendgrid_client: sendgrid_client, name: setting_name, query_params: {} }
14
- expect(user_settings.fetch(args)).to be_a SendGrid::Response
14
+ expect(user_settings.fetch(**args)).to be_a SendGrid::Response
15
15
  end
16
16
  end
17
17
 
18
18
  describe '.update' do
19
19
  it 'calls patch on sendgrid_client' do
20
20
  args = { sendgrid_client: sendgrid_client, name: setting_name, request_body: setting_params }
21
- expect(user_settings.update(args)).to be_a SendGrid::Response
21
+ expect(user_settings.update(**args)).to be_a SendGrid::Response
22
22
  end
23
23
  end
24
24
  end
@@ -33,8 +33,9 @@ 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.3.9', SendGrid::VERSION)
36
+ assert_equal('6.5.2', SendGrid::VERSION)
37
37
  assert_instance_of(SendGrid::Client, sg.client)
38
+ assert_equal({}, sg.http_options)
38
39
  end
39
40
 
40
41
  def test_init_when_impersonate_subuser_is_not_given
@@ -42,6 +43,23 @@ class TestAPI < MiniTest::Test
42
43
  refute_includes(sg.request_headers, 'On-Behalf-Of')
43
44
  end
44
45
 
46
+ def test_init_when_http_options_is_given
47
+ params = JSON.parse('{"subuser": "test_string", "ip": "test_string", "limit": 1, "exclude_whitelabels": "true", "offset": 1}')
48
+ headers = JSON.parse('{"X-Mock": 200}')
49
+ http_options = {
50
+ open_timeout: 40,
51
+ read_timeout: 40
52
+ }
53
+
54
+ sg = SendGrid::API.new(api_key: 'SENDGRID_API_KEY', version: 'v3', http_options: http_options)
55
+ client = sg.client.ips
56
+ response = client.get(query_params: params, request_headers: headers)
57
+
58
+ assert_equal(40, client.http.open_timeout)
59
+ assert_equal(40, client.http.read_timeout)
60
+ assert_equal('200', response.status_code)
61
+ end
62
+
45
63
  def test_access_settings_activity_get
46
64
  params = JSON.parse('{"limit": 1}')
47
65
  headers = JSON.parse('{"X-Mock": 200}')
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.3.9
4
+ version: 6.5.2
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-01-27 00:00:00.000000000 Z
13
+ date: 2021-10-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby_http_client
@@ -167,6 +167,7 @@ extra_rdoc_files: []
167
167
  files:
168
168
  - ".codeclimate.yml"
169
169
  - ".env_sample"
170
+ - ".github/ISSUE_TEMPLATE/config.yml"
170
171
  - ".gitignore"
171
172
  - ".rubocop.yml"
172
173
  - ".rubocop_todo.yml"