Merge pull request #991 from alphagov/invite-service-to-schedule

Invite the service to schedule notifications from the API
This commit is contained in:
Rebecca Law
2017-06-01 12:37:32 +01:00
committed by GitHub
6 changed files with 51 additions and 22 deletions

View File

@@ -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"]
}

View File

@@ -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']