Skip to content

Commit d94fdb6

Browse files
committed
Merge remote-tracking branch 'upstream/master' into not-java
That wasn't too bad.
2 parents d1d0a80 + 1ab4285 commit d94fdb6

41 files changed

Lines changed: 1002 additions & 78 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.codeclimate.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
engines:
1+
plugins:
22
pep8:
33
enabled: true
4-
ratings:
5-
paths:
6-
- "**.py"

LICENSE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2012-2016 SendGrid, Inc.
1+
Copyright (c) 2012-2017 SendGrid, Inc.
22

33
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
44
documentation files (the "Software"), to deal in the Software without restriction, including without limitation

PULL-REQUEST-TEMPLATE.md

Lines changed: 0 additions & 23 deletions
This file was deleted.

PULL_REQUEST_TEMPLATE

Lines changed: 0 additions & 26 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ echo "sendgrid.env" >> .gitignore
5555
source ./sendgrid.env
5656
```
5757

58-
Sengrid also supports local enviroment file `.env`. Copy or rename `.env_sample` into `.env` and update [SENGRID_API_KEY](https://app.sendgrid.com/settings/api_keys) with your key.
58+
Sendgrid also supports local enviroment file `.env`. Copy or rename `.env_sample` into `.env` and update [SENDGRID_API_KEY](https://app.sendgrid.com/settings/api_keys) with your key.
5959

6060
## Install Package
6161

@@ -180,6 +180,8 @@ Please see [our helper](https://github.com/sendgrid/sendgrid-python/tree/master/
180180
<a name="announcements"></a>
181181
# Announcements
182182

183+
Join an experienced and passionate team that focuses on making an impact. Opportunities abound to grow the product - and grow your career! Check out our [Data Platform Engineer role](http://grnh.se/wbx1701)
184+
183185
Please see our announcement regarding [breaking changes](https://github.com/sendgrid/sendgrid-python/issues/217). Your support is appreciated!
184186

185187
All updates to this library are documented in our [CHANGELOG](https://github.com/sendgrid/sendgrid-python/blob/master/CHANGELOG.md) and [releases](https://github.com/sendgrid/sendgrid-python/releases). You may also subscribe to email [release notifications](https://dx.sendgrid.com/newsletter/java) for releases and breaking changes.

TROUBLESHOOTING.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ If you can't find a solution below, please open an [issue](https://github.com/se
1212
* [Using the Package Manager](#package-manager)
1313
* [Version Convention](#versions)
1414
* [Viewing the Request Body](#request-body)
15+
* [Error Handling](#error-handling)
1516

1617
<a name="environment"></a>
1718
## Environment Variables and Your SendGrid API Key
@@ -106,3 +107,8 @@ You can do this right before you call `response = sg.client.mail.send.post(reque
106107
```python
107108
print mail.get()
108109
```
110+
111+
<a name="error-handling"></a>
112+
# Error Handling
113+
114+
Please review [our use_cases](https://github.com/sendgrid/sendgrid-python/USE_CASES.md) for examples of error handling.

USE_CASES.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ This documentation provides examples for specific use cases. Please [open an iss
77
* [How to Setup a Domain Whitelabel](#domain_whitelabel)
88
* [How to View Email Statistics](#email_stats)
99
* [Asynchronous Mail Send](#asynchronous-mail-send)
10+
* [Error Handling](#error-handling)
1011

1112
<a name="transactional-templates"></a>
1213
# Transactional Templates
@@ -272,3 +273,30 @@ if __name__ == "__main__":
272273
loop.run_until_complete(task)
273274
```
274275

276+
<a name="error-handling"></a>
277+
# Error Handling
278+
[Custom exceptions](https://github.com/sendgrid/python-http-client/blob/master/python_http_client/exceptions.py) for `python_http_client` are now supported, which can be imported by consuming libraries.
279+
280+
Please see [here](https://github.com/sendgrid/python-http-client/blob/master/python_http_client/exceptions.py) for a list of supported exceptions.
281+
282+
```python
283+
import sendgrid
284+
import os
285+
from sendgrid.helpers.mail import *
286+
from python_http_client import exceptions
287+
288+
sg = sendgrid.SendGridAPIClient(apikey=os.environ.get('SENDGRID_API_KEY'))
289+
from_email = Email("dx@sendgrid.com")
290+
to_email = Email("elmer.thomas@sendgrid.com")
291+
subject = "Sending with SendGrid is Fun"
292+
content = Content("text/plain", "and easy to do anywhere, even with Python")
293+
mail = Mail(from_email, subject, to_email, content)
294+
try:
295+
response = sg.client.mail.send.post(request_body=mail.get())
296+
except exceptions.BadRequestsError as e:
297+
print(e.body)
298+
exit()
299+
print(response.status_code)
300+
print(response.body)
301+
print(response.headers)
302+
```

register.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import pypandoc
2-
import os
32

43
output = pypandoc.convert('README.md', 'rst')
54
with open('README.txt' 'w+') as f:

sendgrid/__init__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
"""
2+
This library allows you to quickly and easily use the SendGrid Web API v3 via
3+
Python.
4+
5+
For more information on this library, see the README on Github.
6+
http://github.com/sendgrid/sendgrid-python
7+
For more information on the SendGrid v3 API, see the v3 docs:
8+
http://sendgrid.com/docs/API_Reference/api_v3.html
9+
For the user guide, code examples, and more, visit the main docs page:
10+
http://sendgrid.com/docs/index.html
11+
12+
Available subpackages
13+
---------------------
14+
helpers
15+
Modules to help with common tasks.
16+
"""
17+
118
from .version import __version__ # noqa
219
# v3 API
320
from .sendgrid import SendGridAPIClient # noqa

sendgrid/helpers/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
"""v3/mail/send response body builder
2+
3+
Builder for assembling emails to be sent with the v3 SendGrid API.
4+
5+
Usage example:
6+
def build_hello_email():
7+
to_email = from_email = Email("test@example.com")
8+
subject = "Hello World from the SendGrid Python Library"
9+
content = Content("text/plain", "some text here")
10+
mail = Mail(from_email, subject, to_email, content)
11+
mail.personalizations[0].add_to(Email("test2@example.com"))
12+
return mail.get() # assembled request body
13+
14+
For more usage examples, see
15+
https://github.com/sendgrid/sendgrid-python/tree/master/examples/helpers/mail
16+
17+
For more information on the v3 API, see
18+
https://sendgrid.com/docs/API_Reference/api_v3.html
19+
"""

0 commit comments

Comments
 (0)