mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-05 00:20:43 -04:00
Update get_notifications_for_service to make POST requests
This updates the `get_notifications_for_service` of the `NotificationApiClient` to make POST request to the api when the `to` field is provided. This is done so that we avoid logging personal details such as email addreses. If the `to` field is not present, the method will make a GET reqeust and there will be no change to how it works.
This commit is contained in:
committed by
Katie Smith
parent
444d844dfb
commit
04fa99b3dc
@@ -19,7 +19,6 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
to=None,
|
||||
include_one_off=None,
|
||||
):
|
||||
# TODO: if "to" is included, this should be a POST
|
||||
params = {
|
||||
'page': page,
|
||||
'page_size': page_size,
|
||||
@@ -35,17 +34,22 @@ class NotificationApiClient(NotifyAdminAPIClient):
|
||||
|
||||
params = {k: v for k, v in params.items() if v is not None}
|
||||
|
||||
# if `to` is set it is likely PII like an email address or mobile which
|
||||
# we do not want in our logs, so we do a POST request instead of a GET
|
||||
method = self.post if to else self.get
|
||||
kwargs = {'data': params} if to else {'params': params}
|
||||
|
||||
if job_id:
|
||||
return self.get(
|
||||
return method(
|
||||
url='/service/{}/job/{}/notifications'.format(service_id, job_id),
|
||||
params=params
|
||||
**kwargs
|
||||
)
|
||||
else:
|
||||
if limit_days is not None:
|
||||
params['limit_days'] = limit_days
|
||||
return self.get(
|
||||
return method(
|
||||
url='/service/{}/notifications'.format(service_id),
|
||||
params=params
|
||||
**kwargs
|
||||
)
|
||||
|
||||
def send_notification(self, service_id, *, template_id, recipient, personalisation, sender_id):
|
||||
|
||||
Reference in New Issue
Block a user