sendgrid-ruby 5.3.0 → 6.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +22 -20
  3. data/CHANGELOG.md +55 -0
  4. data/CODE_OF_CONDUCT.md +57 -25
  5. data/CONTRIBUTING.md +18 -23
  6. data/ISSUE_TEMPLATE.md +26 -0
  7. data/LICENSE.md +21 -0
  8. data/Makefile +7 -0
  9. data/PULL_REQUEST_TEMPLATE.md +31 -0
  10. data/README.md +26 -13
  11. data/Rakefile +1 -1
  12. data/TROUBLESHOOTING.md +22 -16
  13. data/UPGRADE.md +5 -0
  14. data/USAGE.md +1103 -1101
  15. data/USE_CASES.md +248 -18
  16. data/examples/helpers/mail/example.rb +7 -7
  17. data/examples/ips/ips.rb +13 -0
  18. data/examples/mail/mail.rb +2 -2
  19. data/examples/scopes/scopes.rb +49 -3
  20. data/examples/{whitelabel/whitelabel.rb → senderauthentication/senderauthentication.rb} +27 -27
  21. data/examples/suppression/suppression.rb +10 -10
  22. data/lib/sendgrid/client.rb +12 -9
  23. data/lib/sendgrid/helpers/inbound/README.md +22 -5
  24. data/lib/sendgrid/helpers/inbound/app.rb +13 -1
  25. data/lib/sendgrid/helpers/inbound/public/index.html +1 -1
  26. data/lib/sendgrid/helpers/inbound/sample_data/default_data.txt +2 -2
  27. data/lib/sendgrid/helpers/inbound/sample_data/raw_data.txt +2 -2
  28. data/lib/sendgrid/helpers/inbound/sample_data/raw_data_with_attachments.txt +2 -2
  29. data/lib/sendgrid/helpers/inbound/send.rb +2 -2
  30. data/lib/sendgrid/helpers/ip_management/ip_management.rb +17 -0
  31. data/lib/sendgrid/helpers/mail/README.md +1 -1
  32. data/lib/sendgrid/helpers/mail/attachment.rb +24 -1
  33. data/lib/sendgrid/helpers/mail/category.rb +0 -8
  34. data/lib/sendgrid/helpers/mail/content.rb +3 -16
  35. data/lib/sendgrid/helpers/mail/email.rb +3 -16
  36. data/lib/sendgrid/helpers/mail/mail.rb +8 -40
  37. data/lib/sendgrid/helpers/permissions/scope.rb +28 -0
  38. data/lib/sendgrid/helpers/permissions/scopes.yml +309 -0
  39. data/lib/sendgrid/helpers/settings/README.md +1 -1
  40. data/lib/sendgrid/helpers/stats/stats_response.rb +1 -1
  41. data/lib/sendgrid/version.rb +1 -1
  42. data/lib/sendgrid-ruby.rb +2 -0
  43. data/mail_helper_v3.md +9 -9
  44. data/sendgrid-ruby.gemspec +3 -3
  45. data/spec/sendgrid/helpers/ip_management/ip_management_spec.rb +12 -0
  46. data/test/sendgrid/helpers/mail/test_attachment.rb +35 -0
  47. data/test/sendgrid/helpers/mail/test_mail.rb +29 -21
  48. data/test/sendgrid/permissions/test_scopes.rb +38 -0
  49. data/test/sendgrid/test_sendgrid-ruby.rb +21 -13
  50. metadata +22 -11
  51. data/.github/ISSUE_TEMPLATE +0 -17
  52. data/.github/PULL_REQUEST_TEMPLATE +0 -24
  53. data/LICENSE.txt +0 -22
@@ -0,0 +1,38 @@
1
+ require_relative '../../../lib/sendgrid/helpers/permissions/scope'
2
+ require 'minitest/autorun'
3
+
4
+ class TestCategory < Minitest::Test
5
+
6
+ include SendGrid
7
+
8
+ # usecases
9
+ # 1. test admin scopes
10
+ # 2. test read only scopes
11
+ # 3. test read only and full access scopes for a method by hardcoding
12
+ # 4. test read only and full access scopes by loading scopes.yaml
13
+
14
+ def setup
15
+ @scopes_from_yaml = YAML.load_file(File.dirname(__FILE__) + '/../../../lib/sendgrid/helpers/permissions/scopes.yml').freeze
16
+ end
17
+
18
+ def test_admin_scopes
19
+ assert_equal Scope.admin_permissions, @scopes_from_yaml.values.map(&:values).flatten
20
+ end
21
+
22
+ def test_read_only_scopes
23
+ assert_equal Scope.read_only_permissions, @scopes_from_yaml.map { |_, v| v[:read] }.flatten
24
+ end
25
+
26
+ def test_read_only_and_full_access_for_mail_hardcoded
27
+ assert_equal Scope.mail_read_only_permissions, ["mail.batch.read"]
28
+ assert_equal Scope.mail_full_access_permissions, ["mail.send", "mail.batch.create", "mail.batch.delete", "mail.batch.read", "mail.batch.update"]
29
+ end
30
+
31
+ def test_read_only_and_full_access_from_file
32
+ @scopes_from_yaml.each_key do |endpoint|
33
+ assert_equal Scope.send("#{endpoint}_read_only_permissions"), @scopes_from_yaml[endpoint][:read]
34
+ assert_equal Scope.send("#{endpoint}_full_access_permissions"), @scopes_from_yaml[endpoint].values.flatten
35
+ end
36
+ end
37
+
38
+ end
@@ -41,7 +41,8 @@ class TestAPI < MiniTest::Test
41
41
  "X-Test": "test"
