Skip to content

Commit f3d2ec6

Browse files
authored
Merge pull request #140 from SparkPost/issue133
allow sending params in transmission list endpoint
2 parents 266b3a7 + 6989132 commit f3d2ec6

File tree

4 files changed

+33
-5
lines changed

4 files changed

+33
-5
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: analysis all build clean docs docs-install docs-open install release release-test test venv
1+
.PHONY: analysis all build clean docs docs-install docs-open install release release-test test venv
22

33
all: clean venv install
44

sparkpost/transmissions.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import base64
22
import copy
33
import json
4+
import warnings
45
from email.utils import parseaddr
56

67
from .base import Resource
@@ -270,15 +271,21 @@ def get(self, transmission_id):
270271
results = self._fetch_get(transmission_id)
271272
return results['transmission']
272273

273-
def list(self):
274+
def list(self, **kwargs):
274275
"""
275276
Get a list of your transmissions
276277
278+
:param campaign_id: ID of the campaign used by the transmissions
279+
:param template_id: ID of the template used by the transmissions
280+
277281
:returns: list of transmissions
278282
:raises: :exc:`SparkPostAPIException` if API call fails
279283
"""
280-
results = self.request('GET', self.uri)
281-
return results
284+
warn_msg = 'This endpoint is deprecated. For details, '
285+
'check https://sparkpo.st/5qcj4.'
286+
287+
warnings.warn(warn_msg, DeprecationWarning)
288+
return self.request('GET', self.uri, params=kwargs)
282289

283290
def delete(self, transmission_id):
284291
"""

test-requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ pytest==2.8.7
33
pytest-cov==1.8.1
44
requests==2.5.1
55
responses==0.3.0
6+
mock==2.0.0

test/test_transmissions.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
import json
33
import os
44
import tempfile
5+
import warnings
56

67
import pytest
78
import responses
89
import six
10+
from mock import patch
911

1012
from sparkpost import SparkPost
1113
from sparkpost import Transmissions
@@ -303,7 +305,8 @@ def test_fail_get():
303305

304306

305307
@responses.activate
306-
def test_success_list():
308+
@patch.object(warnings, 'warn')
309+
def test_success_list(mock_warn):
307310
responses.add(
308311
responses.GET,
309312
'https://api.sparkpost.com/api/v1/transmissions',
@@ -313,6 +316,23 @@ def test_success_list():
313316
)
314317
sp = SparkPost('fake-key')
315318
response = sp.transmission.list()
319+
assert mock_warn.called
320+
assert response == []
321+
322+
323+
@responses.activate
324+
def test_success_list_with_params():
325+
responses.add(
326+
responses.GET,
327+
'https://api.sparkpost.com/api/v1/transmissions?template_id=abcd',
328+
status=200,
329+
content_type='application/json',
330+
body='{"results": []}',
331+
match_querystring=True
332+
333+
)
334+
sp = SparkPost('fake-key')
335+
response = sp.transmission.list(template_id='abcd')
316336
assert response == []
317337

318338

0 commit comments

Comments
 (0)