mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-03-02 07:11:14 -05:00
> Service teams that use the admin interface often need to know the > outcome of a message... at the moment they have to page through all > the results in the activity stream. They should be able to find > notifications by email address or phone number. – https://www.pivotaltracker.com/n/projects/1443052 This commit adds an additional query string parameter (`to`) to the URL, which users can use to filter down the list of notifications. It: - takes the status into account - doesn’t update the counts based on the search term (in reality each service will only send a handful of notifications to one person in any 7 day period) In other words the funnel that filters down the notifications looks like: > all notifications for service → only failed → only to this phone > number
57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
from app.notify_client import NotifyAdminAPIClient
|
|
|
|
|
|
class NotificationApiClient(NotifyAdminAPIClient):
|
|
def __init__(self):
|
|
super().__init__("a", "b", "c")
|
|
|
|
def init_app(self, app):
|
|
self.base_url = app.config['API_HOST_NAME']
|
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
|
|
|
def get_notifications_for_service(
|
|
self,
|
|
service_id,
|
|
job_id=None,
|
|
template_type=None,
|
|
status=None,
|
|
page=None,
|
|
page_size=None,
|
|
limit_days=None,
|
|
include_jobs=None,
|
|
include_from_test_key=None,
|
|
format_for_csv=None,
|
|
to=None,
|
|
):
|
|
params = {}
|
|
if page is not None:
|
|
params['page'] = page
|
|
if page_size is not None:
|
|
params['page_size'] = page_size
|
|
if template_type is not None:
|
|
params['template_type'] = template_type
|
|
if status is not None:
|
|
params['status'] = status
|
|
if include_jobs is not None:
|
|
params['include_jobs'] = include_jobs
|
|
if include_from_test_key is not None:
|
|
params['include_from_test_key'] = include_from_test_key
|
|
if format_for_csv is not None:
|
|
params['format_for_csv'] = format_for_csv
|
|
if to is not None:
|
|
params['to'] = to
|
|
if job_id:
|
|
return self.get(
|
|
url='/service/{}/job/{}/notifications'.format(service_id, job_id),
|
|
params=params
|
|
)
|
|
else:
|
|
if limit_days is not None:
|
|
params['limit_days'] = limit_days
|
|
|
|
return self.get(
|
|
url='/service/{}/notifications'.format(service_id),
|
|
params=params
|
|
)
|