42
42
  }
43
43
  ')
44
- sg = SendGrid::API.new(api_key: "SENDGRID_API_KEY", host: "https://api.test.com", request_headers: headers, version: "v3")
44
+ subuser = 'test_user'
45
+ sg = SendGrid::API.new(api_key: "SENDGRID_API_KEY", host: "https://api.test.com", request_headers: headers, version: "v3", impersonate_subuser: subuser)
45
46
 
46
47
  assert_equal("https://api.test.com", sg.host)
47
48
  user_agent = "sendgrid/#{SendGrid::VERSION};ruby"
@@ -50,15 +51,22 @@ class TestAPI < MiniTest::Test
50
51
  "Authorization": "Bearer SENDGRID_API_KEY",
51
52
  "Accept": "application/json",
52
53
  "X-Test": "test",
53
- "User-agent": "' + user_agent + '"
54
+ "User-agent": "' + user_agent + '",
55
+ "On-Behalf-Of": "' + subuser + '"
54
56
  }
55
57
  ')
56
58
  assert_equal(test_headers, sg.request_headers)
57
59
  assert_equal("v3", sg.version)
58
- assert_equal("5.3.0", SendGrid::VERSION)
60
+ assert_equal(subuser, sg.impersonate_subuser)
61
+ assert_equal("6.0.4", SendGrid::VERSION)
59
62
  assert_instance_of(SendGrid::Client, sg.client)
60
63
  end
61
64
 
65
+ def test_init_when_impersonate_subuser_is_not_given
66
+ sg = SendGrid::API.new(api_key: "SENDGRID_API_KEY", host: "https://api.test.com", version: "v3")
67
+ refute_includes(sg.request_headers, 'On-Behalf-Of')
68
+ end
69
+
62
70
  def test_access_settings_activity_get
63
71
  params = JSON.parse('{"limit": 1}')
64
72
  headers = JSON.parse('{"X-Mock": 200}')
@@ -1176,8 +1184,8 @@ class TestAPI < MiniTest::Test
1176
1184
  },
1177
1185
  "footer": {
1178
1186
  "enable": true,
1179
- "html": "<p>Thanks</br>The SendGrid Team</p>",
1180
- "text": "Thanks,/n The SendGrid Team"
1187
+ "html": "<p>Thanks</br>The Twilio SendGrid Team</p>",
1188
+ "text": "Thanks,/n The Twilio SendGrid Team"
1181
1189
  },
