Skip to content

allow sending params in transmission list endpoint #140

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

Merged
merged 4 commits into from
Mar 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: analysis all build clean docs docs-install docs-open install release release-test test venv
.PHONY: analysis all build clean docs docs-install docs-open install release release-test test venv

all: clean venv install

Expand Down
13 changes: 10 additions & 3 deletions sparkpost/transmissions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import base64
import copy
import json
import warnings
from email.utils import parseaddr

from .base import Resource
Expand Down Expand Up @@ -265,15 +266,21 @@ def get(self, transmission_id):
results = self._fetch_get(transmission_id)
return results['transmission']

def list(self):
def list(self, **kwargs):
"""
Get a list of your transmissions

:param campaign_id: ID of the campaign used by the transmissions
:param template_id: ID of the template used by the transmissions

:returns: list of transmissions
:raises: :exc:`SparkPostAPIException` if API call fails
"""
results = self.request('GET', self.uri)
return results
warn_msg = 'This endpoint is deprecated. For details, '
'check https://sparkpo.st/5qcj4.'

warnings.warn(warn_msg, DeprecationWarning)
return self.request('GET', self.uri, params=kwargs)

def delete(self, transmission_id):
"""
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ pytest==2.8.7
pytest-cov==1.8.1
requests==2.5.1
responses==0.3.0
mock==2.0.0
22 changes: 21 additions & 1 deletion test/test_transmissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
import json
import os
import tempfile
import warnings

import pytest
import responses
import six
from mock import patch

from sparkpost import SparkPost
from sparkpost import Transmissions
Expand Down Expand Up @@ -297,7 +299,8 @@ def test_fail_get():


@responses.activate
def test_success_list():
@patch.object(warnings, 'warn')
def test_success_list(mock_warn):
responses.add(
responses.GET,
'https://api.sparkpost.com/api/v1/transmissions',
Expand All @@ -307,6 +310,23 @@ def test_success_list():
)
sp = SparkPost('fake-key')
response = sp.transmission.list()
assert mock_warn.called
assert response == []


@responses.activate
def test_success_list_with_params():
responses.add(
responses.GET,
'https://api.sparkpost.com/api/v1/transmissions?template_id=abcd',
status=200,
content_type='application/json',
body='{"results": []}',
match_querystring=True

)
sp = SparkPost('fake-key')
response = sp.transmission.list(template_id='abcd')
assert response == []


Expand Down