Files
notifications-api/app/v2/notifications/create_response.py

67 lines
1.5 KiB
Python
Raw Normal View History

def create_post_sms_response_from_notification(
2023-08-29 14:54:30 -07:00
notification_id,
client_reference,
template_id,
template_version,
service_id,
content,
from_number,
url_root,
):
resp = __create_notification_response(
2023-08-29 14:54:30 -07:00
notification_id,
client_reference,
template_id,
template_version,
service_id,
url_root,
)
2023-08-29 14:54:30 -07:00
resp["content"] = {"from_number": from_number, "body": content}
return resp
def create_post_email_response_from_notification(
notification_id,
client_reference,
template_id,
template_version,
service_id,
content,
subject,
email_from,
url_root,
):
resp = __create_notification_response(
2023-08-29 14:54:30 -07:00
notification_id,
client_reference,
template_id,
template_version,
service_id,
url_root,
)
2023-08-29 14:54:30 -07:00
resp["content"] = {"from_email": email_from, "body": content, "subject": subject}
return resp
def __create_notification_response(
2023-08-29 14:54:30 -07:00
notification_id,
client_reference,
template_id,
template_version,
service_id,
url_root,
):
return {
"id": notification_id,
"reference": client_reference,
"uri": "{}v2/notifications/{}".format(url_root, str(notification_id)),
2023-08-29 14:54:30 -07:00
"template": {
"id": template_id,
"version": template_version,
"uri": "{}services/{}/templates/{}".format(
2023-08-29 14:54:30 -07:00
url_root, str(service_id), str(template_id)
),
},
2023-08-29 14:54:30 -07:00
"scheduled_for": None,
}