1182
1190
  "sandbox_mode": {
1183
1191
  "enable": false
@@ -1883,7 +1891,7 @@ class TestAPI < MiniTest::Test
1883
1891
  email = "test_url_param"
1884
1892
  headers = JSON.parse('{"X-Mock": 204}')
1885
1893
 
1886
- response = @sg.client.suppression.spam_report._(email).delete(request_headers: headers)
1894
+ response = @sg.client.suppression.spam_reports._(email).delete(request_headers: headers)
1887
1895
 
1888
1896
  self.assert_equal('204', response.status_code)
1889
1897
  end
@@ -2670,15 +2678,15 @@ class TestAPI < MiniTest::Test
2670
2678
 
2671
2679
 
2672
2680
  def test_license_file_correct_year_range
2673
- if File.exist?('./LICENSE.txt')
2681
+ if File.exist?('./LICENSE.md')
2674
2682
  # get only the first line from the license txt file
2675
- year_range = File.open('./LICENSE.txt', &:readline).gsub(/[^\d-]/, '')
2676
- self.assert_equal("2014-#{Time.now.year}", year_range)
2683
+ year_range = File.open('./LICENSE.md', &:readline).gsub(/[^\d-]/, '')
2684
+ self.assert_equal("#{Time.now.year}", year_range)
2677
2685
  end
2678
2686
  end
2679
2687
 
2680
2688
  def test_docker_exists
2681
- assert(File.file?('./Dockerfile') || File.file?('./docker/Dockerfile'))
2689
+ assert(File.file?('./Docker') || File.file?('./docker/Dockerfile'))
2682
2690
  end
2683
2691
 
2684
2692
  # def test_docker_compose_exists
@@ -2714,15 +2722,15 @@ class TestAPI < MiniTest::Test
2714
2722
  end
2715
2723
 
2716
2724
  def test_issue_template_exists
2717
- assert(File.file?('./.github/ISSUE_TEMPLATE'))
2725
+ assert(File.file?('./ISSUE_TEMPLATE.md'))
2718
2726
  end
2719
2727
 
2720
2728
  def test_license_exists
2721
- assert(File.file?('./LICENSE.txt'))
2729
+ assert(File.file?('./LICENSE.md'))
2722
2730
  end
2723
2731
 
2724
2732
  def test_pull_request_template_exists
2725
- assert(File.file?('./.github/PULL_REQUEST_TEMPLATE'))
2733
+ assert(File.file?('./PULL_REQUEST_TEMPLATE.md'))
2726
2734
  end
2727
2735
 
2728
2736
  def test_readme_exists
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: 5.3.0
4
+ version: 6.0.4
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: 2018-10-12 00:00:00.000000000 Z
13
+ date: 2020-01-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: ruby_http_client
@@ -36,7 +36,7 @@ dependencies:
36
36
  - - "<"
37
37
  - !ruby/object:Gem::Version
38
38
  version: '3'
39
- type: :runtime
39
+ type: :development
40
40
  prerelease: false
41
41
  version_requirements: !ruby/object:Gem::Requirement
42
42
  requirements:
@@ -130,7 +130,8 @@ dependencies:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
132
  version: '5.9'
133
- description: Official SendGrid Gem to Interact with SendGrids API in native Ruby
133
+ description: Official Twilio SendGrid Gem to Interact with Twilio SendGrids API in
134
+ native Ruby
134
135
  email: dx@sendgrid.com
135
136
  executables: []
136
137
  extensions: []
@@ -138,18 +139,20 @@ extra_rdoc_files: []
138
139
  files:
139
140
  - ".codeclimate.yml"
140
141
  - ".env_sample"
141
- - ".github/ISSUE_TEMPLATE"
142
- - ".github/PULL_REQUEST_TEMPLATE"
143
142
  - ".gitignore"
144
143
  - ".travis.yml"
145
144
  - CHANGELOG.md
146
145
  - CODE_OF_CONDUCT.md
147
146
  - CONTRIBUTING.md
148
147
  - Gemfile
149
- - LICENSE.txt
148
+ - ISSUE_TEMPLATE.md
149
+ - LICENSE.md
150
+ - Makefile
151
+ - PULL_REQUEST_TEMPLATE.md
150
152
  - README.md
151
153
  - Rakefile
152
154
  - TROUBLESHOOTING.md
155
+ - UPGRADE.md
153
156
  - USAGE.md
154
157
  - USE_CASES.md
155
158
  - config.ru
@@ -175,6 +178,7 @@ files:
175
178
  - examples/mailsettings/mailsettings.rb
176
179
  - examples/partnersettings/partnersettings.rb
177
180
  - examples/scopes/scopes.rb
181
+ - examples/senderauthentication/senderauthentication.rb
178
182
  - examples/senders/senders.rb
179
183
  - examples/stats/stats.rb
180
184
  - examples/subusers/subusers.rb
@@ -182,7 +186,6 @@ files:
182
186
  - examples/templates/templates.rb
183
187
  - examples/trackingsettings/trackingsettings.rb
184
188
  - examples/user/user.rb
185
- - examples/whitelabel/whitelabel.rb
186
189
  - gemfiles/Sinatra_1.gemfile
187
190
  - gemfiles/Sinatra_2.gemfile
188
191
  - lib/sendgrid-ruby.rb
@@ -195,6 +198,7 @@ files:
195
198
  - lib/sendgrid/helpers/inbound/sample_data/raw_data.txt
196
199
  - lib/sendgrid/helpers/inbound/sample_data/raw_data_with_attachments.txt
197
200
  - lib/sendgrid/helpers/inbound/send.rb
201
+ - lib/sendgrid/helpers/ip_management/ip_management.rb
198
202
  - lib/sendgrid/helpers/mail/README.md
199
203
  - lib/sendgrid/helpers/mail/asm.rb
200
204
  - lib/sendgrid/helpers/mail/attachment.rb
@@ -217,6 +221,8 @@ files:
217
221
  - lib/sendgrid/helpers/mail/subscription_tracking.rb
218
222
  - lib/sendgrid/helpers/mail/substitution.rb
219
223
  - lib/sendgrid/helpers/mail/tracking_settings.rb
224
+ - lib/sendgrid/helpers/permissions/scope.rb
225
+ - lib/sendgrid/helpers/permissions/scopes.yml
220
226
  - lib/sendgrid/helpers/settings/README.md
221
227
  - lib/sendgrid/helpers/settings/mail_settings_dto.rb
222
228
  - lib/sendgrid/helpers/settings/partner_settings_dto.rb
@@ -229,6 +235,7 @@ files:
229
235
  - lib/sendgrid/version.rb
230
236
  - mail_helper_v3.md
231
237
  - sendgrid-ruby.gemspec
238
+ - spec/sendgrid/helpers/ip_management/ip_management_spec.rb
232
239
  - spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb
233
240
  - spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb
234
241
  - spec/sendgrid/helpers/settings/settings_spec.rb
@@ -239,10 +246,12 @@ files:
239
246
  - spec/sendgrid/helpers/stats/stats_response_spec.rb
240
247
  - spec/spec_helper.rb
241
248
  - test/prism.sh
249
+ - test/sendgrid/helpers/mail/test_attachment.rb
242
250
  - test/sendgrid/helpers/mail/test_category.rb
243
251
  - test/sendgrid/helpers/mail/test_email.rb
244
252
  - test/sendgrid/helpers/mail/test_mail.rb
245
253
  - test/sendgrid/helpers/mail/test_personalizations.rb
254
+ - test/sendgrid/permissions/test_scopes.rb
246
255
  - test/sendgrid/test_sendgrid-ruby.rb
247
256
  homepage: http://github.com/sendgrid/sendgrid-ruby
248
257
  licenses:
@@ -263,12 +272,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
272
  - !ruby/object:Gem::Version
264
273
  version: '0'
265
274
  requirements: []
266
- rubyforge_project:
267
- rubygems_version: 2.6.10
275
+ rubygems_version: 3.0.3
268
276
  signing_key:
269
277
  specification_version: 4
270
- summary: Official SendGrid Gem
278
+ summary: Official Twilio SendGrid Gem
271
279
  test_files:
280
+ - spec/sendgrid/helpers/ip_management/ip_management_spec.rb
272
281
  - spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb
273
282
  - spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb
274
283
  - spec/sendgrid/helpers/settings/settings_spec.rb
@@ -279,8 +288,10 @@ test_files:
279
288
  - spec/sendgrid/helpers/stats/stats_response_spec.rb
280
289
  - spec/spec_helper.rb
281
290
  - test/prism.sh
291
+ - test/sendgrid/helpers/mail/test_attachment.rb
282
292
  - test/sendgrid/helpers/mail/test_category.rb
283
293
  - test/sendgrid/helpers/mail/test_email.rb
284
294
  - test/sendgrid/helpers/mail/test_mail.rb
285
295
  - test/sendgrid/helpers/mail/test_personalizations.rb
296
+ - test/sendgrid/permissions/test_scopes.rb
286
297
  - test/sendgrid/test_sendgrid-ruby.rb
@@ -1,17 +0,0 @@
1
- #### Issue Summary
2
-
3
- A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, code examples.
4
-
5
-
6
- #### Steps to Reproduce
7
-
8
- 1. This is the first step
9
- 2. This is the second step
10
- 3. Further steps, etc.
11
-
12
- Any other information you want to share that is relevant to the issue being reported. Especially, why do you consider this to be a bug? What do you expect to happen instead?
13
-
14
- #### Technical details:
15
-
16
- * sendgrid-ruby Version: master (latest commit: [commit number])
17
- * Ruby Version: 2.2
@@ -1,24 +0,0 @@
1
- <!--
2
- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines given above, then fill out the blanks below.
3
-
4
-
5
- Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged!
6
- e.g.
7
- Fixes #1
8
- Closes #2
9
- -->
10
- # Fixes #
11
-
12
- ### Checklist
13
- - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
14
- - [ ] I have read the [Contribution Guide] and my PR follows them.
15
- - [ ] I updated my branch with the master branch.
16
- - [ ] I have added tests that prove my fix is effective or that my feature works
17
- - [ ] I have added necessary documentation about the functionality in the appropriate .md file
18
- - [ ] I have added in line documentation to the code I modified
19
-
20
- ### Short description of what this PR does:
21
- -
22
- -
23
-
24
- If you have questions, please send an email to [Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository.
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2014-2018 SendGrid, Inc.
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.