Skip to content

Commit 2a1476a

Browse files
authored
fix: keyerror when calling trigger_data (#20)
1 parent 67fba40 commit 2a1476a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

knockapi/resources/messages.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def list(self, options=None):
1515
"""
1616
endpoint = '/messages'
1717

18-
if options and options['trigger_data']:
18+
if options and options.get('trigger_data'):
1919
options['trigger_data'] = json.dumps(options['trigger_data'])
2020

2121
return self.client.request('get', endpoint, payload=options)
@@ -58,7 +58,7 @@ def get_activities(self, id, options=None):
5858
"""
5959
endpoint = '/messages/{}/activities'.format(id)
6060

61-
if options and options['trigger_data']:
61+
if options and options.get('trigger_data'):
6262
options['trigger_data'] = json.dumps(options['trigger_data'])
6363

6464
return self.client.request('get', endpoint, options)

knockapi/resources/objects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ def get_messages(self, collection, id, options=None):
152152
"""
153153
endpoint = '/objects/{}/{}/messages'.format(collection, id)
154154

155-
if options and options['trigger_data']:
155+
if options and options.get('trigger_data'):
156156
options['trigger_data'] = json.dumps(options['trigger_data'])
157157

158158
return self.client.request('get', endpoint, payload=options)

knockapi/resources/users.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def get_feed(self, user_id, channel_id, options=None):
9393
"""
9494
endpoint = '/users/{}/feeds/{}'.format(user_id, channel_id)
9595

96-
if options and options['trigger_data']:
96+
if options and options.get('trigger_data'):
9797
options['trigger_data'] = json.dumps(options['trigger_data'])
9898

9999
return self.client.request('get', endpoint, payload=options)

0 commit comments

Comments
 (0)