mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-04 10:21:14 -05:00
Merge pull request #991 from alphagov/invite-service-to-schedule
Invite the service to schedule notifications from the API
This commit is contained in:
@@ -113,7 +113,7 @@ post_sms_request = {
|
||||
"phone_number": {"type": "string", "format": "phone_number"},
|
||||
"template_id": uuid,
|
||||
"personalisation": personalisation,
|
||||
"scheduled_for": {"type": "string", "format": "datetime"}
|
||||
"scheduled_for": {"type": ["string", "null"], "format": "datetime"}
|
||||
},
|
||||
"required": ["phone_number", "template_id"]
|
||||
}
|
||||
@@ -141,7 +141,7 @@ post_sms_response = {
|
||||
"content": sms_content,
|
||||
"uri": {"type": "string", "format": "uri"},
|
||||
"template": template,
|
||||
"scheduled_for": {"type": "string"}
|
||||
"scheduled_for": {"type": ["string", "null"]}
|
||||
},
|
||||
"required": ["id", "content", "uri", "template"]
|
||||
}
|
||||
@@ -157,7 +157,7 @@ post_email_request = {
|
||||
"email_address": {"type": "string", "format": "email_address"},
|
||||
"template_id": uuid,
|
||||
"personalisation": personalisation,
|
||||
"scheduled_for": {"type": "string", "format": "datetime"}
|
||||
"scheduled_for": {"type": ["string", "null"], "format": "datetime"}
|
||||
},
|
||||
"required": ["email_address", "template_id"]
|
||||
}
|
||||
@@ -186,7 +186,7 @@ post_email_response = {
|
||||
"content": email_content,
|
||||
"uri": {"type": "string", "format": "uri"},
|
||||
"template": template,
|
||||
"scheduled_for": {"type": "string"}
|
||||
"scheduled_for": {"type": ["string", "null"]}
|
||||
},
|
||||
"required": ["id", "content", "uri", "template"]
|
||||
}
|
||||
|
||||
@@ -35,9 +35,8 @@ def post_notification(notification_type):
|
||||
form = validate(request.get_json(), post_sms_request)
|
||||
|
||||
scheduled_for = form.get("scheduled_for", None)
|
||||
if scheduled_for:
|
||||
if not service_can_schedule_notification(authenticated_service):
|
||||
return
|
||||
service_can_schedule_notification(authenticated_service, scheduled_for)
|
||||
|
||||
check_rate_limiting(authenticated_service, api_user)
|
||||
|
||||
form_send_to = form['phone_number'] if notification_type == SMS_TYPE else form['email_address']
|
||||
|
||||
Reference in New Issue
Block a user