sendgrid-ruby 5.3.0 → 6.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (143) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/pr-lint.yml +15 -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 +261 -8
  8. data/CODE_OF_CONDUCT.md +57 -25
  9. data/CONTRIBUTING.md +24 -71
  10. data/Dockerfile +14 -0
  11. data/FIRST_TIMERS.md +53 -0
  12. data/Gemfile +0 -1
  13. data/LICENSE +21 -0
  14. data/Makefile +14 -0
  15. data/PULL_REQUEST_TEMPLATE.md +31 -0
  16. data/README.md +39 -43
  17. data/Rakefile +3 -4
  18. data/TROUBLESHOOTING.md +41 -21
  19. data/UPGRADE.md +5 -0
  20. data/USAGE.md +1231 -1122
  21. data/examples/accesssettings/accesssettings.rb +9 -12
  22. data/examples/alerts/alerts.rb +8 -11
  23. data/examples/apikeys/apikeys.rb +12 -15
  24. data/examples/asm/asm.rb +27 -30
  25. data/examples/browsers/browsers.rb +0 -3
  26. data/examples/campaigns/campaigns.rb +29 -32
  27. data/examples/categories/categories.rb +0 -3
  28. data/examples/clients/clients.rb +1 -4
  29. data/examples/contactdb/contactdb.rb +63 -66
  30. data/examples/dataresidency/setregion.rb +48 -0
  31. data/examples/devices/devices.rb +0 -3
  32. data/examples/emailactivity/emailactivity.rb +52 -0
  33. data/examples/geo/geo.rb +0 -3
  34. data/examples/helpers/eventwebhook/example.rb +16 -0
  35. data/examples/helpers/mail/example.rb +30 -19
  36. data/examples/helpers/settings/example.rb +1 -1
  37. data/examples/helpers/stats/example.rb +4 -4
  38. data/examples/ips/ips.rb +31 -21
  39. data/examples/mail/mail.rb +73 -76
  40. data/examples/mailboxproviders/mailboxproviders.rb +0 -3
  41. data/examples/mailsettings/mailsettings.rb +21 -24
  42. data/examples/partnersettings/partnersettings.rb +3 -6
  43. data/examples/scopes/scopes.rb +49 -5
  44. data/examples/{whitelabel/whitelabel.rb → senderauthentication/senderauthentication.rb} +68 -71
  45. data/examples/senders/senders.rb +28 -31
  46. data/examples/stats/stats.rb +0 -3
  47. data/examples/subusers/subusers.rb +17 -20
  48. data/examples/suppression/suppression.rb +23 -26
  49. data/examples/templates/templates.rb +29 -31
  50. data/examples/trackingsettings/trackingsettings.rb +14 -17
  51. data/examples/user/user.rb +41 -44
  52. data/lib/rack/sendgrid_webhook_verification.rb +55 -0
  53. data/lib/sendgrid/base_interface.rb +57 -0
  54. data/lib/sendgrid/helpers/eventwebhook/eventwebhook.rb +50 -0
  55. data/lib/sendgrid/helpers/inbound/README.md +26 -9
  56. data/lib/sendgrid/helpers/inbound/app.rb +15 -3
  57. data/lib/sendgrid/helpers/inbound/public/index.html +2 -2
  58. data/lib/sendgrid/helpers/inbound/sample_data/default_data.txt +2 -2
  59. data/lib/sendgrid/helpers/inbound/sample_data/raw_data.txt +2 -2
  60. data/lib/sendgrid/helpers/inbound/sample_data/raw_data_with_attachments.txt +2 -2
  61. data/lib/sendgrid/helpers/inbound/send.rb +5 -5
  62. data/lib/sendgrid/helpers/ip_management/ip_management.rb +17 -0
  63. data/lib/sendgrid/helpers/mail/README.md +4 -4
  64. data/lib/sendgrid/helpers/mail/asm.rb +4 -18
  65. data/lib/sendgrid/helpers/mail/attachment.rb +30 -38
  66. data/lib/sendgrid/helpers/mail/bcc_settings.rb +4 -18
  67. data/lib/sendgrid/helpers/mail/bypass_list_management.rb +6 -18
  68. data/lib/sendgrid/helpers/mail/category.rb +2 -12
  69. data/lib/sendgrid/helpers/mail/click_tracking.rb +4 -18
  70. data/lib/sendgrid/helpers/mail/content.rb +4 -18
  71. data/lib/sendgrid/helpers/mail/custom_arg.rb +4 -10
  72. data/lib/sendgrid/helpers/mail/email.rb +10 -20
  73. data/lib/sendgrid/helpers/mail/footer.rb +5 -27
  74. data/lib/sendgrid/helpers/mail/ganalytics.rb +9 -55
  75. data/lib/sendgrid/helpers/mail/header.rb +4 -10
  76. data/lib/sendgrid/helpers/mail/mail.rb +37 -87
  77. data/lib/sendgrid/helpers/mail/mail_settings.rb +7 -25
  78. data/lib/sendgrid/helpers/mail/open_tracking.rb +4 -18
  79. data/lib/sendgrid/helpers/mail/personalization.rb +38 -27
  80. data/lib/sendgrid/helpers/mail/section.rb +4 -10
  81. data/lib/sendgrid/helpers/mail/spam_check.rb +5 -27
  82. data/lib/sendgrid/helpers/mail/subscription_tracking.rb +6 -36
  83. data/lib/sendgrid/helpers/mail/substitution.rb +4 -10
  84. data/lib/sendgrid/helpers/mail/tracking_settings.rb +6 -20
  85. data/lib/sendgrid/helpers/permissions/scope.rb +28 -0
  86. data/lib/sendgrid/helpers/permissions/scopes.yml +309 -0
  87. data/lib/sendgrid/helpers/settings/README.md +3 -3
  88. data/lib/sendgrid/helpers/settings/settings.rb +1 -1
  89. data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +3 -5
  90. data/lib/sendgrid/helpers/stats/metrics.rb +5 -7
  91. data/lib/sendgrid/helpers/stats/stats_response.rb +1 -3
  92. data/lib/sendgrid/sendgrid.rb +21 -0
  93. data/lib/sendgrid/twilio_email.rb +21 -0
  94. data/lib/sendgrid/version.rb +1 -1
  95. data/lib/sendgrid-ruby.rb +7 -1
  96. data/mail_helper_v3.md +21 -21
  97. data/sendgrid-ruby.gemspec +12 -12
  98. data/spec/fixtures/event_webhook.rb +22 -0
  99. data/spec/rack/sendgrid_webhook_verification_spec.rb +142 -0
  100. data/spec/sendgrid/helpers/eventwebhook/eventwebhook_spec.rb +105 -0
  101. data/spec/sendgrid/helpers/ip_management/ip_management_spec.rb +12 -0
  102. data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +3 -3
  103. data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +3 -3
  104. data/spec/sendgrid/helpers/settings/settings_spec.rb +2 -2
  105. data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +3 -3
  106. data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +3 -3
  107. data/spec/sendgrid/helpers/stats/email_stats_spec.rb +22 -23
  108. data/spec/sendgrid/helpers/stats/metrics_spec.rb +19 -20
  109. data/spec/sendgrid/helpers/stats/stats_response_spec.rb +22 -23
  110. data/spec/sendgrid/sendgrid_spec.rb +11 -0
  111. data/spec/sendgrid/twilio_email_spec.rb +11 -0
  112. data/spec/spec_helper.rb +3 -1
  113. data/static/img/github-fork.png +0 -0
  114. data/static/img/github-sign-up.png +0 -0
  115. data/test/sendgrid/helpers/mail/test_attachment.rb +33 -0
  116. data/test/sendgrid/helpers/mail/test_category.rb +0 -2
  117. data/test/sendgrid/helpers/mail/test_data_residency.rb +44 -0
  118. data/test/sendgrid/helpers/mail/test_email.rb +17 -10
  119. data/test/sendgrid/helpers/mail/test_mail.rb +126 -119
  120. data/test/sendgrid/helpers/mail/test_personalizations.rb +145 -92
  121. data/test/sendgrid/permissions/test_scopes.rb +36 -0
  122. data/test/sendgrid/test_sendgrid-ruby.rb +1961 -1979
  123. data/twilio_sendgrid_logo.png +0 -0
  124. data/use-cases/README.md +17 -0
  125. data/use-cases/domain-authentication.md +5 -0
  126. data/use-cases/email-statistics.md +52 -0
  127. data/use-cases/legacy-templates.md +98 -0
  128. data/use-cases/personalizations.md +34 -0
  129. data/use-cases/sms.md +39 -0
  130. data/use-cases/transactional-templates.md +111 -0
  131. data/use-cases/twilio-email.md +13 -0
  132. data/use-cases/twilio-setup.md +54 -0
  133. metadata +99 -45
  134. data/.codeclimate.yml +0 -21
  135. data/.github/ISSUE_TEMPLATE +0 -17
  136. data/.github/PULL_REQUEST_TEMPLATE +0 -24
  137. data/.travis.yml +0 -29
  138. data/LICENSE.txt +0 -22
  139. data/USE_CASES.md +0 -147
  140. data/docker/Dockerfile +0 -12
  141. data/docker/README.md +0 -30
  142. data/lib/sendgrid/client.rb +0 -35
  143. data/test/prism.sh +0 -42
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,41 +1,73 @@
1
- # SendGrid Community Code of Conduct
1
+ # Contributor Covenant Code of Conduct
2
2
 
