2016-03-02 13:52:05 +00:00
|
|
|
from notifications_python_client.base import BaseAPIClient
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class NotificationApiClient(BaseAPIClient):
|
2016-09-12 12:14:57 +01:00
|
|
|
def __init__(self):
|
2016-09-12 14:59:53 +01:00
|
|
|
super().__init__("a", "b", "c")
|
2016-03-02 13:52:05 +00:00
|
|
|
|
|
|
|
|
def init_app(self, app):
|
|
|
|
|
self.base_url = app.config['API_HOST_NAME']
|
2016-09-08 15:55:07 +01:00
|
|
|
self.service_id = app.config['ADMIN_CLIENT_USER_NAME']
|
|
|
|
|
self.api_key = app.config['ADMIN_CLIENT_SECRET']
|
2016-03-02 13:52:05 +00:00
|
|
|
|
2016-09-21 09:28:06 +01:00
|
|
|
def get_notifications_for_service(
|
|
|
|
|
self,
|
|
|
|
|
service_id,
|
|
|
|
|
job_id=None,
|
|
|
|
|
template_type=None,
|
|
|
|
|
status=None,
|
|
|
|
|
page=None,
|
|
|
|
|
page_size=None,
|
2016-09-21 09:32:20 +01:00
|
|
|
limit_days=None,
|
|
|
|
|
include_jobs=None,
|
|
|
|
|
include_from_test_key=None
|
2016-09-21 09:28:06 +01:00
|
|
|
):
|
2016-03-02 13:52:05 +00:00
|
|
|
params = {}
|
|
|
|
|
if page is not None:
|
|
|
|
|
params['page'] = page
|
2016-04-19 11:45:36 +01:00
|
|
|
if page_size is not None:
|
|
|
|
|
params['page_size'] = page_size
|
2016-04-04 16:34:06 +01:00
|
|
|
if template_type is not None:
|
|
|
|
|
params['template_type'] = template_type
|
|
|
|
|
if status is not None:
|
|
|
|
|
params['status'] = status
|
2016-09-21 09:32:20 +01:00
|
|
|
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
|
2016-03-02 13:52:05 +00:00
|
|
|
if job_id:
|
|
|
|
|
return self.get(
|
|
|
|
|
url='/service/{}/job/{}/notifications'.format(service_id, job_id),
|
|
|
|
|
params=params
|
|
|
|
|
)
|
|
|
|
|
else:
|
2016-04-28 15:50:05 +01:00
|
|
|
if limit_days is not None:
|
|
|
|
|
params['limit_days'] = limit_days
|
|
|
|
|
|
2016-03-02 13:52:05 +00:00
|
|
|
return self.get(
|
|
|
|
|
url='/service/{}/notifications'.format(service_id),
|
|
|
|
|
params=params
|
|
|
|
|
)
|