mirror of
https://github.com/GSA/notifications-api.git
synced 2025-12-22 16:31:15 -05:00
Update the post letter flow - not able to get reduce the dB transactions used in the letter flow. Prioritising the reduction for the SMS/Email flow.
Only update the daily limit cache if the service is in trial mode.
This commit is contained in:
@@ -1,57 +1,10 @@
|
||||
|
||||
|
||||
def create_post_sms_response_from_notification(notification, content, from_number, url_root, scheduled_for):
|
||||
noti = __create_notification_response(notification, url_root, scheduled_for)
|
||||
noti['content'] = {
|
||||
'from_number': from_number,
|
||||
'body': content
|
||||
}
|
||||
return noti
|
||||
|
||||
|
||||
def create_post_email_response_from_notification(notification, content, subject, email_from, url_root, scheduled_for):
|
||||
noti = __create_notification_response(notification, url_root, scheduled_for)
|
||||
noti['content'] = {
|
||||
"from_email": email_from,
|
||||
"body": content,
|
||||
"subject": subject
|
||||
}
|
||||
return noti
|
||||
|
||||
|
||||
def create_post_letter_response_from_notification(notification, content, subject, url_root, scheduled_for):
|
||||
noti = __create_notification_response(notification, url_root, scheduled_for)
|
||||
noti['content'] = {
|
||||
"body": content,
|
||||
"subject": subject
|
||||
}
|
||||
return noti
|
||||
|
||||
|
||||
def __create_notification_response(notification, url_root, scheduled_for):
|
||||
return {
|
||||
"id": notification.id,
|
||||
"reference": notification.client_reference,
|
||||
"uri": "{}v2/notifications/{}".format(url_root, str(notification.id)),
|
||||
'template': {
|
||||
"id": notification.template_id,
|
||||
"version": notification.template_version,
|
||||
"uri": "{}services/{}/templates/{}".format(
|
||||
url_root,
|
||||
str(notification.service_id),
|
||||
str(notification.template_id)
|
||||
)
|
||||
},
|
||||
"scheduled_for": scheduled_for if scheduled_for else None
|
||||
}
|
||||
|
||||
|
||||
# test detaching notification
|
||||
def create_post_sms_response_from_notification_detached(
|
||||
notification_id, client_reference, template_id, template_version, service_id,
|
||||
def create_post_sms_response_from_notification(
|
||||
notification_id, client_reference, template_id, template_version, service_id,
|
||||
content, from_number, url_root, scheduled_for
|
||||
):
|
||||
resp = __create_notification_response_detached(
|
||||
resp = __create_notification_response(
|
||||
notification_id, client_reference, template_id, template_version, service_id, url_root, scheduled_for
|
||||
)
|
||||
resp['content'] = {
|
||||
@@ -61,10 +14,19 @@ def create_post_sms_response_from_notification_detached(
|
||||
return resp
|
||||
|
||||
|
||||
def create_post_email_response_from_notification_detached(
|
||||
notification_id, client_reference, template_id, template_version, service_id, content, subject, email_from,
|
||||
url_root, scheduled_for):
|
||||
resp = __create_notification_response_detached(
|
||||
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(
|
||||
notification_id, client_reference, template_id, template_version, service_id, url_root, scheduled_for
|
||||
)
|
||||
resp['content'] = {
|
||||
@@ -75,11 +37,11 @@ def create_post_email_response_from_notification_detached(
|
||||
return resp
|
||||
|
||||
|
||||
def create_post_letter_response_from_notification_detached(
|
||||
def create_post_letter_response_from_notification(
|
||||
notification_id, client_reference, template_id, template_version, service_id,
|
||||
content, subject, url_root, scheduled_for
|
||||
):
|
||||
resp = __create_notification_response_detached(
|
||||
resp = __create_notification_response(
|
||||
notification_id, client_reference, template_id, template_version, service_id, url_root, scheduled_for
|
||||
)
|
||||
resp['content'] = {
|
||||
@@ -89,7 +51,7 @@ def create_post_letter_response_from_notification_detached(
|
||||
return resp
|
||||
|
||||
|
||||
def __create_notification_response_detached(
|
||||
def __create_notification_response(
|
||||
notification_id, client_reference, template_id, template_version, service_id, url_root, scheduled_for
|
||||
):
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user