3
- The SendGrid open source community is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences successes and continued growth. When you're working with members of the community, we encourage you to follow these guidelines, which help steer our interactions and strive to maintain a positive, successful and growing community.
3
+ ## Our Pledge
4
4
 
5
- ### Be Open
6
- Members of the community are open to collaboration, whether it's on pull requests, code reviews, approvals, issues or otherwise. We're receptive to constructive comments and criticism, as the experiences and skill sets of all members contribute to the whole of our efforts. We're accepting of all who wish to take part in our activities, fostering an environment where anyone can participate, and everyone can make a difference.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
7
11
 
8
- ### Be Considerate
9
- Members of the community are considerate of their peers, which include other contributors and users of SendGrid. We're thoughtful when addressing the efforts of others, keeping in mind that often the labor was completed with the intent of the good of the community. We're attentive in our communications, whether in person or online, and we're tactful when approaching differing views.
12
+ ## Our Standards
10
13
 
11
- ### Be Respectful
12
- Members of the community are respectful. We're respectful of others, their positions, their skills, their commitments and their efforts. We're respectful of the volunteer efforts that permeate the SendGrid community. We're respectful of the processes outlined in the community, and we work within them. When we disagree, we are courteous in raising our issues. Overall, we're good to each other. We contribute to this community not because we have to, but because we want to. If we remember that, these guidelines will come naturally.
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
13
16
 
