mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-18 05:29:38 -04:00
merge from main
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
from app.notify_client import NotifyAdminAPIClient, _attach_current_user
|
||||
|
||||
|
||||
class ContactListApiClient(NotifyAdminAPIClient):
|
||||
|
||||
def create_contact_list(
|
||||
self,
|
||||
*,
|
||||
service_id,
|
||||
upload_id,
|
||||
original_file_name,
|
||||
row_count,
|
||||
template_type,
|
||||
):
|
||||
data = {
|
||||
"id": upload_id,
|
||||
"original_file_name": original_file_name,
|
||||
"row_count": row_count,
|
||||
"template_type": template_type,
|
||||
}
|
||||
|
||||
data = _attach_current_user(data)
|
||||
job = self.post(url='/service/{}/contact-list'.format(service_id), data=data)
|
||||
|
||||
return job
|
||||
|
||||
def get_contact_lists(self, service_id):
|
||||
return self.get(f'/service/{service_id}/contact-list')
|
||||
|
||||
def get_contact_list(self, *, service_id, contact_list_id):
|
||||
return self.get(f'/service/{service_id}/contact-list/{contact_list_id}')
|
||||
|
||||
def delete_contact_list(self, *, service_id, contact_list_id):
|
||||
return self.delete(f'/service/{service_id}/contact-list/{contact_list_id}')
|
||||
|
||||
|
||||
contact_list_api_client = ContactListApiClient()
|
||||
@@ -25,14 +25,12 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
|
||||
return job
|
||||
|
||||
def get_jobs(self, service_id, *, limit_days=None, contact_list_id=None, statuses=None, page=1):
|
||||
def get_jobs(self, service_id, *, limit_days=None, statuses=None, page=1):
|
||||
params = {'page': page}
|
||||
if limit_days is not None:
|
||||
params['limit_days'] = limit_days
|
||||
if statuses is not None:
|
||||
params['statuses'] = ','.join(statuses)
|
||||
if contact_list_id is not None:
|
||||
params['contact_list_id'] = contact_list_id
|
||||
|
||||
return self.get(url='/service/{}/job'.format(service_id), params=params)
|
||||
|
||||
@@ -53,12 +51,11 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
if job['job_status'] != 'cancelled'
|
||||
)
|
||||
|
||||
def get_page_of_jobs(self, service_id, *, page, statuses=None, contact_list_id=None, limit_days=None):
|
||||
def get_page_of_jobs(self, service_id, *, page, statuses=None, limit_days=None):
|
||||
return self.get_jobs(
|
||||
service_id,
|
||||
statuses=statuses or self.NON_SCHEDULED_JOB_STATUSES,
|
||||
page=page,
|
||||
contact_list_id=contact_list_id,
|
||||
limit_days=limit_days,
|
||||
)
|
||||
|
||||
@@ -88,15 +85,12 @@ class JobApiClient(NotifyAdminAPIClient):
|
||||
def has_jobs(self, service_id):
|
||||
return bool(self.get_jobs(service_id)['data'])
|
||||
|
||||
def create_job(self, job_id, service_id, scheduled_for=None, contact_list_id=None):
|
||||
def create_job(self, job_id, service_id, scheduled_for=None):
|
||||
data = {"id": job_id}
|
||||
|
||||
if scheduled_for:
|
||||
data.update({'scheduled_for': scheduled_for})
|
||||
|
||||
if contact_list_id:
|
||||
data.update({'contact_list_id': contact_list_id})
|
||||
|
||||
data = _attach_current_user(data)
|
||||
job = self.post(url='/service/{}/job'.format(service_id), data=data)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user