Skip to content
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

Merged
merged 12 commits into from
May 25, 2017
Merged

Update docs for 2.x #152

merged 12 commits into from
May 25, 2017

Conversation

richleland
Copy link
Contributor

Resolves #144

@richleland richleland changed the base branch from master to 2.x May 23, 2017 14:52
Copy link
Contributor

@ewandennis ewandennis left a 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.
Copy link
Contributor

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
Copy link
Contributor

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...)

Copy link
Contributor Author

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.
Copy link
Contributor

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
Copy link
Contributor

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

Copy link
Contributor Author

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',
Copy link
Contributor

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)
Copy link
Contributor

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

Copy link
Contributor Author

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

@richleland richleland merged commit 7030e43 into 2.x May 25, 2017
@richleland richleland deleted the issue-144 branch May 25, 2017 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants