Skip to content

Commit af4cea5

Browse files
committed
Merge branch 'master' of github.com:SparkPost/python-sparkpost into ISSUE-16
2 parents 05498f0 + 39b4581 commit af4cea5

16 files changed

+439
-9
lines changed

docs/api/recipient_lists.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. module:: sparkpost.recipient_lists
2+
3+
:mod:`sparkpost.recipient_lists`
4+
================================
5+
6+
.. autoclass:: RecipientLists
7+
:members:

docs/api/transmissions.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
.. module:: sparkpost.transmission
1+
.. module:: sparkpost.transmissions
22

3-
:mod:`sparkpost.transmission`
4-
=============================
3+
:mod:`sparkpost.transmissions`
4+
==============================
55

6-
.. autoclass:: Transmission
6+
.. autoclass:: Transmissions
77
:members:

docs/resources/recipient_lists.rst

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
Recipient Lists
2+
===============
3+
4+
Let's use the underlying `recipient_lists API`_ to create a recipient list:
5+
6+
.. code-block:: python
7+
8+
from sparkpost import SparkPost
9+
10+
sp = SparkPost()
11+
12+
response = sp.recipient_lists.create(
13+
id='UNIQUE_TEST_ID',
14+
name='Test Recipient list',
15+
recipients=[
16+
{
17+
'address': {
18+
'email': '[email protected]'
19+
}
20+
},
21+
{
22+
'address': {
23+
'email': '[email protected]'
24+
}
25+
},
26+
{
27+
'address': {
28+
'email': '[email protected]'
29+
}
30+
}
31+
]
32+
)
33+
34+
print response
35+
# outputs {u'total_accepted_recipients': 3, u'id': u'UNIQUE_TEST_ID', u'total_rejected_recipients': 0, u'name':'Test Recipient list'}
36+
37+
.. _recipient_lists API: https://www.sparkpost.com/api#/reference/recipient-lists
38+
39+
40+
Retrieve a recipient list
41+
-------------------------
42+
43+
.. code-block:: python
44+
45+
from sparkpost import SparkPost
46+
47+
sp = SparkPost()
48+
49+
sp.recipient_lists.get('my-list-id')
50+
51+
52+
List all recipient lists
53+
------------------------
54+
55+
.. code-block:: python
56+
57+
from sparkpost import SparkPost
58+
59+
sp = SparkPost()
60+
61+
sp.recipient_lists.list()
62+
63+
64+
API reference
65+
-------------
66+
67+
:doc:`/api/recipient_lists`
68+
69+
70+
Further examples
71+
----------------
72+
73+
See the `python-sparkpost recipient_lists examples`_.
74+
75+
.. _python-sparkpost recipient_lists examples: https://github.com/SparkPost/python-sparkpost/tree/master/examples/recipient_lists
76+
77+
78+
Additional documentation
79+
------------------------
80+
81+
See the `SparkPost Recipient Lists API Reference`_.
82+
83+
.. _SparkPost Recipient Lists API Reference: https://www.sparkpost.com/api#/reference/recipient_lists
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from sparkpost import SparkPost
2+
3+
sp = SparkPost('YOUR API KEY')
4+
response = sp.recipient_lists.create(
5+
id='UNIQUE_TEST_ID',
6+
name='Test Recipient list',
7+
recipients=[
8+
{
9+
'address': {
10+
'email': '[email protected]'
11+
}
12+
},
13+
{
14+
'address': {
15+
'email': '[email protected]'
16+
}
17+
},
18+
{
19+
'address': {
20+
'email': '[email protected]'
21+
}
22+
}
23+
]
24+
)
25+
print response
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from sparkpost import SparkPost
2+
3+
sp = SparkPost('YOUR API KEY')
4+
result = sp.recipient_lists.delete('list_id')
5+
print result
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from sparkpost import SparkPost
2+
3+
sp = SparkPost('YOUR API KEY')
4+
recipient_list = sp.recipient_lists.get('list_id')
5+
print recipient_list
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from sparkpost import SparkPost
2+
3+
sp = SparkPost('YOUR API KEY')
4+
recipient_list = sp.recipient_lists.get('list_id', True)
5+
print recipient_list
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
from sparkpost import SparkPost
2+
3+
sp = SparkPost('YOUR API KEY')
4+
recipient_lists = sp.recipient_lists.list()
5+
print recipient_lists
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from sparkpost import SparkPost
2+
3+
sp = SparkPost('YOUR API KEY')
4+
response = sp.recipient_lists.update(
5+
'EXISTING_TEST_ID',
6+
name='Test Recipient list',
7+
recipients=[
8+
{
9+
'address': {
10+
'email': '[email protected]'
11+
}
12+
},
13+
{
14+
'address': {
15+
'email': '[email protected]'
16+
}
17+
},
18+
{
19+
'address': {
20+
'email': '[email protected]'
21+
}
22+
}
23+
]
24+
)
25+
print response

examples/templates/delete_template.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from sparkpost import SparkPost
22

33
sp = SparkPost('YOUR API KEY')
4-
template = sp.transmission.delete('template_id')
5-
print template
4+
result = sp.templates.delete('template_id')
5+
print result

0 commit comments

Comments
 (0)