-
Notifications
You must be signed in to change notification settings - Fork 727
feat: geolocation setter in sendgrid-python for GDPR compliance #1073
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
30b1ca6
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 1e1299d
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 9d433a6
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 bb9535f
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 b81337d
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 7e56049
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 e7b9578
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 3bd6d6f
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 cf2cc5d
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 4019024
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 6ceb524
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 2a9930f
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 5885985
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 3dc77d8
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 da3f03c
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 f86747b
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 0a95877
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 41312f4
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 9f73f25
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 7eb07f7
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 d760424
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 7fc733d
feat: geolocation setter in sendgrid-python for GDPR compliance
manisha1997 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import sendgrid | ||
| import os | ||
|
|
||
| from sendgrid import Email, To, Content, Mail | ||
|
|
||
| # Example 1 | ||
| # setting region to be "global" | ||
|
|
||
| sg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY')) | ||
| from_email = Email("[email protected]") | ||
| to_email = To("[email protected]") | ||
| subject = "Sending with SendGrid is Fun" | ||
| content = Content("text/plain", "and easy to do anywhere, even with Python") | ||
| mail = Mail(from_email, to_email, subject, content) | ||
| sg.set_sendgrid_data_residency("global") | ||
| print(sg.client.host) | ||
| response = sg.client.mail.send.post(request_body=mail.get()) | ||
| print(response) | ||
| print(response.status_code) | ||
| print(response.body) | ||
| print(response.headers) | ||
|
|
||
| # Example 2 | ||
| # setting region to "eu" | ||
| sg = sendgrid.SendGridAPIClient(api_key=os.environ.get('SENDGRID_API_KEY_EU')) | ||
| sg.set_sendgrid_data_residency("eu") | ||
| from_email = Email("[email protected]") | ||
| to_email = To("[email protected]") | ||
| subject = "Sending with SendGrid is Fun" | ||
| content = Content("text/plain", "and easy to do anywhere, even with Python") | ||
| print(sg.client.host) | ||
| mail = Mail(from_email, to_email, subject, content) | ||
| response = sg.client.mail.send.post(request_body=mail.get()) | ||
| print(response) | ||
| print(response.status_code) | ||
| print(response.body) | ||
| print(response.headers) |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| import unittest | ||
| import sendgrid | ||
|
|
||
| class UnitTests(unittest.TestCase): | ||
| def test_host_with_no_region(self): | ||
| sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY') | ||
| self.assertEqual("https://api.sendgrid.com",sg.client.host) | ||
|
|
||
| def test_host_with_eu_region(self): | ||
| sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY') | ||
| sg.set_sendgrid_data_residency("eu") | ||
| self.assertEqual("https://api.eu.sendgrid.com",sg.client.host) | ||
|
|
||
| def test_host_with_global_region(self): | ||
| sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY') | ||
| sg.set_sendgrid_data_residency("global") | ||
| self.assertEqual("https://api.sendgrid.com",sg.client.host) | ||
|
|
||
| def test_with_region_is_none(self): | ||
| sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY') | ||
| with self.assertRaises(ValueError): | ||
| sg.set_sendgrid_data_residency(None) | ||
|
|
||
| def test_with_region_is_invalid(self): | ||
| sg = sendgrid.SendGridAPIClient(api_key='MY_API_KEY') | ||
| with self.assertRaises(ValueError): | ||
| sg.set_sendgrid_data_residency("abc") | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.