-
Notifications
You must be signed in to change notification settings - Fork 67
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
Update docs for 2.x #152
Update docs for 2.x #152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor suggestions inline.
README.rst
Outdated
Custom wrappers | ||
=============== | ||
|
||
The ``sp.transmissions`` object is a wrapper around the library's `base resource`_. We create wrappers to add some syntactic sugar on top of our API. For example, adding ``cc`` and ``bcc`` to a transmission. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tiny nit: There's a sentence fragment in there. For example, adding cc and bcc to a transmission
.
How about: For example, the wrapper makes it easy to add CC and BCC recipients to a transmission
.
|
||
We recommend the `django-anymail`_ package for using SparkPost with Django. | ||
|
||
.. _django-anymail: https://github.com/anymail/django-anymail | ||
|
||
Using with Google Cloud |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it worth linking to our 2 Google App Engine python samples?
(...and we should likely update them once python-sparkpsot 2.0 drops...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
docs/index.rst
Outdated
Custom wrappers | ||
=============== | ||
|
||
The ``sp.transmissions`` object is a wrapper around the library's `base resource`_. We create wrappers to add some syntactic sugar on top of our API. For example, adding ``cc`` and ``bcc`` to a transmission. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the same sentence fragment as in the README.
For example, the wrapper makes it easy to add CC and BCC recipients to a transmission
.
|
||
.. _django-anymail: https://github.com/anymail/django-anymail | ||
|
||
Using with Google Cloud |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment about out GAE samples: https://github.com/search?q=org%3ASparkPost+google
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added
response = sp.transmissions.post({ | ||
'options': { | ||
'sandbox': True, | ||
'start_time': '2015-11-06T09:10:00-05:00', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we show how to relate python datetime to our start_time format? It's a really common question. Something like this?
(Jeez python - include some tzinfo batteries):
from datetime import datetime, timedelta, tzinfo
class EasternTime(tzinfo):
"""UTC+5 tzinfo implementation"""
# can be configured here
_offset = timedelta(hours = -5)
_dst = timedelta(hours=1)
_name = "-05:00"
def utcoffset(self, dt):
return self.__class__._offset
def dst(self, dt):
return self.__class__._dst
def tzname(self, dt):
return self.__class__._name
py_start_time = datetime(2015, 1, 6, 9, 10, 0, tzinfo=EasternTime())
start_time = py_start_time.strftime('%Y-%m-%dT%H:%M:%S%Z')
'html': '<p>Hello world!</p>', | ||
}, | ||
'campaign_id': 'python-sparkpost example', | ||
}) | ||
except SparkPostAPIException as err: | ||
# http response status code | ||
print(err.status) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we crack open the SparkPostAPIException
type in this example? It'd be good to show how to recognise HTTP-level errors (e.g. 401 and 5xx) and extract API-level detail to help diagnose.
There's some sample code here: https://github.com/SparkPost/appengine-std-python-sample/blob/master/main.py#L32
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a loop that prints out error specifics
Resolves #144