mirror of
https://github.com/GSA/notifications-api.git
synced 2026-02-01 07:35:34 -05:00
Merge branch 'master' into caching-with-redis
Conflicts: app/__init__.py
This commit is contained in:
@@ -1,9 +1,17 @@
|
||||
from flask import jsonify
|
||||
|
||||
from app import api_user
|
||||
from app.dao import notifications_dao
|
||||
from app.v2.notifications import notification_blueprint
|
||||
|
||||
|
||||
@notification_blueprint.route("/<uuid:id>", methods=['GET'])
|
||||
def get_notification_by_id(id):
|
||||
pass
|
||||
notification = notifications_dao.get_notification_with_personalisation(
|
||||
str(api_user.service_id), id, key_type=None
|
||||
)
|
||||
|
||||
return jsonify(notification.serialize()), 200
|
||||
|
||||
|
||||
@notification_blueprint.route("/", methods=['GET'])
|
||||
|
||||
@@ -1,5 +1,79 @@
|
||||
from app.schema_validation.definitions import (uuid, personalisation)
|
||||
|
||||
# this may belong in a templates module
|
||||
template = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "template schema",
|
||||
"type": "object",
|
||||
"title": "notification content",
|
||||
"properties": {
|
||||
"id": uuid,
|
||||
"version": {"type": "integer"},
|
||||
"uri": {"type": "string"}
|
||||
},
|
||||
"required": ["id", "version", "uri"]
|
||||
}
|
||||
|
||||
get_notification_response = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "GET notification response schema",
|
||||
"type": "object",
|
||||
"title": "response v2/notification",
|
||||
"oneOf": [
|
||||
{"properties": {
|
||||
"email_address": {"type": "string", "format": "email_address"},
|
||||
"type": {"enum": ["email"]},
|
||||
|
||||
"phone_number": {"type": "null"},
|
||||
"line_1": {"type": "null"},
|
||||
"postcode": {"type": "null"}
|
||||
}},
|
||||
{"properties": {
|
||||
"phone_number": {"type": "string", "format": "phone_number"},
|
||||
"type": {"enum": ["sms"]},
|
||||
|
||||
"email_address": {"type": "null"},
|
||||
"line_1": {"type": "null"},
|
||||
"postcode": {"type": "null"}
|
||||
}},
|
||||
{"properties": {
|
||||
"line_1": {"type": "string", "minLength": 1},
|
||||
"postcode": {"type": "string", "minLength": 1},
|
||||
"type": {"enum": ["letter"]},
|
||||
|
||||
"email_address": {"type": "null"},
|
||||
"phone_number": {"type": "null"}
|
||||
}}
|
||||
],
|
||||
"properties": {
|
||||
"id": uuid,
|
||||
"reference": {"type": ["string", "null"]},
|
||||
"email_address": {"type": ["string", "null"]},
|
||||
"phone_number": {"type": ["string", "null"]},
|
||||
"line_1": {"type": ["string", "null"]},
|
||||
"line_2": {"type": ["string", "null"]},
|
||||
"line_3": {"type": ["string", "null"]},
|
||||
"line_4": {"type": ["string", "null"]},
|
||||
"line_5": {"type": ["string", "null"]},
|
||||
"line_6": {"type": ["string", "null"]},
|
||||
"postcode": {"type": ["string", "null"]},
|
||||
"cost": {"type": "number"},
|
||||
"type": {"enum": ["sms", "letter", "email"]},
|
||||
"status": {"type": "string"},
|
||||
"template": template,
|
||||
"created_at": {"type": "string"},
|
||||
"sent_at": {"type": ["string", "null"]},
|
||||
"completed_at": {"type": ["string", "null"]}
|
||||
},
|
||||
"required": [
|
||||
# technically, all keys are required since we always have all of them
|
||||
"id", "reference", "email_address", "phone_number",
|
||||
"line_1", "line_2", "line_3", "line_4", "line_5", "line_6", "postcode",
|
||||
"cost", "type", "status", "template",
|
||||
"created_at", "sent_at", "completed_at"
|
||||
]
|
||||
}
|
||||
|
||||
post_sms_request = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "POST sms notification schema",
|
||||
@@ -26,20 +100,6 @@ sms_content = {
|
||||
"required": ["body"]
|
||||
}
|
||||
|
||||
# this may belong in a templates module
|
||||
template = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "template schema",
|
||||
"type": "object",
|
||||
"title": "notification content",
|
||||
"properties": {
|
||||
"id": uuid,
|
||||
"version": {"type": "integer"},
|
||||
"uri": {"type": "string"}
|
||||
},
|
||||
"required": ["id", "version", "uri"]
|
||||
}
|
||||
|
||||
post_sms_response = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "POST sms notification response schema",
|
||||
@@ -47,7 +107,7 @@ post_sms_response = {
|
||||
"title": "response v2/notifications/sms",
|
||||
"properties": {
|
||||
"id": uuid,
|
||||
"reference": {"type": "string"},
|
||||
"reference": {"type": ["string", "null"]},
|
||||
"content": sms_content,
|
||||
"uri": {"type": "string"},
|
||||
"template": template
|
||||
@@ -90,7 +150,7 @@ post_email_response = {
|
||||
"title": "response v2/notifications/email",
|
||||
"properties": {
|
||||
"id": uuid,
|
||||
"reference": {"type": "string"},
|
||||
"reference": {"type": ["string", "null"]},
|
||||
"content": email_content,
|
||||
"uri": {"type": "string"},
|
||||
"template": template
|
||||
|
||||
@@ -38,7 +38,7 @@ def post_sms_notification():
|
||||
notification_type=SMS_TYPE,
|
||||
api_key_id=api_user.id,
|
||||
key_type=api_user.key_type,
|
||||
reference=form['reference'])
|
||||
reference=form.get('reference'))
|
||||
send_notification_to_queue(notification, service.research_mode)
|
||||
|
||||
resp = create_post_sms_response_from_notification(notification,
|
||||
@@ -65,7 +65,7 @@ def post_email_notification():
|
||||
notification_type=EMAIL_TYPE,
|
||||
api_key_id=api_user.id,
|
||||
key_type=api_user.key_type,
|
||||
reference=form['reference'])
|
||||
reference=form.get('reference'))
|
||||
|
||||
send_notification_to_queue(notification, service.research_mode)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user