sendgrid-ruby 6.2.0 → 6.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/.github/ISSUE_TEMPLATE/config.yml +10 -0
  3. data/.github/workflows/test-and-deploy.yml +120 -0
  4. data/.gitignore +2 -0
  5. data/.rubocop.yml +8 -0
  6. data/.rubocop_todo.yml +127 -0
  7. data/CHANGELOG.md +147 -9
  8. data/CONTRIBUTING.md +11 -21
  9. data/Dockerfile +14 -0
  10. data/FIRST_TIMERS.md +79 -0
  11. data/Gemfile +0 -1
  12. data/ISSUE_TEMPLATE.md +5 -1
  13. data/{LICENSE.md → LICENSE} +1 -1
  14. data/Makefile +9 -2
  15. data/PULL_REQUEST_TEMPLATE.md +5 -5
  16. data/README.md +23 -31
  17. data/Rakefile +2 -3
  18. data/TROUBLESHOOTING.md +17 -5
  19. data/USAGE.md +146 -39
  20. data/examples/accesssettings/accesssettings.rb +9 -12
  21. data/examples/alerts/alerts.rb +8 -11
  22. data/examples/apikeys/apikeys.rb +12 -15
  23. data/examples/asm/asm.rb +27 -30
  24. data/examples/browsers/browsers.rb +0 -3
  25. data/examples/campaigns/campaigns.rb +29 -32
  26. data/examples/categories/categories.rb +0 -3
  27. data/examples/clients/clients.rb +1 -4
  28. data/examples/contactdb/contactdb.rb +63 -66
  29. data/examples/devices/devices.rb +0 -3
  30. data/examples/emailactivity/emailactivity.rb +52 -0
  31. data/examples/geo/geo.rb +0 -3
  32. data/examples/helpers/eventwebhook/example.rb +16 -0
  33. data/examples/helpers/mail/example.rb +24 -13
  34. data/examples/helpers/settings/example.rb +1 -1
  35. data/examples/helpers/stats/example.rb +4 -4
  36. data/examples/ips/ips.rb +19 -22
  37. data/examples/mail/mail.rb +72 -75
  38. data/examples/mailboxproviders/mailboxproviders.rb +0 -3
  39. data/examples/mailsettings/mailsettings.rb +21 -24
  40. data/examples/partnersettings/partnersettings.rb +3 -6
  41. data/examples/scopes/scopes.rb +8 -10
  42. data/examples/senderauthentication/senderauthentication.rb +41 -44
  43. data/examples/senders/senders.rb +28 -31
  44. data/examples/stats/stats.rb +0 -3
  45. data/examples/subusers/subusers.rb +17 -20
  46. data/examples/suppression/suppression.rb +15 -18
  47. data/examples/templates/templates.rb +29 -31
  48. data/examples/trackingsettings/trackingsettings.rb +14 -17
  49. data/examples/user/user.rb +41 -44
  50. data/lib/rack/sendgrid_webhook_verification.rb +55 -0
  51. data/lib/sendgrid/base_interface.rb +8 -4
  52. data/lib/sendgrid/helpers/eventwebhook/eventwebhook.rb +50 -0
  53. data/lib/sendgrid/helpers/inbound/README.md +5 -5
  54. data/lib/sendgrid/helpers/inbound/app.rb +2 -2
  55. data/lib/sendgrid/helpers/inbound/public/index.html +1 -1
  56. data/lib/sendgrid/helpers/inbound/send.rb +3 -3
  57. data/lib/sendgrid/helpers/ip_management/ip_management.rb +1 -1
  58. data/lib/sendgrid/helpers/mail/README.md +3 -3
  59. data/lib/sendgrid/helpers/mail/asm.rb +6 -18
  60. data/lib/sendgrid/helpers/mail/attachment.rb +12 -42
  61. data/lib/sendgrid/helpers/mail/bcc_settings.rb +6 -18
  62. data/lib/sendgrid/helpers/mail/bypass_list_management.rb +8 -18
  63. data/lib/sendgrid/helpers/mail/category.rb +2 -2
  64. data/lib/sendgrid/helpers/mail/click_tracking.rb +6 -18
  65. data/lib/sendgrid/helpers/mail/content.rb +4 -3
  66. data/lib/sendgrid/helpers/mail/custom_arg.rb +6 -10
  67. data/lib/sendgrid/helpers/mail/email.rb +10 -5
  68. data/lib/sendgrid/helpers/mail/footer.rb +7 -27
  69. data/lib/sendgrid/helpers/mail/ganalytics.rb +10 -54
  70. data/lib/sendgrid/helpers/mail/header.rb +6 -10
  71. data/lib/sendgrid/helpers/mail/mail.rb +32 -48
  72. data/lib/sendgrid/helpers/mail/mail_settings.rb +9 -25
  73. data/lib/sendgrid/helpers/mail/open_tracking.rb +6 -18
  74. data/lib/sendgrid/helpers/mail/personalization.rb +40 -27
  75. data/lib/sendgrid/helpers/mail/section.rb +6 -10
  76. data/lib/sendgrid/helpers/mail/spam_check.rb +7 -27
  77. data/lib/sendgrid/helpers/mail/subscription_tracking.rb +8 -36
  78. data/lib/sendgrid/helpers/mail/substitution.rb +6 -10
  79. data/lib/sendgrid/helpers/mail/tracking_settings.rb +8 -20
  80. data/lib/sendgrid/helpers/permissions/scope.rb +2 -2
  81. data/lib/sendgrid/helpers/settings/README.md +2 -2
  82. data/lib/sendgrid/helpers/settings/settings.rb +1 -1
  83. data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +3 -5
  84. data/lib/sendgrid/helpers/stats/metrics.rb +5 -5
  85. data/lib/sendgrid/sendgrid.rb +4 -3
  86. data/lib/sendgrid/twilio_email.rb +1 -1
  87. data/lib/sendgrid/version.rb +1 -1
  88. data/lib/sendgrid-ruby.rb +2 -0
  89. data/mail_helper_v3.md +12 -12
  90. data/sendgrid-ruby.gemspec +8 -8
  91. data/spec/fixtures/event_webhook.rb +22 -0
  92. data/spec/rack/sendgrid_webhook_verification_spec.rb +142 -0
  93. data/spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb +105 -0
  94. data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +3 -3
  95. data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +3 -3
  96. data/spec/sendgrid/helpers/settings/settings_spec.rb +2 -2
  97. data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +3 -3
  98. data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +3 -3
  99. data/spec/sendgrid/helpers/stats/email_stats_spec.rb +22 -23
  100. data/spec/sendgrid/helpers/stats/metrics_spec.rb +19 -20
  101. data/spec/sendgrid/helpers/stats/stats_response_spec.rb +22 -23
  102. data/spec/spec_helper.rb +3 -1
  103. data/static/img/github-fork.png +0 -0
  104. data/static/img/github-sign-up.png +0 -0
  105. data/test/sendgrid/helpers/mail/test_attachment.rb +4 -6
  106. data/test/sendgrid/helpers/mail/test_category.rb +0 -2
  107. data/test/sendgrid/helpers/mail/test_email.rb +17 -10
  108. data/test/sendgrid/helpers/mail/test_mail.rb +101 -102
  109. data/test/sendgrid/helpers/mail/test_personalizations.rb +145 -92
  110. data/test/sendgrid/permissions/test_scopes.rb +1 -3
  111. data/test/sendgrid/test_sendgrid-ruby.rb +1964 -1986
  112. data/twilio_sendgrid_logo.png +0 -0
  113. data/use-cases/README.md +17 -0
  114. data/use-cases/domain-authentication.md +5 -0
  115. data/use-cases/email-statistics.md +52 -0
  116. data/use-cases/legacy-templates.md +98 -0
  117. data/use-cases/personalizations.md +34 -0
  118. data/use-cases/sms.md +39 -0
  119. data/use-cases/transactional-templates.md +111 -0
  120. data/use-cases/twilio-email.md +13 -0
  121. data/use-cases/twilio-setup.md +54 -0
  122. metadata +69 -34
  123. data/.codeclimate.yml +0 -21
  124. data/.travis.yml +0 -40
  125. data/USE_CASES.md +0 -405
  126. data/docker/Dockerfile +0 -12
  127. data/docker/README.md +0 -30
  128. data/test/prism.sh +0 -42
