sendgrid-ruby 6.3.9 → 6.4.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/.rubocop_todo.yml +2 -0
- data/CHANGELOG.md +6 -0
- data/lib/sendgrid/base_interface.rb +6 -3
- data/lib/sendgrid/sendgrid.rb +3 -2
- data/lib/sendgrid/version.rb +1 -1
- data/test/sendgrid/test_sendgrid-ruby.rb +19 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8a77256d8db572200bdedd90a2b719d0f36d1a1aecbf17070968b555ed404028
|
|
4
|
+
data.tar.gz: 10081de69452a519515b2fe5f086460935cac375e1d3ade7528412477aab38a9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa4e2a6a2cd904d43f1c32a57ecbc1ea7db0729fed4cab05303566515975661fd12bb0e1d3f92480b3101276019db4a1858dc060ff35a1055ff587dc5582d071
|
|
7
|
+
data.tar.gz: 10493d88b4836f3f90a8813dbe3bb6d40e141a3d0f1ed99adc35c34a308c7a149104b7bde9829c8bf5b5b1efb7e855ad1236fc43c5f6c444c656a1e6f740599c
|
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/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-02-10] Version 6.4.0
|
|
5
|
+
--------------------------
|
|
6
|
+
**Library - Feature**
|
|
7
|
+
- [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)!
|
|
8
|
+
|
|
9
|
+
|
|
4
10
|
[2021-01-27] Version 6.3.9
|
|
5
11
|
--------------------------
|
|
6
12
|
**Library - Fix**
|
|
@@ -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
|
data/lib/sendgrid/sendgrid.rb
CHANGED
|
@@ -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
|
data/lib/sendgrid/version.rb
CHANGED
|
@@ -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.
|
|
36
|
+
assert_equal('6.4.0', 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.
|
|
4
|
+
version: 6.4.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-02-10 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: ruby_http_client
|