2017-12-01 15:30:18 +00:00
|
|
|
|
2017-07-20 15:23:46 +01:00
|
|
|
|
2020-06-17 12:11:28 +01:00
|
|
|
def create_post_sms_response_from_notification(
|
|
|
|
|
notification_id, client_reference, template_id, template_version, service_id,
|
2020-06-16 14:33:53 +01:00
|
|
|
content, from_number, url_root, scheduled_for
|
|
|
|
|
):
|
2020-06-17 12:11:28 +01:00
|
|
|
resp = __create_notification_response(
|
2020-06-16 14:33:53 +01:00
|
|
|
notification_id, client_reference, template_id, template_version, service_id, url_root, scheduled_for
|
|
|
|
|
)
|
|
|
|
|
resp['content'] = {
|
|
|
|
|
'from_number': from_number,
|
|
|
|
|
'body': content
|
|
|
|
|
}
|
|
|
|
|
return resp
|
|
|
|
|
|
|
|
|
|
|
2020-06-17 12:11:28 +01:00
|
|
|
def create_post_email_response_from_notification(
|
|
|
|
|
notification_id,
|
|
|
|
|
client_reference,
|
|
|
|
|
template_id,
|
|
|
|
|
template_version,
|
|
|
|
|
service_id,
|
|
|
|
|
content,
|
|
|
|
|
subject,
|
|
|
|
|
email_from,
|
|
|
|
|
url_root,
|
|
|
|
|
scheduled_for
|
|
|
|
|
):
|
|
|
|
|
resp = __create_notification_response(
|
2020-06-16 14:33:53 +01:00
|
|
|
notification_id, client_reference, template_id, template_version, service_id, url_root, scheduled_for
|
|
|
|
|
)
|
|
|
|
|
resp['content'] = {
|
|
|
|
|
"from_email": email_from,
|
|
|
|
|
"body": content,
|
|
|
|
|
"subject": subject
|
|
|
|
|
}
|
|
|
|
|
return resp
|
|
|
|
|
|
|
|
|
|
|
2020-06-17 12:11:28 +01:00
|
|
|
def create_post_letter_response_from_notification(
|
2020-06-16 14:33:53 +01:00
|
|
|
notification_id, client_reference, template_id, template_version, service_id,
|
|
|
|
|
content, subject, url_root, scheduled_for
|
|
|
|
|
):
|
2020-06-17 12:11:28 +01:00
|
|
|
resp = __create_notification_response(
|
2020-06-16 14:33:53 +01:00
|
|
|
notification_id, client_reference, template_id, template_version, service_id, url_root, scheduled_for
|
|
|
|
|
)
|
|
|
|
|
resp['content'] = {
|
|
|
|
|
"body": content,
|
|
|
|
|
"subject": subject
|
|
|
|
|
}
|
|
|
|
|
return resp
|
|
|
|
|
|
|
|
|
|
|
2020-06-17 12:11:28 +01:00
|
|
|
def __create_notification_response(
|
2020-06-16 14:33:53 +01:00
|
|
|
notification_id, client_reference, template_id, template_version, service_id, url_root, scheduled_for
|
|
|
|
|
):
|
|
|
|
|
return {
|
|
|
|
|
"id": notification_id,
|
|
|
|
|
"reference": client_reference,
|
|
|
|
|
"uri": "{}v2/notifications/{}".format(url_root, str(notification_id)),
|
|
|
|
|
'template': {
|
|
|
|
|
"id": template_id,
|
|
|
|
|
"version": template_version,
|
|
|
|
|
"uri": "{}services/{}/templates/{}".format(
|
|
|
|
|
url_root,
|
|
|
|
|
str(service_id),
|
|
|
|
|
str(template_id)
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
"scheduled_for": scheduled_for if scheduled_for else None
|
|
|
|
|
}
|