-
Notifications
You must be signed in to change notification settings - Fork 716
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
382 additions
and
70 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
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 |
---|---|---|
|
@@ -4,36 +4,36 @@ | |
|
||
### Be Open | ||
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. | ||
|
||
### Be Considerate | ||
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. | ||
|
||
### Be Respectful | ||
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. | ||
## Additional Guidance | ||
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 with 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. | ||
|
||
## Additional Guidance | ||
|
||
### Disclose Potential Conflicts of Interest | ||
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. | ||
|
||
### Interpretation | ||
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. | ||
|
||
### Enforcement | ||
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. | ||
|
||
## If you have concerns about someone’s conduct | ||
**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. | ||
|
||
**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. | ||
|
||
**Contact the Moderators** - You can reach the SendGrid moderators by emailing [email protected]. | ||
|
||
## Submission to SendGrid Repositories | ||
Finally, just a reminder, changes to the SendGrid repositories will only be accepted upon completion of the [SendGrid Contributor Agreement](https://cla.sendgrid.com). | ||
|
||
## Attribution | ||
|
||
SendGrid thanks the following, on which it draws for content and inspiration: | ||
|
||
* [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct) | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5034,4 +5034,3 @@ print(response.status_code) | |
print(response.body) | ||
print(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
Submodule sendgrid-python
added at
28cf42
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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
import json | ||
import os | ||
import urllib2 | ||
from sendgrid import SendGridAPIClient | ||
from sendgrid.helpers.mail import * | ||
from sendgrid import * | ||
|
||
|
||
# NOTE: you will need move this file to the root | ||
# directory of this project to execute properly. | ||
|
@@ -28,6 +26,84 @@ def build_hello_email(): | |
except SendGridException as e: | ||
print(e.message) | ||
|
||
<<<<<<< HEAD:examples/helpers/mail/mail_example.py | ||
======= | ||
for cc_addr in personalization['cc_list']: | ||
mock_personalization.add_to(cc_addr) | ||
|
||
for bcc_addr in personalization['bcc_list']: | ||
mock_personalization.add_bcc(bcc_addr) | ||
|
||
for header in personalization['headers']: | ||
mock_personalization.add_header(header) | ||
|
||
for substitution in personalization['substitutions']: | ||
mock_personalization.add_substitution(substitution) | ||
|
||
for arg in personalization['custom_args']: | ||
mock_personalization.add_custom_arg(arg) | ||
|
||
mock_personalization.subject = personalization['subject'] | ||
mock_personalization.send_at = personalization['send_at'] | ||
return mock_personalization | ||
|
||
|
||
def get_mock_personalization_dict(): | ||
"""Get a dict of personalization mock.""" | ||
mock_pers = dict() | ||
|
||
mock_pers['to_list'] = [Email("[email protected]", | ||
"Example User"), | ||
Email("[email protected]", | ||
"Example User")] | ||
|
||
mock_pers['cc_list'] = [Email("[email protected]", | ||
"Example User"), | ||
Email("[email protected]", | ||
"Example User")] | ||
|
||
mock_pers['bcc_list'] = [Email("[email protected]"), | ||
Email("[email protected]")] | ||
|
||
mock_pers['subject'] = ("Hello World from the Personalized " | ||
"SendGrid Python Library") | ||
|
||
mock_pers['headers'] = [Header("X-Test", "test"), | ||
Header("X-Mock", "true")] | ||
|
||
mock_pers['substitutions'] = [Substitution("%name%", "Example User"), | ||
Substitution("%city%", "Denver")] | ||
|
||
mock_pers['custom_args'] = [CustomArg("user_id", "343"), | ||
CustomArg("type", "marketing")] | ||
|
||
mock_pers['send_at'] = 1443636843 | ||
return mock_pers | ||
|
||
|
||
def build_attachment1(): | ||
"""Build attachment mock. Make sure your content is base64 encoded before passing into attachment.content. | ||
Another example: https://github.com/sendgrid/sendgrid-python/blob/master/use_cases/attachment.md""" | ||
attachment = Attachment() | ||
attachment.content = ("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNl" | ||
"Y3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12") | ||
attachment.type = "application/pdf" | ||
attachment.filename = "balance_001.pdf" | ||
attachment.disposition = "attachment" | ||
attachment.content_id = "Balance Sheet" | ||
return attachment | ||
|
||
|
||
def build_attachment2(): | ||
"""Build attachment mock.""" | ||
attachment = Attachment() | ||
attachment.content = "BwdW" | ||
attachment.type = "image/png" | ||
attachment.filename = "banner.png" | ||
attachment.disposition = "inline" | ||
attachment.content_id = "Banner" | ||
return attachment | ||
>>>>>>> master:examples/helpers/mail_example.py | ||
|
||
def build_kitchen_sink(): | ||
"""All settings set""" | ||
|
@@ -261,5 +337,40 @@ def send_kitchen_sink(): | |
## this will actually send an email | ||
# send_hello_email() | ||
|
||
<<<<<<< HEAD:examples/helpers/mail/mail_example.py | ||
## this will only send an email if you set SandBox Mode to False | ||
# send_kitchen_sink() | ||
======= | ||
# this will only send an email if you set SandBox Mode to False | ||
send_kitchen_sink() | ||
|
||
|
||
def transactional_template_usage(): | ||
# Assumes you set your environment variable: | ||
# https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key | ||
|
||
""" | ||
Sample usage of dynamic (handlebars) transactional templates. | ||
To make this work, you should have dynamic template created within your | ||
SendGrid account. For this particular example, template may be like:: | ||
<p>Hello, {{name}}! Your current balance is {{balance}}<p> | ||
""" | ||
mail = Mail() | ||
mail.from_email = Email('[email protected]') | ||
mail.template_id = 'd-your-dynamic-template-uid' | ||
p = Personalization() | ||
p.add_to(Email('[email protected]')) | ||
p.dynamic_template_data = { | ||
'name': 'Bob', | ||
'balance': 42 | ||
} | ||
mail.add_personalization(p) | ||
|
||
sg = SendGridAPIClient() | ||
response = sg.client.mail.send.post(request_body=mail.get()) | ||
print(response.status_code) | ||
print(response.headers) | ||
print(response.body) | ||
>>>>>>> master:examples/helpers/mail_example.py |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
from .validators import ValidateApiKey | ||
|
||
|
||
|
||
class Content(object): | ||
"""Content to be included in your email. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
import unittest | ||
|
||
|
||
|
||
class ProjectTests(unittest.TestCase): | ||
# ./docker | ||
def test_docker_dir(self): | ||
|
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
Oops, something went wrong.