-
Notifications
You must be signed in to change notification settings - Fork 323
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: geolocation setter in sendgrid-ruby for GDPR compliance
- Loading branch information
1 parent
bc213ec
commit 82be96b
Showing
4 changed files
with
25 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ | |
content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
mail = SendGrid::Mail.new(from, subject, to, content) | ||
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
sg.sendgrid_data_residency(region: "global") | ||
puts sg.host | ||
response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
puts response.status_code | ||
|
@@ -24,7 +25,7 @@ | |
content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
mail = SendGrid::Mail.new(from, subject, to, content) | ||
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY_EU']) | ||
sg.data_residency(region: 'eu') | ||
sg.sendgrid_data_residency(region: 'eu') | ||
puts sg.host | ||
response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
puts response.status_code | ||
|
@@ -45,66 +46,3 @@ | |
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
# Example 4 | ||
# Sending using "global" data residency in constructor | ||
|
||
from = SendGrid::Email.new(email: '[email protected]') | ||
to = SendGrid::Email.new(email: '[email protected]') | ||
subject = 'Sending with Twilio SendGrid is Fun' | ||
content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
mail = SendGrid::Mail.new(from, subject, to, content) | ||
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY'], region: 'global') | ||
puts sg.host | ||
response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
# Example 5 | ||
# Sending using "eu" data residency in constructor | ||
|
||
from = SendGrid::Email.new(email: '[email protected]') | ||
to = SendGrid::Email.new(email: '[email protected]') | ||
subject = 'Sending with Twilio SendGrid is Fun' | ||
content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
mail = SendGrid::Mail.new(from, subject, to, content) | ||
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY_EU'], region: 'eu') | ||
puts sg.host | ||
response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
# Example 6 | ||
# Sending using "nil" data residency | ||
# This will throw exception because data residency cannot be null | ||
|
||
from = SendGrid::Email.new(email: '[email protected]') | ||
to = SendGrid::Email.new(email: '[email protected]') | ||
subject = 'Sending with Twilio SendGrid is Fun' | ||
content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
mail = SendGrid::Mail.new(from, subject, to, content) | ||
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY_EU']) | ||
sg.data_residency(region: nil) | ||
puts sg.host | ||
response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers | ||
|
||
# Example 7 | ||
# First region, then host | ||
from = SendGrid::Email.new(email: '[email protected]') | ||
to = SendGrid::Email.new(email: '[email protected]') | ||
subject = 'Sending with Twilio SendGrid is Fun' | ||
content = SendGrid::Content.new(type: 'text/plain', value: 'and easy to do anywhere, even with Ruby') | ||
mail = SendGrid::Mail.new(from, subject, to, content) | ||
sg = SendGrid::API.new(api_key: ENV['SENDGRID_API_KEY']) | ||
sg.data_residency(region: "eu") | ||
sg.update_host(host: "https://api.sendgrid.com") | ||
puts sg.host | ||
response = sg.client.mail._('send').post(request_body: mail.to_json) | ||
puts response.status_code | ||
puts response.body | ||
puts response.headers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters