Skip to content

Commit 610e933

Browse files
enugentdtthinkingserious
authored andcommitted
Handle new API in the helper example (#818)
* Fix to handle new API * Make it return the raw Mail object rather than a JSON representation
1 parent f549dc0 commit 610e933

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

examples/helpers/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ content = Content("text/plain", "some text here")
2121
The `Content` class takes mainly two parameters: MIME type and the actual content of the email, it then returns the JSON-ready representation of this content.
2222

2323
```
24-
mail = Mail(from_email, subject, to_email, content)
24+
mail = Mail(from_email, to_email, subject, content)
2525
```
2626
After adding the above we create a mail object using `Mail` class, it takes the following parameters: email address to send from, subject line of emails, email address to send to, content of the message.
2727
For more information on parameters and usage, see [here](https://github.com/sendgrid/sendgrid-python/blob/master/sendgrid/helpers/mail/mail.py)
@@ -58,7 +58,7 @@ After you have configured every component and added your own functions, you can
5858
```
5959
sg = SendGridAPIClient()
6060
data = build_kitchen_sink()
61-
response = sg.client.mail.send.post(request_body=data)
61+
response = sg.send(data)
6262
```
6363
Make sure you have [environment variable](https://github.com/sendgrid/sendgrid-python/blob/master/TROUBLESHOOTING.md#environment-variables-and-your-sendgrid-api-key) set up!
6464
Full example [here](https://github.com/sendgrid/sendgrid-python/blob/0b683169b08d3a7c204107cd333be33053297e74/examples/helpers/mail_example.py#L203).

examples/helpers/mail_example.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def build_kitchen_sink():
306306
UtmCampaign("utm_campaign"))
307307
message.tracking_settings = tracking_settings
308308

309-
return message.get()
309+
return message
310310

311311

312312
def send_hello_email():

0 commit comments

Comments
 (0)