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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bf21bd306727e384a838c428f07f5866f9108ab03f41160b8dfe429d3116537b
4
- data.tar.gz: b73d7dfbb09c9d817096762a882e85e1eeb77bd2abd3397d45923fcf4f81b4cc
3
+ metadata.gz: 8a77256d8db572200bdedd90a2b719d0f36d1a1aecbf17070968b555ed404028
4
+ data.tar.gz: 10081de69452a519515b2fe5f086460935cac375e1d3ade7528412477aab38a9
5
5
  SHA512:
6
- metadata.gz: 52f3285d9ff1f54c4fd46372118de4847fb7508e8c28720362d66aebde5f67decb780a51a9fdaa295d4a67c38bae70ae484ab17ec53e80b38aa8a614de7a0083
7
- data.tar.gz: 21b3545263c927498194e31f628d91ded1d6ba39da5e81865a3368729a804338be697f6cb9ca9c89ddeb0dcebca7635b4c8a1a7c99516cf3b8c4425c2bca8688
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
@@ -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.4.0'.freeze
3
3
  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.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.3.9
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-01-27 00:00:00.000000000 Z
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