14
- ## Additional Guidance
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
15
22
 
16
- ### Disclose Potential Conflicts of Interest
17
- Community discussions often involve interested parties. We expect participants to be aware when they are conflicted due to employment or other projects they are involved in and disclose those interests to other project members. When in doubt, over-disclose. Perceived conflicts of interest are important to address so that the community’s decisions are credible even when unpopular, difficult or favorable to the interests of one group over another.
23
+ Examples of unacceptable behavior by participants include:
18
24
 
19
- ### Interpretation
20
- This Code is not exhaustive or complete. It is not a rulebook; it serves to distill our common understanding of a collaborative, shared environment and goals. We expect it to be followed in spirit as much as in the letter. When in doubt, try to abide by [SendGrid’s cultural values](https://sendgrid.com/blog/employee-engagement-the-4h-way) defined by our “4H’s”: Happy, Hungry, Humble and Honest.
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
21
33
 
22
- ### Enforcement
23
- Most members of the SendGrid community always comply with this Code, not because of the existence of this Code, but because they have long experience participating in open source communities where the conduct described above is normal and expected. However, failure to observe this Code may be grounds for suspension, reporting the user for abuse or changing permissions for outside contributors.
34
+ ## Our Responsibilities
24
35
 
25
- ## If you have concerns about someone’s conduct
26
- **Initiate Direct Contact** - It is always appropriate to email a community member (if contact information is available), mention that you think their behavior was out of line, and (if necessary) point them to this Code.
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
27
39
 
28
- **Discuss Publicly** - Discussing publicly is always acceptable. Note, though, that approaching the person directly may be better, as it tends to make them less defensive, and it respects the time of other community members, so you probably want to try direct contact first.
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
29
45
 
30
- **Contact the Moderators** - You can reach the SendGrid moderators by emailing dx@sendgrid.com.
46
+ ## Scope
31
47
 
32
- ## Submission to SendGrid Repositories
33
- Finally, just a reminder, changes to the SendGrid repositories will only be accepted upon completion of the [SendGrid Contributor Agreement](https://cla.sendgrid.com).
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at open-source@twilio.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
34
67
 
35
68
  ## Attribution
36
69
 
37
- SendGrid thanks the following, on which it draws for content and inspiration:
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
38
72
 
39
- * [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/)
40
- * [Open Source Initiative General Code of Conduct](https://opensource.org/codeofconduct)
41
- * [Apache Code of Conduct](https://www.apache.org/foundation/policies/conduct.html)
73
+ [homepage]: https://www.contributor-covenant.org
data/CONTRIBUTING.md CHANGED
@@ -1,64 +1,21 @@
1
- Hello! Thank you for choosing to help contribute to one of the SendGrid open source libraries. There are many ways you can contribute and help is always welcome. We simply ask that you follow the following contribution policies.
1
+ Hello! Thank you for choosing to help contribute to one of the Twilio SendGrid open-source libraries. There are many ways you can contribute and help is always welcome. We simply ask that you follow the following contribution policies.
2
2
 
3
- - [CLAs and CCLAs](#clas-and-cclas)
4
- - [Feature Request](#feature-request)
5
- - [Submit a Bug Report](#submit-a-bug-report)
6
- - [Please use our Bug Report Template](#please-use-our-bug-report-template)
3
+ **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.**
7
4
  - [Improvements to the Codebase](#improvements-to-the-codebase)
8
- - [Development Environment](#development-environment)
9
- - [Install and Run Locally](#install-and-run-locally)
10
- - [Prerequisites](#prerequisites)
11
- - [Initial setup:](#initial-setup)
12
- - [Environment Variables](#environment-variables)
13
- - [Execute:](#execute)
5
+ - [Development Environment](#development-environment)
6
+ - [Install and Run Locally](#install-and-run-locally)
7
+ - [Prerequisites](#prerequisites)
8
+ - [Initial setup:](#initial-setup)
9
+ - [Environment Variables](#environment-variables)
10
+ - [Execute:](#execute)
14
11
  - [Understanding the Code Base](#understanding-the-code-base)
15
12
  - [Testing](#testing)
16
13
  - [Style Guidelines & Naming Conventions](#style-guidelines--naming-conventions)
17
14
  - [Creating a Pull Request](#creating-a-pull-request)
18
-
19
- <a name="roadmap"></a>
20
- We use [Milestones](https://github.com/sendgrid/sendgrid-ruby/milestones) to help define current roadmaps, please feel free to grab an issue from the current milestone. Please indicate that you have begun work on it to avoid collisions. Once a PR is made, community review, comments, suggestions and additional PRs are welcomed and encouraged.
21
-
22
- <a name="cla"></a>
23
- ## CLAs and CCLAs
24
-
25
- Before you get started, SendGrid requires that a SendGrid Contributor License Agreement (CLA) be filled out by every contributor to a SendGrid open source project.
26
-
27
- Our goal with the CLA is to clarify the rights of our contributors and reduce other risks arising from inappropriate contributions. The CLA also clarifies the rights SendGrid holds in each contribution and helps to avoid misunderstandings over what rights each contributor is required to grant to SendGrid when making a contribution. In this way the CLA encourages broad participation by our open source community and helps us build strong open source projects, free from any individual contributor withholding or revoking rights to any contribution.
28
-
29
- SendGrid does not merge a pull request made against a SendGrid open source project until that pull request is associated with a signed CLA. Copies of the CLA are available [here](https://gist.github.com/SendGridDX/98b42c0a5d500058357b80278fde3be8#file-sendgrid_cla).
30
-
31
- When you create a Pull Request, after a few seconds, a comment will appear with a link to the CLA. Click the link and fill out the brief form and then click the "I agree" button and you are all set. You will not be asked to re-sign the CLA unless we make a change.
15
+ - [Code Reviews](#code-reviews)
32
16
 
33
17
  There are a few ways to contribute, which we'll enumerate below:
34
18
 
35
- <a name="feature-request"></a>
36
- ## Feature Request
37
-
38
- If you'd like to make a feature request, please read this section.
39
-
40
- The GitHub issue tracker is the preferred channel for library feature requests, but please respect the following restrictions:
41
-
42
- - Please **search for existing issues** in order to ensure we don't have duplicate bugs/feature requests.
43
- - Please be respectful and considerate of others when commenting on issues
44
-
45
- <a name="submit-a-bug-report"></a>
46
- ## Submit a Bug Report
47
-
48
- Note: DO NOT include your credentials in ANY code examples, descriptions, or media you make public.
49
-
50
- A software bug is a demonstrable issue in the code base. In order for us to diagnose the issue and respond as quickly as possible, please add as much detail as possible into your bug report.
51
-
52
- Before you decide to create a new issue, please try the following:
53
-
54
- 1. Check the Github issues tab if the identified issue has already been reported, if so, please add a +1 to the existing post.
55
- 2. Update to the latest version of this code and check if issue has already been fixed
56
- 3. Copy and fill in the Bug Report Template we have provided below
57
-
58
- ### Please use our Bug Report Template
59
-
60
- In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/sendgrid-ruby/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
61
-
62
19
  <a name="improvements-to-the-codebase"></a>
63
20
  ## Improvements to the Codebase
64
21
 
@@ -89,9 +46,9 @@ We welcome direct contributions to the sendgrid-ruby code base. Thank you!
89
46
  bundle install
90
47
  ```
91
48
 
92
- ## Environment Variables
49
+ ### Environment Variables
93
50
 
94
- First, get your free SendGrid account [here](https://sendgrid.com/free?source=sendgrid-ruby).
51
+ First, get your free Twilio SendGrid account [here](https://sendgrid.com/free?source=sendgrid-ruby).
95
52
 
96
53
  Next, update your environment with your [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys).
97
54
 
@@ -103,7 +60,7 @@ source ./sendgrid.env
103
60
 
104
61
  ##### Execute: #####
105
62
 
106
- See the [examples folder](https://github.com/sendgrid/sendgrid-ruby/tree/master/examples) to get started quickly.
63
+ See the [examples folder](examples) to get started quickly.
107
64
 
108
65
  To run the examples using the local version of this library from the root directory of this repo, please replace:
109
66
 
@@ -134,20 +91,13 @@ Tests for the mail send and Web API v3 endpoints.
134
91
 
135
92
  The Web API v3 client is `sendgrid-ruby.rb`
136
93
 
137
- <a name="testing"></a>
138
94
  ## Testing
139
95
 
140
- All PRs require passing tests before the PR will be reviewed.
141
-
142
- All test files are in the [`tests`](https://github.com/sendgrid/sendgrid-ruby/tree/master/test) directory.
96
+ All PRs require passing tests before the PR will be reviewed. All test files are in the [`tests`](test) directory. For the purposes of contributing to this repo, please update the [`test_sendgrid-ruby.rb`](test/sendgrid/test_sendgrid-ruby.rb) file with unit tests as you modify the code.
143
97
 
144
- For the purposes of contributing to this repo, please update the [`test_sendgrid-ruby.rb`](https://github.com/sendgrid/sendgrid-ruby/blob/master/test/test_sendgrid-ruby.rb) file with unit tests as you modify the code.
98
+ The integration tests require a Twilio SendGrid mock API in order to execute. We've simplified setting this up using Docker to run the tests. You will just need [Docker Desktop](https://docs.docker.com/get-docker/) and `make`.
145
99
 
146
- To run the tests:
147
-
148
- ```bash
149
- rake
150
- ```
100
+ Once these are available, simply execute the Docker test target to run all tests: `make test-docker`. This command can also be used to open an interactive shell into the container where this library is installed. To start a *bash* shell for example, use this command: `command=bash make test-docker`.
151
101
 
152
102
  <a name="style-guidelines-and-naming-conventions"></a>
153
103
  ## Style Guidelines & Naming Conventions
@@ -169,10 +119,10 @@ Please run your code through:
169
119
  ```bash
170
120
  # Clone your fork of the repo into the current directory
171
121
  git clone https://github.com/sendgrid/sendgrid-ruby
172
-
122
+
173
123
  # Navigate to the newly cloned directory
174
124
  cd sendgrid-ruby
175
-
125
+
176
126
  # Assign the original repo to a remote called "upstream"
177
127
  git remote add upstream https://github.com/sendgrid/sendgrid-ruby
178
128
  ```
@@ -193,7 +143,7 @@ Please run your code through:
193
143
 
194
144
  4. Commit your changes in logical chunks. Please adhere to these [git commit
195
145
  message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
196
- or your code is unlikely be merged into the main project. Use Git's
146
+ or your code is unlikely to be merged into the main project. Use Git's
197
147
  [interactive rebase](https://help.github.com/articles/interactive-rebase)
198
148
  feature to tidy up your commits before making them public.
199
149
 
@@ -204,7 +154,7 @@ Please run your code through:
204
154
  5. Locally merge (or rebase) the upstream development branch into your topic branch:
205
155
 
206
156
  ```bash
207
- git pull [--rebase] upstream master
157
+ git pull [--rebase] upstream main
208
158
  ```
209
159
 
210
160
  6. Push your topic branch up to your fork:
@@ -214,6 +164,9 @@ Please run your code through:
214
164
  ```
215
165
 
216
166
  7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
217
- with a clear title and description against the `master` branch. All tests must be passing before we will review the PR.
167
+ with a clear title and description against the `main` branch. All tests must be passing before we will review the PR.
168
+
169
+ <a name="code-reviews"></a>
170
+ ## Code Reviews
218
171
 
219
- If you have any additional questions, please feel free to [email](mailto:dx@sendgrid.com) us or create an issue in this repo.
172
+ If you can, please look at open PRs and review them. Give feedback and help us merge these PRs much faster! If you don't know how, Github has some [great information on how to review a Pull Request](https://help.github.com/articles/about-pull-request-reviews/).
data/Dockerfile ADDED
@@ -0,0 +1,14 @@
1
+ ARG version=ruby:latest
2
+ FROM $version
3
+
4
+ # Needed for jruby
5
+ RUN apt-get update \
6
+ && apt-get install -y make git
7
+
8
+ COPY prism/prism/nginx/cert.crt /usr/local/share/ca-certificates/cert.crt
9
+ RUN update-ca-certificates
10
+
11
+ WORKDIR /app
12
+ COPY . .
13
+
14
+ RUN make install
data/FIRST_TIMERS.md ADDED
@@ -0,0 +1,53 @@
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.
data/Gemfile CHANGED
@@ -3,4 +3,3 @@ source 'http://rubygems.org'
3
3
  gemspec
4
4
 
5
5
  gem 'ruby_http_client'
6
-
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (C) 2023, Twilio SendGrid, Inc. <help@twilio.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/Makefile ADDED
@@ -0,0 +1,14 @@
1
+ .PHONY: install test test-integ test-docker
2
+
3
+ install:
4
+ gem install bundler:2.1.2; bundle install
5
+
6
+ test:
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
@@ -0,0 +1,31 @@
1
+ <!--
2
+ We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below.
3
+
4
+ Please format the PR title appropriately based on the type of change:
5
+ <type>[!]: <description>
6
+ Where <type> is one of: docs, chore, feat, fix, test, misc.
7
+ Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature).
8
+
9
+ **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.**
10
+
11
+ 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!
12
+ e.g.
13
+ Fixes #1
14
+ Closes #2
15
+ -->
16
+
17
+ # Fixes #
18
+
19
+ A short description of what this PR does.
20
+
21
+ ### Checklist
22
+ - [x] I acknowledge that all my contributions will be made under the project's license
23
+ - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
24
+ - [ ] I have read the [Contribution Guidelines](https://github.com/sendgrid/sendgrid-ruby/blob/main/CONTRIBUTING.md) and my PR follows them
25
+ - [ ] I have titled the PR appropriately
26
+ - [ ] I have updated my branch with the main branch
27
+ - [ ] I have added tests that prove my fix is effective or that my feature works
28
+ - [ ] I have added the necessary documentation about the functionality in the appropriate .md file
29
+ - [ ] I have added inline documentation to the code I modified
30
+
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,31 +1,33 @@
1
- ![SendGrid Logo](https://uiux.s3.amazonaws.com/2016-logos/email-logo%402x.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) [![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)[![Email Notifications Badge](https://dx.sendgrid.com/badge/ruby)](https://dx.sendgrid.com/newsletter/ruby)[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt)[![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)[![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-ruby.svg)](https://github.com/sendgrid/sendgrid-ruby/graphs/contributors)
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
+ [![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)
5
+ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
+ [![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
7
+ [![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/sendgrid-ruby.svg)](https://github.com/sendgrid/sendgrid-ruby/graphs/contributors)
8
+ [![Open Source Helpers](https://www.codetriage.com/sendgrid/sendgrid-ruby/badges/users.svg)](https://www.codetriage.com/sendgrid/sendgrid-ruby)
4
9
 
5
- **NEW:** Subscribe to email [notifications](https://dx.sendgrid.com/newsletter/ruby) for releases and breaking changes.
10
+ **This library allows you to quickly and easily use the Twilio SendGrid Web API v3 via Ruby.**
6
11
 
7
- **This library allows you to quickly and easily use the SendGrid Web API v3 via Ruby.**
12
+ 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).
8
13
 
9
- Version 3.X.X+ of this library provides full support for all 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).
14
+ 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.
10
15
 
11
- This library represents the beginning of a new path for SendGrid. We want this library to be community driven and 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.
12
-
13
- Please browse the rest of this README for further details.
14
-
15
- We appreciate your continued support, thank you!
16
+ **If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).**
16
17
 
17
18
  # Table of Contents
18
19
 
20
+ * [Announcements](#announcements)
19
21
  * [Installation](#installation)
20
22
  * [Quick Start](#quick-start)
21
23
  * [Processing Inbound Email](#inbound)
22
24
  * [Usage](#usage)
23
25
  * [Use Cases](#use_cases)
24
26
  * [Announcements](#announcements)
25
- * [Roadmap](#roadmap)
26
27
  * [How to Contribute](#contribute)
27
28
  * [Troubleshooting](#troubleshooting)
28
29
  * [About](#about)
30
+ * [Support](#support)
29
31
  * [License](#license)
30
32
 
31
33
  <a name="installation"></a>
@@ -33,8 +35,8 @@ We appreciate your continued support, thank you!
33
35
 
34
36
  ## Prerequisites
35
37
 
36
- - Ruby version >= 2.2
37
- - The SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-ruby)
38
+ - Ruby version >= 2.4 (except version [2.6.0](TROUBLESHOOTING.md#ruby-versions))
39
+ - The Twilio SendGrid service, starting at the [free level](https://sendgrid.com/free?source=sendgrid-ruby)
38
40
 
39
41
  ## Setup Environment Variables
40
42
 
@@ -68,14 +70,13 @@ gem install sendgrid-ruby
68
70
  ## Dependencies
69
71
 
70
72
  - [Ruby-HTTP-Client](https://github.com/sendgrid/ruby-http-client)
71
- - [Sinatra](http://www.sinatrarb.com/) - this is only needed if you plan to process [Inbound Email](#inbound).
72
73
 
73
74
  <a name="quick-start"></a>
74
75
  # Quick Start
75
76
 
76
77
  ## Hello Email
77
78
 
78
- 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):
79
+ 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):
79
80
 
80
81
  ### With Mail Helper Class
81
82
 
@@ -85,7 +86,7 @@ include SendGrid
85
86
 
86
87
  from = SendGrid::Email.new(email: 'test@example.com')
87
88
  to = SendGrid::Email.new(email: 'test@example.com')
88
- subject = 'Sending with SendGrid is Fun'
89
+ subject = 'Sending with Twilio SendGrid is Fun'
89
90
  content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby')
90
91
  mail = SendGrid::Mail.new(from, subject, to, content)
91
92
 
@@ -97,11 +98,11 @@ puts response.parsed_body
97
98
  puts response.headers
98
99
  ```
99
100
 
100
- 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).
101
+ 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).
101
102
 
102
103
  ### Without Mail Helper Class
103
104
 
104
- 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):
105
+ 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):
105
106
 
106
107
  ```ruby
107
108
  require 'sendgrid-ruby'
@@ -115,7 +116,7 @@ data = JSON.parse('{
115
116
  "email": "test@example.com"
116
117
  }
117
118
  ],
118
- "subject": "Sending with SendGrid is Fun"
119
+ "subject": "Sending with Twilio SendGrid is Fun"
119
120
  }
120
121
  ],
121
122
  "from": {
@@ -163,57 +164,52 @@ puts response.headers
163
164
  <a name="inbound"></a>
164
165
  # Processing Inbound Email
165
166
 
166
- Please see [our helper](https://github.com/sendgrid/sendgrid-ruby/tree/master/lib/sendgrid/helpers/inbound) for utilizing our Inbound Parse webhook.
167
+ Please see [our helper](lib/sendgrid/helpers/inbound) for utilizing our Inbound Parse webhook.
167
168
 
168
169
  <a name="usage"></a>
169
170
  # Usage
170
171
 
171
- - [SendGrid Docs](https://sendgrid.com/docs/API_Reference/index.html)
172
- - [Library Usage Docs](https://github.com/sendgrid/sendgrid-ruby/tree/master/USAGE.md)
173
- - [Example Code](https://github.com/sendgrid/sendgrid-ruby/tree/master/examples)
172
+ - [Twilio SendGrid Docs](https://sendgrid.com/docs/API_Reference/index.html)
173
+ - [Library Usage Docs](USAGE.md)
174
+ - [Example Code](examples)
174
175
  - [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)
175
- - [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.
176
- - [Settings Helper](https://github.com/sendgrid/sendgrid-ruby/tree/master/lib/sendgrid/helpers/settings)
176
+ - [v3 Web API Mail Send Helper](lib/sendgrid/helpers/mail) - build a request object payload for a v3 /mail/send API call.
177
+ - [Settings Helper](lib/sendgrid/helpers/settings)
177
178
 
178
179
  <a name="use_cases"></a>
179
180
  # Use Cases
180
181
 
181
- [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.
182
+ [Examples of common API use cases](use-cases), such as how to send an email with a transactional template.
182
183
 
183
184
  <a name="announcements"></a>
184
185
  # Announcements
185
186
 
186
- Please see our announcement regarding [breaking changes](https://github.com/sendgrid/sendgrid-ruby/issues/94). Your support is appreciated!
187
-
188
- 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.
189
-
190
- <a name="roadmap"></a>
191
- # Roadmap
192
-
193
- 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.
187
+ All updates to this library are documented in our [CHANGELOG](CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-ruby/releases).
194
188
 
195
189
  <a name="contribute"></a>
196
190
  # How to Contribute
197
191
 
198
- 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.
192
+ We encourage contribution to our libraries (you might even score some nifty swag), please see our [CONTRIBUTING](CONTRIBUTING.md) guide for details.
199
193
 
200
- - [Feature Request](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#feature_request)
201
- - [Bug Reports](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#submit_a_bug_report)
202
- - [Sign the CLA to Create a Pull Request](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#cla)
203
- - [Improvements to the Codebase](https://github.com/sendgrid/sendgrid-ruby/tree/master/CONTRIBUTING.md#improvements_to_the_codebase)
194
+ - [Feature Request](CONTRIBUTING.md#feature_request)
195
+ - [Bug Reports](CONTRIBUTING.md#submit_a_bug_report)
196
+ - [Improvements to the Codebase](CONTRIBUTING.md#improvements_to_the_codebase)
197
+ - [Review Pull Requests](CONTRIBUTING.md#code-reviews)
204
198
 
205
199
  <a name="troubleshooting"></a>
206
200
  # Troubleshooting
207
201
 
208
- Please see our [troubleshooting guide](https://github.com/sendgrid/sendgrid-ruby/blob/master/TROUBLESHOOTING.md) for common library issues.
202
+ Please see our [troubleshooting guide](TROUBLESHOOTING.md) for common library issues.
209
203
 
210
204
  <a name="about"></a>
211
205
  # About
212
206
 
213
- sendgrid-ruby is guided and supported by the SendGrid [Developer Experience Team](mailto:dx@sendgrid.com).
207
+ sendgrid-ruby is maintained and funded by Twilio SendGrid, Inc. The names and logos for sendgrid-ruby are trademarks of Twilio SendGrid, Inc.
208
+
209
+ <a name="support"></a>
214
210
 
215
- sendgrid-ruby is maintained and funded by SendGrid, Inc. The names and logos for sendgrid-ruby are trademarks of SendGrid, Inc.
211
+ If you need help using SendGrid, please check the [Twilio SendGrid Support Help Center](https://support.sendgrid.com).
216
212
 
217
213
  <a name="license"></a>
218
214
  # License
219
- [The MIT License (MIT)](LICENSE.txt)
215
+ [The MIT License (MIT)](LICENSE)
data/Rakefile CHANGED
@@ -4,12 +4,11 @@ require 'rspec/core/rake_task'
4
4
 
5
5
  Rake::TestTask.new do |t|
6
6
  t.libs << 'test'
7
- t.test_files = FileList['test/sendgrid/test*.rb', 'test/sendgrid/helpers/mail/test*.rb']
7
+ t.test_files = FileList['test/sendgrid/test*.rb', 'test/sendgrid/helpers/mail/test*.rb', 'test/sendgrid/helpers/permissions/test*.rb']
8
8
  t.verbose = true
9
9
  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]