data/FIRST_TIMERS.md ADDED
@@ -0,0 +1,79 @@
1
+ # How To Contribute to Twilio SendGrid Repositories via GitHub
2
+ Contributing to the Twilio SendGrid repositories is easy! All you need to do is find an open issue (see the bottom of this page for a list of repositories containing open issues), fix it and submit a pull request. Once you have submitted your pull request, the team can easily review it before it is merged into the repository.
3
+
4
+ To make a pull request, follow these steps:
5
+
6
+ 1. Log into GitHub. If you do not already have a GitHub account, you will have to create one in order to submit a change. Click the Sign up link in the upper right-hand corner to create an account. Enter your username, password, and email address. If you are an employee of Twilio SendGrid, please use your full name with your GitHub account and enter Twilio SendGrid as your company so we can easily identify you.
7
+
8
+ <img src="/static/img/github-sign-up.png" width="800">
9
+
10
+ 2. __[Fork](https://help.github.com/fork-a-repo/)__ the [sendgrid-ruby](https://github.com/sendgrid/sendgrid-ruby) repository:
11
+
12
+ <img src="/static/img/github-fork.png" width="800">
13
+
14
+ 3. __Clone__ your fork via the following commands:
15
+
16
+ ```bash
17
+ # Clone your fork of the repo into the current directory
18
+ git clone https://github.com/your_username/sendgrid-ruby
19
+ # Navigate to the newly cloned directory
20
+ cd sendgrid-ruby
21
+ # Assign the original repo to a remote called "upstream"
22
+ git remote add upstream https://github.com/sendgrid/sendgrid-ruby
23
+ ```
24
+
25
+ > Don't forget to replace *your_username* in the URL by your real GitHub username.
26
+
27
+ 4. __Create a new topic branch__ (off the main project development branch) to contain your feature, change, or fix:
28
+
29
+ ```bash
30
+ git checkout -b <topic-branch-name>
31
+ ```
32
+
33
+ 5. __Commit your changes__ in logical chunks.
34
+
35
+ Please adhere to these [git commit message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) or your code is unlikely be merged into the main project. Use Git's [interactive rebase](https://help.github.com/articles/interactive-rebase) feature to tidy up your commits before making them public. Probably you will also have to create tests (if needed) or create or update the example code that demonstrates the functionality of this change to the code.
36
+
37
+ 6. __Locally merge (or rebase)__ the upstream development branch into your topic branch:
38
+
39
+ ```bash
40
+ git pull [--rebase] upstream main
41
+ ```
42
+
43
+ 7. __Push__ your topic branch up to your fork:
44
+
45
+ ```bash
46
+ git push origin <topic-branch-name>
47
+ ```
48
+
49
+ 8. __[Open a Pull Request](https://help.github.com/articles/creating-a-pull-request/#changing-the-branch-range-and-destination-repository/)__ with a clear title and description against the `main` branch. All tests must be passing before we will review the PR.
50
+
51
+ ## Important notice
52
+
53
+ Before creating a pull request, make sure that you respect the repository's constraints regarding contributions. You can find them in the [CONTRIBUTING.md](CONTRIBUTING.md) file.
54
+
55
+ ## Repositories with Open, Easy, Help Wanted, Issue Filters
56
+
57
+ * [Python SDK](https://github.com/sendgrid/sendgrid-python/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
58
+ * [PHP SDK](https://github.com/sendgrid/sendgrid-php/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
59
+ * [C# SDK](https://github.com/sendgrid/sendgrid-csharp/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
60
+ * [Ruby SDK](https://github.com/sendgrid/sendgrid-ruby/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
61
+ * [Node.js SDK](https://github.com/sendgrid/sendgrid-nodejs/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
62
+ * [Java SDK](https://github.com/sendgrid/sendgrid-java/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
63
+ * [Go SDK](https://github.com/sendgrid/sendgrid-go/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
64
+ * [Python SMTPAPI Client](https://github.com/sendgrid/smtpapi-python/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
65
+ * [PHP SMTPAPI Client](https://github.com/sendgrid/smtpapi-php/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
66
+ * [C# SMTPAPI Client](https://github.com/sendgrid/smtpapi-csharp/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
67
+ * [Ruby SMTPAPI Client](https://github.com/sendgrid/smtpapi-ruby/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
68
+ * [Node.js SMTPAPI Client](https://github.com/sendgrid/smtpapi-nodejs/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
69
+ * [Java SMTPAPI Client](https://github.com/sendgrid/smtpapi-java/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
70
+ * [Go SMTPAPI Client](https://github.com/sendgrid/smtpapi-go/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
71
+ * [Python HTTP Client](https://github.com/sendgrid/python-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
72
+ * [PHP HTTP Client](https://github.com/sendgrid/php-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
73
+ * [C# HTTP Client](https://github.com/sendgrid/csharp-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
74
+ * [Java HTTP Client](https://github.com/sendgrid/java-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
75
+ * [Ruby HTTP Client](https://github.com/sendgrid/ruby-http-client/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
76
+ * [Go HTTP Client](https://github.com/sendgrid/rest/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
77
+ * [Open API Definition](https://github.com/sendgrid/sendgrid-oai/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
78
+ * [DX Automator](https://github.com/sendgrid/dx-automator/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
79
+ * [Documentation](https://github.com/sendgrid/docs/issues?utf8=%E2%9C%93&q=is%3Aopen+label%3A%22difficulty%3A+easy%22+label%3A%22status%3A+help+wanted%22)
data/Gemfile CHANGED
@@ -3,4 +3,3 @@ source 'http://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'ruby_http_client'
6
-
data/ISSUE_TEMPLATE.md CHANGED
@@ -1,5 +1,9 @@
1
1
  <!--
2
2
  If this is a feature request, make sure you search Issues for an existing request before creating a new one!
3
+
4
+ Please utilize the template below to help us resolve your issue.
5
+
6
+ Note that many issues can be resolved by updating to the latest version.
3
7
  -->
4
8
 
5
9
  ### Issue Summary
@@ -21,6 +25,6 @@ A summary of the issue and the environment in which it occurs. If suitable, incl
21
25
  ```
22
26
 
23
27
  ### Technical details:
24
- * sendgrid-ruby version:
28
+ * sendgrid-ruby version:
25
29
  * ruby version:
26
30
 
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (C) 2020, Twilio SendGrid, Inc. <help@twilio.com>
3
+ Copyright (C) 2022, Twilio SendGrid, Inc. <help@twilio.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy of
6
6
  this software and associated documentation files (the "Software"), to deal in
data/Makefile CHANGED
@@ -1,7 +1,14 @@
1
- .PHONY: install test
1
+ .PHONY: install test test-integ test-docker
2
2
 
3
3
  install:
4
4
  gem install bundler:2.1.2; bundle install
5
5
 
6
6
  test:
7
- bundle exec rake spec
7
+ bundle exec rake
8
+
9
+ test-integ: test
10
+
11
+ version ?= ruby:latest
12
+ test-docker:
13
+ curl -s https://raw.githubusercontent.com/sendgrid/sendgrid-oai/HEAD/prism/prism.sh -o prism.sh
14
+ version=$(version) bash ./prism.sh
@@ -19,13 +19,13 @@ Closes #2
19
19
  A short description of what this PR does.
20
20
 
21
21
  ### Checklist
22
- - [ ] I acknowledge that all my contributions will be made under the project's license
22
+ - [x] I acknowledge that all my contributions will be made under the project's license
23
23
  - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
24
- - [ ] I have read the [Contribution Guidelines](CONTRIBUTING.md) and my PR follows them
24
+ - [ ] I have read the [Contribution Guidelines](https://github.com/sendgrid/sendgrid-ruby/blob/main/CONTRIBUTING.md) and my PR follows them
25
25
  - [ ] I have titled the PR appropriately
26
- - [ ] I have updated my branch with the master branch
26
+ - [ ] I have updated my branch with the main branch
27
27
  - [ ] I have added tests that prove my fix is effective or that my feature works
28
- - [ ] I have added necessary documentation about the functionality in the appropriate .md file
28
+ - [ ] I have added the necessary documentation about the functionality in the appropriate .md file
29
29
  - [ ] I have added inline documentation to the code I modified
30
30
 
31
- If you have questions, please file a [support ticket](https://twilio.com/help/contact), or create a GitHub Issue in this repository.
31
+ If you have questions, please file a [support ticket](https://support.sendgrid.com), or create a GitHub Issue in this repository.
data/README.md CHANGED
@@ -1,20 +1,19 @@
1
- ![Twilio SendGrid Logo](https://github.com/sendgrid/sendgrid-python/raw/master/twilio_sendgrid_logo.png)
1
+ ![Twilio SendGrid Logo](twilio_sendgrid_logo.png)
2
2
 
3
- [![Travis Badge](https://travis-ci.org/sendgrid/sendgrid-ruby.svg?branch=master)](https://travis-ci.org/sendgrid/sendgrid-ruby)
3
+ [![Travis Badge](https://github.com/sendgrid/sendgrid-ruby/actions/workflows/test-and-deploy.yml/badge.svg)](https://github.com/sendgrid/sendgrid-ruby/actions/workflows/test-and-deploy.yml)
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
- [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md)
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)
9
8
  [![Open Source Helpers](https://www.codetriage.com/sendgrid/sendgrid-ruby/badges/users.svg)](https://www.codetriage.com/sendgrid/sendgrid-ruby)
10
9
 
11
- **NEW:** Subscribe to email [notifications](https://dx.sendgrid.com/newsletter/ruby) for releases and breaking changes.
10
+ **The default branch name for this repository has been changed to `main` as of 07/27/2020.**
12
11
 
13
12
  **This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via Ruby.**
14
13
 
15
14
  Version 3.X.X+ of this library provides full support for all Twilio SendGrid [Web API v3](https://sendgrid.com/docs/API_Reference/Web_API_v3/index.html) endpoints, including the new [v3 /mail/send](https://sendgrid.com/blog/introducing-v3mailsend-sendgrids-new-mail-endpoint).
16
15
 
17
- This library represents the beginning of a new path for Twilio SendGrid. We want this library to be community driven and Twilio SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-ruby/issues) and [pull requests](https://github.com/sendgrid/sendgrid-ruby/blob/master/CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests.
16
+ This library represents the beginning of a new path for Twilio SendGrid. We want this library to be community driven and Twilio SendGrid led. We need your help to realize this goal. To help make sure we are building the right things in the right order, we ask that you create [issues](https://github.com/sendgrid/sendgrid-ruby/issues) and [pull requests](CONTRIBUTING.md) or simply upvote or comment on existing issues or pull requests.
18
17
 
19
18
  Please browse the rest of this README for further details.
20
19
 
@@ -29,7 +28,6 @@ We appreciate your continued support, thank you!
29
28
  * [Usage](#usage)
30
29
  * [Use Cases](#use_cases)
31
30
  * [Announcements](#announcements)
32
- * [Roadmap](#roadmap)
33
31
  * [How to Contribute](#contribute)
34
32
  * [Troubleshooting](#troubleshooting)
35
33
  * [About](#about)
@@ -40,7 +38,7 @@ We appreciate your continued support, thank you!
40
38
 
41
39
  ## Prerequisites
42
40
 
43
- - Ruby version >= 2.4 (except version [2.6.0](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md#ruby-versions))
41
+ - Ruby version >= 2.4 (except version [2.6.0](TROUBLESHOOTING.md#ruby-versions))
44
42
  - The Twilio SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-ruby)
45
43
 
46
44
  ## Setup Environment Variables
@@ -81,7 +79,7 @@ gem install sendgrid-ruby
81
79
 
82
80
  ## Hello Email
83
81
 
84
- The following is the minimum needed code to send an email with the [/mail/send Helper](https://github.com/sendgrid/sendgrid-ruby/tree/master/lib/sendgrid/helpers/mail) ([here](https://github.com/sendgrid/sendgrid-ruby/blob/master/examples/helpers/mail/example.rb#L21) is a full example):
82
+ The following is the minimum needed code to send an email with the [/mail/send Helper](lib/sendgrid/helpers/mail) ([here](examples/helpers/mail/example.rb#L21) is a full example):
85
83
 
86
84
  ### With Mail Helper Class
87
85
 
@@ -103,11 +101,11 @@ puts response.parsed_body
103
101
  puts response.headers
104
102
  ```
105
103
 
106
- For more complex scenarios, please do not use the above constructor and instead build your own personalization object as [demonstrated here](https://github.com/sendgrid/sendgrid-ruby/blob/master/examples/helpers/mail/example.rb#L21).
104
+ For more complex scenarios, please do not use the above constructor and instead build your own personalization object as [demonstrated here](examples/helpers/mail/example.rb#L21).
107
105
 
108
106
  ### Without Mail Helper Class
109
107
 
110
- The following is the minimum needed code to send an email without the /mail/send Helper ([here](https://github.com/sendgrid/sendgrid-ruby/blob/master/examples/mail/mail.rb#L26) is a full example):
108
+ The following is the minimum needed code to send an email without the /mail/send Helper ([here](examples/mail/mail.rb#L26) is a full example):
111
109
 
112
110
  ```ruby
113
111
  require 'sendgrid-ruby'
@@ -169,50 +167,44 @@ puts response.headers
169
167
  <a name="inbound"></a>
170
168
  # Processing Inbound Email
171
169
 
172
- Please see [our helper](https://github.com/sendgrid/sendgrid-ruby/tree/master/lib/sendgrid/helpers/inbound) for utilizing our Inbound Parse webhook.
170
+ Please see [our helper](lib/sendgrid/helpers/inbound) for utilizing our Inbound Parse webhook.
173
171
 
174
172
  <a name="usage"></a>
175
173
  # Usage
176
174
 
177
175
  - [Twilio SendGrid Docs](https://sendgrid.com/docs/API_Reference/index.html)
178
- - [Library Usage Docs](https://github.com/sendgrid/sendgrid-ruby/tree/master/USAGE.md)
179
- - [Example Code](https://github.com/sendgrid/sendgrid-ruby/tree/master/examples)
176
+ - [Library Usage Docs](USAGE.md)
177
+ - [Example Code](examples)
180
178
  - [How-to: Migration from v2 to v3](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html)
181
- - [v3 Web API Mail Send Helper](https://github.com/sendgrid/sendgrid-ruby/tree/master/lib/sendgrid/helpers/mail) - build a request object payload for a v3 /mail/send API call.
182
- - [Settings Helper](https://github.com/sendgrid/sendgrid-ruby/tree/master/lib/sendgrid/helpers/settings)
179
+ - [v3 Web API Mail Send Helper](lib/sendgrid/helpers/mail) - build a request object payload for a v3 /mail/send API call.
180
+ - [Settings Helper](lib/sendgrid/helpers/settings)
183
181
 
184
182
  <a name="use_cases"></a>
185
183
  # Use Cases
186
184
 
187
- [Examples of common API use cases](https://github.com/sendgrid/sendgrid-ruby/blob/master/USE_CASES.md), such as how to send an email with a transactional template.
185
+ [Examples of common API use cases](use-cases), such as how to send an email with a transactional template.
188
186
 
189
187
  <a name="announcements"></a>
190
188
  # Announcements
191
189
 
192
190
  Please see our announcement regarding [breaking changes](https://github.com/sendgrid/sendgrid-ruby/issues/94). Your support is appreciated!
193
191
 
194
- All updates to this library are documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-ruby/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-ruby/releases). You may also subscribe to email [release notifications](https://dx.sendgrid.com/newsletter/ruby) for releases and breaking changes.
195
-
196
- <a name="roadmap"></a>
197
- # Roadmap
198
-
199
- If you are interested in the future direction of this project, please take a look at our open [issues](https://github.com/sendgrid/sendgrid-ruby/issues) and [pull requests](https://github.com/sendgrid/sendgrid-ruby/pulls). We would love to hear your feedback.
192
+ All updates to this library are documented in our [CHANGELOG](CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-ruby/releases). You may also subscribe to email [release notifications](https://dx.sendgrid.com/newsletter/ruby) for releases and breaking changes.
200
193
 
201
194
  <a name="contribute"></a>
202
195
  # How to Contribute
203
196
 
204
- We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md) guide for details.
197
+ We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](CONTRIBUTING.md) guide for details.
205
198
 
206
- - [Feature Request](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#feature_request)
207
- - [Bug Reports](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#submit_a_bug_report)
208
- - [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#cla)
209
- - [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#improvements_to_the_codebase)
210
- - [Review Pull Requests](https://github.com/sendgrid/sendgrid-ruby/blob/master/CONTRIBUTING.md#code-reviews)
199
+ - [Feature Request](CONTRIBUTING.md#feature_request)
200
+ - [Bug Reports](CONTRIBUTING.md#submit_a_bug_report)
201
+ - [Improvements to the Codebase](CONTRIBUTING.md#improvements_to_the_codebase)
202
+ - [Review Pull Requests](CONTRIBUTING.md#code-reviews)
211
203
 
212
204
  <a name="troubleshooting"></a>
213
205
  # Troubleshooting
214
206
 
215
- Please see our [troubleshooting guide](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md) for common library issues.
207
+ Please see our [troubleshooting guide](TROUBLESHOOTING.md) for common library issues.
216
208
 
217
209
  <a name="about"></a>
218
210
  # About
@@ -225,4 +217,4 @@ If you've instead found a bug in the library or would like new features added, g
225
217
 
226
218
  <a name="license"></a>
227
219
  # License
228
- [The MIT License (MIT)](LICENSE.md)
220
+ [The MIT License (MIT)](LICENSE)
data/Rakefile CHANGED
@@ -10,6 +10,5 @@ end
10
10
 
11
11
  RSpec::Core::RakeTask.new(:spec)
12
12
 
13
- desc "Run tests"
14
- task default: [:spec, :test]
15
-
13
+ desc 'Run tests'
14
+ task default: %i[spec test]
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
@@ -28,7 +29,7 @@ Please review [our guide](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/
28
29
 
29
30
  [Here](https://github.com/sendgrid/sendgrid-ruby/tree/0fbf579c0f7ed1dff87adc4957c4dc5a6b257068) is the last working version with v2 support.
30
31
 
31
- Using rubygems:
32
+ Using RubyGems:
32
33
 
33
34
  Add this line to your application's Gemfile:
34
35
 
@@ -73,7 +74,7 @@ end
73
74
  <a name="versioning"></a>
74
75
  ## Versioning
75
76
 
76
- We follow the MAJOR.MINOR.PATCH versioning scheme as described by [SemVer.org](http://semver.org). Therefore, we recommend that you always pin (or vendor) the particular version you are working with to your code and never auto-update to the latest version. Especially when there is a MAJOR point release, since that is guaranteed to be a breaking change. Changes are documented in the [CHANGELOG](https://github.com/sendgrid/sendgrid-ruby/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-ruby/releases) section.
77
+ We follow the MAJOR.MINOR.PATCH versioning scheme as described by [SemVer.org](http://semver.org). Therefore, we recommend that you always pin (or vendor) the particular version you are working with your code and never auto-update to the latest version. Especially when there is a MAJOR point release since that is guaranteed to be a breaking change. Changes are documented in the [CHANGELOG](CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-ruby/releases) section.
77
78
 
78
79
  <a name="environment"></a>
79
80
  ## Environment Variables and Your Twilio SendGrid API Key
@@ -88,7 +89,7 @@ becomes
88
89
 
89
90
  `sg = SendGrid::API.new(api_key: 'SENDGRID_API_KEY')`
90
91
 
91
- In the first case SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual Twilio SendGrid API Key.
92
+ In the first case, SENDGRID_API_KEY is in reference to the name of the environment variable, while the second case references the actual Twilio SendGrid API Key.
92
93
 
93
94
  <a name="package-manager"></a>
94
95
  ## Using the Package Manager
@@ -118,9 +119,9 @@ gem install sendgrid-ruby -v X.X.X
118
119
  <a name="rails-specifics"></a>
119
120
  ## Rails Specifics
120
121
 
121
- - Namespace collision between Rails own `Mail` class and sendgrid class `Mail`. To avoid that issues please use `SendGrid::Mail` instead.
122
+ - Namespace collision between Rails own `Mail` class and sendgrid class `Mail`. To avoid that issues please use `SendGrid:: Mail` instead.
122
123
 
123
- - Possibility of a namespace collision between the sendgrid class `Email` and your own defined `Email` class. To avoid these issues, you can skip the `include SendGrid` line and use the `SendGrid::` prefix for Email. Please see this [SO answer](https://stackoverflow.com/questions/41508464/rails-model-name-conflict-with-included-gem?noredirect=1#comment70223099_41508464) for specifics.
124
+ - The possibility of a namespace collision between the sendgrid class `Email` and your own defined `Email` class. To avoid these issues, you can skip the `include SendGrid` line and use the `SendGrid::` prefix for Email. Please see this [SO answer](https://stackoverflow.com/questions/41508464/rails-model-name-conflict-with-included-gem?noredirect=1#comment70223099_41508464) for specifics.
124
125
 
125
126
  <a name="ruby-versions"></a>
126
127
  ## Ruby Versions
@@ -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