Skip to content

Commit ef8fba6

Browse files
committed
fix to notifications entry layout
1 parent 4c0a62d commit ef8fba6

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed

planet/order_request.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,21 @@ def notifications(email: Optional[bool] = None,
143143
webhook_per_order: Request a single webhook call per order instead
144144
of one call per each delivered item.
145145
'''
146-
return dict((k, v) for k, v in locals().items() if v)
146+
notifications_dict = {}
147+
148+
if webhook_url:
149+
webhook_dict = {
150+
'url': webhook_url
151+
}
152+
if webhook_per_order is not None:
153+
webhook_dict['per_order'] = webhook_per_order
154+
155+
notifications_dict['webhook'] = webhook_dict
156+
157+
if email is not None:
158+
notifications_dict['email'] = email
159+
160+
return notifications_dict
147161

148162

149163
def delivery(archive_type: Optional[str] = None,

tests/unit/test_order_request.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ def test_build_request():
4646
}
4747
}
4848
notifications = {
49-
'email': 'email',
50-
'webhook_url': 'webhookurl',
51-
'webhook_per_order': True
49+
'email': 'email', 'webhook': {
50+
'url': 'webhookurl', 'per_order': True
51+
}
5252
}
5353
order_type = 'partial'
5454
tool = {'bandmath': 'jsonstring'}
@@ -121,9 +121,9 @@ def test_notifications():
121121
notifications_config = order_request.notifications(
122122
email='email', webhook_url='webhookurl', webhook_per_order=True)
123123
expected = {
124-
'email': 'email',
125-
'webhook_url': 'webhookurl',
126-
'webhook_per_order': True
124+
'email': 'email', 'webhook': {
125+
'url': 'webhookurl', 'per_order': True
126+
}
127127
}
128128
assert notifications_config == expected
129129

0 commit comments

Comments
 (0)