Skip to content

Commit 6df44e1

Browse files
authored
Merge pull request #65 from sailthru/update_postback
adding postback for updates
2 parents 98cdba3 + efaa833 commit 6df44e1

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

CHANGES

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@
3131
- Adding schedule_time parameter support for multi_send fix
3232
- API Rate Limit values are now Integers
3333
- Adding stats_send helper function to retrieve information about a particular transactional template
34+
35+
2.3.3
36+
====
37+
- Adding update postback

sailthru/sailthru_client.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,30 @@ def receive_verify_post(self, post_params):
597597

598598
return True
599599

600+
def receive_update_post(self, post_params):
601+
"""
602+
Update postbacks
603+
"""
604+
605+
if isinstance(post_params, dict):
606+
required_params = ['action', 'email', 'sig']
607+
if not self.check_for_valid_postback_actions(required_params, post_params):
608+
return False
609+
else:
610+
return False
611+
612+
if post_params['action'] != 'update':
613+
return False
614+
615+
signature = post_params['sig']
616+
post_params = post_params.copy()
617+
del post_params['sig']
618+
619+
if signature != get_signature_hash(post_params, self.secret):
620+
return False
621+
622+
return True
623+
600624
def receive_optout_post(self, post_params):
601625
"""
602626
Optout postbacks

sailthru/sailthru_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def sailthru_http_request(url, data, method, file_data=None):
3636
params, data = (None, data) if method == 'POST' else (data, None)
3737

3838
try:
39-
headers = {'User-Agent': 'Sailthru API Python Client %s; Python Version: %s' % ('2.3.2', platform.python_version())}
39+
headers = {'User-Agent': 'Sailthru API Python Client %s; Python Version: %s' % ('2.3.3', platform.python_version())}
4040
response = requests.request(method, url, params=params, data=data, files=file_data, headers=headers, timeout=10)
4141
return SailthruResponse(response)
4242
except requests.HTTPError as e:

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import setup, find_packages
22

33
setup(name='sailthru-client',
4-
version='2.3.2',
4+
version='2.3.3',
55
packages=find_packages(),
66
description='Python client for Sailthru API',
77
long_description=open('README.md').read(),

0 commit comments

Comments
 (0)