sendgrid-ruby 1.1.6 → 6.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.codeclimate.yml +21 -0
- data/.env_sample +1 -3
- data/.gitignore +1 -0
- data/.travis.yml +28 -17
- data/CHANGELOG.md +231 -1
- data/CODE_OF_CONDUCT.md +73 -0
- data/CONTRIBUTING.md +214 -0
- data/Gemfile +5 -4
- data/ISSUE_TEMPLATE.md +26 -0
- data/LICENSE.md +21 -0
- data/Makefile +7 -0
- data/PULL_REQUEST_TEMPLATE.md +31 -0
- data/README.md +161 -225
- data/Rakefile +9 -2
- data/TROUBLESHOOTING.md +137 -0
- data/UPGRADE.md +5 -0
- data/USAGE.md +5037 -0
- data/USE_CASES.md +377 -0
- data/config.ru +4 -0
- data/docker/Dockerfile +12 -0
- data/docker/README.md +30 -0
- data/examples/accesssettings/accesssettings.rb +83 -0
- data/examples/alerts/alerts.rb +62 -0
- data/examples/apikeys/apikeys.rb +84 -0
- data/examples/asm/asm.rb +173 -0
- data/examples/browsers/browsers.rb +16 -0
- data/examples/campaigns/campaigns.rb +153 -0
- data/examples/categories/categories.rb +36 -0
- data/examples/clients/clients.rb +27 -0
- data/examples/contactdb/contactdb.rb +395 -0
- data/examples/devices/devices.rb +16 -0
- data/examples/geo/geo.rb +16 -0
- data/examples/helpers/mail/example.rb +147 -0
- data/examples/helpers/settings/example.rb +23 -0
- data/examples/helpers/stats/example.rb +42 -0
- data/examples/ips/ips.rb +167 -0
- data/examples/mail/mail.rb +173 -0
- data/examples/mailboxproviders/mailboxproviders.rb +16 -0
- data/examples/mailsettings/mailsettings.rb +219 -0
- data/examples/partnersettings/partnersettings.rb +39 -0
- data/examples/scopes/scopes.rb +61 -0
- data/examples/senderauthentication/senderauthentication.rb +310 -0
- data/examples/senders/senders.rb +98 -0
- data/examples/stats/stats.rb +16 -0
- data/examples/subusers/subusers.rb +169 -0
- data/examples/suppression/suppression.rb +201 -0
- data/examples/templates/templates.rb +129 -0
- data/examples/trackingsettings/trackingsettings.rb +110 -0
- data/examples/user/user.rb +293 -0
- data/gemfiles/Sinatra_1.gemfile +6 -0
- data/gemfiles/Sinatra_2.gemfile +6 -0
- data/lib/sendgrid/client.rb +33 -57
- data/lib/sendgrid/helpers/inbound/README.md +98 -0
- data/lib/sendgrid/helpers/inbound/app.rb +32 -0
- data/lib/sendgrid/helpers/inbound/config.yml +26 -0
- data/lib/sendgrid/helpers/inbound/public/index.html +10 -0
- data/lib/sendgrid/helpers/inbound/sample_data/default_data.txt +58 -0
- data/lib/sendgrid/helpers/inbound/sample_data/raw_data.txt +57 -0
- data/lib/sendgrid/helpers/inbound/sample_data/raw_data_with_attachments.txt +298 -0
- data/lib/sendgrid/helpers/inbound/send.rb +26 -0
- data/lib/sendgrid/helpers/ip_management/ip_management.rb +17 -0
- data/lib/sendgrid/helpers/mail/README.md +14 -0
- data/lib/sendgrid/helpers/mail/asm.rb +33 -0
- data/lib/sendgrid/helpers/mail/attachment.rb +86 -0
- data/lib/sendgrid/helpers/mail/bcc_settings.rb +33 -0
- data/lib/sendgrid/helpers/mail/bypass_list_management.rb +43 -0
- data/lib/sendgrid/helpers/mail/category.rb +20 -0
- data/lib/sendgrid/helpers/mail/click_tracking.rb +33 -0
- data/lib/sendgrid/helpers/mail/content.rb +20 -0
- data/lib/sendgrid/helpers/mail/custom_arg.rb +24 -0
- data/lib/sendgrid/helpers/mail/email.rb +29 -0
- data/lib/sendgrid/helpers/mail/footer.rb +43 -0
- data/lib/sendgrid/helpers/mail/ganalytics.rb +74 -0
- data/lib/sendgrid/helpers/mail/header.rb +24 -0
- data/lib/sendgrid/helpers/mail/mail.rb +140 -0
- data/lib/sendgrid/helpers/mail/mail_settings.rb +63 -0
- data/lib/sendgrid/helpers/mail/open_tracking.rb +33 -0
- data/lib/sendgrid/helpers/mail/personalization.rb +82 -0
- data/lib/sendgrid/helpers/mail/section.rb +24 -0
- data/lib/sendgrid/helpers/mail/spam_check.rb +43 -0
- data/lib/sendgrid/helpers/mail/subscription_tracking.rb +53 -0
- data/lib/sendgrid/helpers/mail/substitution.rb +24 -0
- data/lib/sendgrid/helpers/mail/tracking_settings.rb +53 -0
- data/lib/sendgrid/helpers/permissions/scope.rb +28 -0
- data/lib/sendgrid/helpers/permissions/scopes.yml +309 -0
- data/lib/sendgrid/helpers/settings/README.md +14 -0
- data/lib/sendgrid/helpers/settings/mail_settings_dto.rb +13 -0
- data/lib/sendgrid/helpers/settings/partner_settings_dto.rb +13 -0
- data/lib/sendgrid/helpers/settings/settings.rb +28 -0
- data/lib/sendgrid/helpers/settings/tracking_settings_dto.rb +24 -0
- data/lib/sendgrid/helpers/settings/user_settings_dto.rb +13 -0
- data/lib/sendgrid/helpers/stats/email_stats.rb +46 -0
- data/lib/sendgrid/helpers/stats/metrics.rb +35 -0
- data/lib/sendgrid/helpers/stats/stats_response.rb +31 -0
- data/lib/sendgrid/version.rb +1 -1
- data/lib/sendgrid-ruby.rb +27 -6
- data/mail_helper_v3.md +390 -0
- data/sendgrid-ruby.gemspec +13 -17
- data/spec/sendgrid/helpers/ip_management/ip_management_spec.rb +12 -0
- data/spec/sendgrid/helpers/settings/mail_settings_dto_spec.rb +32 -0
- data/spec/sendgrid/helpers/settings/partner_settings_dto_spec.rb +24 -0
- data/spec/sendgrid/helpers/settings/settings_spec.rb +25 -0
- data/spec/sendgrid/helpers/settings/tracking_settings_dto_spec.rb +27 -0
- data/spec/sendgrid/helpers/settings/user_settings_dto_spec.rb +24 -0
- data/spec/sendgrid/helpers/stats/email_stats_spec.rb +112 -0
- data/spec/sendgrid/helpers/stats/metrics_spec.rb +46 -0
- data/spec/sendgrid/helpers/stats/stats_response_spec.rb +76 -0
- data/spec/spec_helper.rb +10 -1
- data/test/prism.sh +42 -0
- data/test/sendgrid/helpers/mail/test_attachment.rb +35 -0
- data/test/sendgrid/helpers/mail/test_category.rb +27 -0
- data/test/sendgrid/helpers/mail/test_email.rb +34 -0
- data/test/sendgrid/helpers/mail/test_mail.rb +261 -0
- data/test/sendgrid/helpers/mail/test_personalizations.rb +161 -0
- data/test/sendgrid/permissions/test_scopes.rb +38 -0
- data/test/sendgrid/test_sendgrid-ruby.rb +2751 -0
- metadata +149 -115
- data/.rspec +0 -2
- data/.rubocop.yml +0 -30
- data/FETCH_HEAD +0 -0
- data/Guardfile +0 -10
- data/LICENSE.txt +0 -22
- data/example.rb +0 -41
- data/lib/sendgrid/exceptions.rb +0 -7
- data/lib/sendgrid/mail.rb +0 -182
- data/lib/sendgrid/recipient.rb +0 -29
- data/lib/sendgrid/response.rb +0 -14
- data/lib/sendgrid/template.rb +0 -26
- data/lib/sendgrid/template_mailer.rb +0 -59
- data/spec/lib/sendgrid/client_spec.rb +0 -87
- data/spec/lib/sendgrid/mail_spec.rb +0 -151
- data/spec/lib/sendgrid/recipient_spec.rb +0 -91
- data/spec/lib/sendgrid/template_mailer_spec.rb +0 -86
- data/spec/lib/sendgrid/template_spec.rb +0 -61
- data/spec/lib/sendgrid_spec.rb +0 -7
data/TROUBLESHOOTING.md
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
If you have a non-library Twilio SendGrid issue, please contact our [support team](https://support.sendgrid.com).
|
|
2
|
+
|
|
3
|
+
If you can't find a solution below, please open an [issue](https://github.com/sendgrid/sendgrid-ruby/issues).
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Table of Contents
|
|
7
|
+
|
|
8
|
+
* [Migrating from v2 to v3](#migrating-from-v2-to-v3)
|
|
9
|
+
* [Continue Using v2](#continue-using-v2)
|
|
10
|
+
* [Testing v3 /mail/send Calls Directly](#testing-v3-mailsend-calls-directly)
|
|
11
|
+
* [Error Messages](#error-messages)
|
|
12
|
+
* [Versioning](#versioning)
|
|
13
|
+
* [Environment Variables and Your Twilio SendGrid API Key](#environment-variables-and-your-twilio-sendgrid-api-key)
|
|
14
|
+
* [Using the Package Manager](#using-the-package-manager)
|
|
15
|
+
* [Rails Specifics](#rails-specifics)
|
|
16
|
+
* [Ruby Versions](#ruby-versions)
|
|
17
|
+
* [Viewing the Request Body](#viewing-the-request-body)
|
|
18
|
+
|
|
19
|
+
<a name="migrating"></a>
|
|
20
|
+
## Migrating from v2 to v3
|
|
21
|
+
|
|
22
|
+
Please review [our guide](https://sendgrid.com/docs/Classroom/Send/v3_Mail_Send/how_to_migrate_from_v2_to_v3_mail_send.html) on how to migrate from v2 to v3.
|
|
23
|
+
|
|
24
|
+
<a name="v2"></a>
|
|
25
|
+
## Continue Using v2
|
|
26
|
+
|
|
27
|
+
[Here](https://github.com/sendgrid/sendgrid-ruby/tree/0fbf579c0f7ed1dff87adc4957c4dc5a6b257068) is the last working version with v2 support.
|
|
28
|
+
|
|
29
|
+
Using rubygems:
|
|
30
|
+
|
|
31
|
+
Add this line to your application's Gemfile:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
gem 'sendgrid-ruby', '1.1.6'
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
And then execute:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
bundle
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Or install it yourself using:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
gem install sendgrid-ruby -v 1.1.6
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Download:
|
|
50
|
+
|
|
51
|
+
Click the "Clone or download" green button in [GitHub](https://github.com/sendgrid/sendgrid-ruby/tree/0fbf579c0f7ed1dff87adc4957c4dc5a6b257068) and choose download.
|
|
52
|
+
|
|
53
|
+
<a name="testing"></a>
|
|
54
|
+
## Testing v3 /mail/send Calls Directly
|
|
55
|
+
|
|
56
|
+
[Here](https://sendgrid.com/docs/for-developers/sending-email/curl-examples/) are some cURL examples for common use cases.
|
|
57
|
+
|
|
58
|
+
<a name="error"></a>
|
|
59
|
+
## Error Messages
|
|
60
|
+
|
|
61
|
+
To read the error message returned by SendGrid's API:
|
|
62
|
+
|
|
63
|
+
```ruby
|
|
64
|
+
begin
|
|
65
|
+
response = sg.client.mail._("send").post(request_body: mail.to_json)
|
|
66
|
+
rescue Exception => e
|
|
67
|
+
puts e.message
|
|
68
|
+
end
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
<a name="versioning"></a>
|
|
72
|
+
## Versioning
|
|
73
|
+
|
|
74
|
+
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.
|
|
75
|
+
|
|
76
|
+
<a name="environment"></a>
|
|
77
|
+
## Environment Variables and Your Twilio SendGrid API Key
|
|
78
|
+
|
|
79
|
+
All of our examples assume you are using [environment variables](https://github.com/sendgrid/sendgrid-ruby#setup-environment-variables) to hold your Twilio SendGrid API key.
|
|
80
|
+
|
|
81
|
+
If you choose to add your Twilio SendGrid API key directly (not recommended):
|
|
82
|
+
|
|
83
|
+
`sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'])`
|
|
84
|
+
|
|
85
|
+
becomes
|
|
86
|
+
|
|
87
|
+
`sg = SendGrid::API.new(api_key: 'SENDGRID_API_KEY')`
|
|
88
|
+
|
|
89
|
+
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.
|
|
90
|
+
|
|
91
|
+
<a name="package-manager"></a>
|
|
92
|
+
## Using the Package Manager
|
|
93
|
+
|
|
94
|
+
We upload this library to [RubyGems](https://rubygems.org/gems/sendgrid-ruby) whenever we make a release. This allows you to use [RubyGems](https://rubygems.org) for easy installation.
|
|
95
|
+
|
|
96
|
+
In most cases we recommend you download the latest version of the library, but if you need a different version, please use:
|
|
97
|
+
|
|
98
|
+
Add this line to your application's Gemfile:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
gem 'sendgrid-ruby', 'X.X.X'
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
And then execute:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
bundle
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Or install it yourself using:
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
gem install sendgrid-ruby -v X.X.X
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
<a name="rails-specifics"></a>
|
|
117
|
+
## Rails Specifics
|
|
118
|
+
|
|
119
|
+
- Namespace collision between Rails own `Mail` class and sendgrid class `Mail`. To avoid that issues please use `SendGrid::Mail` instead.
|
|
120
|
+
|
|
121
|
+
- 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.
|
|
122
|
+
|
|
123
|
+
<a name="ruby-versions"></a>
|
|
124
|
+
## Ruby Versions
|
|
125
|
+
|
|
126
|
+
This SDK [does not work with ruby version 2.6.0](https://github.com/sendgrid/sendgrid-ruby/issues/378) because of [this bug](https://bugs.ruby-lang.org/issues/15468). Please use any other [supported version](https://github.com/sendgrid/sendgrid-ruby#prerequisites).
|
|
127
|
+
|
|
128
|
+
<a name="request-body"></a>
|
|
129
|
+
## Viewing the Request Body
|
|
130
|
+
|
|
131
|
+
When debugging or testing, it may be useful to examine the raw request header to compare against the [documented format](https://sendgrid.com/docs/API_Reference/api_v3.html).
|
|
132
|
+
|
|
133
|
+
You can do this before `response = sg.client.mail._('send').post(request_body: mail.to_json)` like so:
|
|
134
|
+
|
|
135
|
+
```ruby
|
|
136
|
+
puts mail
|
|
137
|
+
```
|