2024-01-10 09:48:32 -05:00
|
|
|
from app.models import NOTIFICATION_STATUS_TYPES, TemplateType
|
2021-03-10 13:55:06 +00:00
|
|
|
from app.schema_validation.definitions import personalisation, uuid
|
2017-05-17 15:06:15 +01:00
|
|
|
|
2016-11-21 15:42:17 +00:00
|
|
|
template = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-11-21 15:42:17 +00:00
|
|
|
"description": "template schema",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"title": "notification content",
|
|
|
|
|
"properties": {
|
|
|
|
|
"id": uuid,
|
|
|
|
|
"version": {"type": "integer"},
|
2023-08-29 14:54:30 -07:00
|
|
|
"uri": {"type": "string", "format": "uri"},
|
2016-11-21 15:42:17 +00:00
|
|
|
},
|
2023-08-29 14:54:30 -07:00
|
|
|
"required": ["id", "version", "uri"],
|
2016-11-21 15:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
2018-04-03 16:37:41 +01:00
|
|
|
notification_by_id = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2018-04-03 16:37:41 +01:00
|
|
|
"description": "GET notification response schema",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"title": "response v2/notification",
|
2023-08-29 14:54:30 -07:00
|
|
|
"properties": {"notification_id": uuid},
|
|
|
|
|
"required": ["notification_id"],
|
2018-04-03 16:37:41 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2016-11-21 15:42:17 +00:00
|
|
|
get_notification_response = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-11-21 15:42:17 +00:00
|
|
|
"description": "GET notification response schema",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"title": "response v2/notification",
|
|
|
|
|
"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"]},
|
2024-01-10 11:18:33 -05:00
|
|
|
"type": {"enum": [e.value for e in TemplateType]},
|
2016-11-21 15:42:17 +00:00
|
|
|
"status": {"type": "string"},
|
|
|
|
|
"template": template,
|
2016-12-15 16:19:55 +00:00
|
|
|
"body": {"type": "string"},
|
|
|
|
|
"subject": {"type": ["string", "null"]},
|
2016-11-21 15:42:17 +00:00
|
|
|
"created_at": {"type": "string"},
|
|
|
|
|
"sent_at": {"type": ["string", "null"]},
|
2017-05-15 15:02:38 +01:00
|
|
|
"completed_at": {"type": ["string", "null"]},
|
2023-08-29 14:54:30 -07:00
|
|
|
"scheduled_for": {"type": ["string", "null"]},
|
2016-11-21 15:42:17 +00:00
|
|
|
},
|
|
|
|
|
"required": [
|
|
|
|
|
# technically, all keys are required since we always have all of them
|
2023-08-29 14:54:30 -07:00
|
|
|
"id",
|
|
|
|
|
"reference",
|
|
|
|
|
"email_address",
|
|
|
|
|
"phone_number",
|
|
|
|
|
"line_1",
|
|
|
|
|
"line_2",
|
|
|
|
|
"line_3",
|
|
|
|
|
"line_4",
|
|
|
|
|
"line_5",
|
|
|
|
|
"line_6",
|
|
|
|
|
"postcode",
|
|
|
|
|
"type",
|
|
|
|
|
"status",
|
|
|
|
|
"template",
|
|
|
|
|
"body",
|
|
|
|
|
"created_at",
|
|
|
|
|
"sent_at",
|
|
|
|
|
"completed_at",
|
|
|
|
|
],
|
2016-11-21 15:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
2016-11-28 14:22:51 +00:00
|
|
|
get_notifications_request = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-11-28 14:22:51 +00:00
|
|
|
"description": "schema for query parameters allowed when getting list of notifications",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
2016-12-12 18:04:20 +00:00
|
|
|
"reference": {"type": "string"},
|
2023-08-29 14:54:30 -07:00
|
|
|
"status": {"type": "array", "items": {"enum": NOTIFICATION_STATUS_TYPES}},
|
2024-01-10 09:48:32 -05:00
|
|
|
"template_type": {
|
|
|
|
|
"type": "array",
|
|
|
|
|
"items": {"enum": [e.value for e in TemplateType]},
|
|
|
|
|
},
|
2017-11-16 14:44:28 +00:00
|
|
|
"include_jobs": {"enum": ["true", "True"]},
|
2023-08-29 14:54:30 -07:00
|
|
|
"older_than": uuid,
|
2016-11-28 14:22:51 +00:00
|
|
|
},
|
|
|
|
|
"additionalProperties": False,
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-25 16:46:19 +00:00
|
|
|
get_notifications_response = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-11-25 16:46:19 +00:00
|
|
|
"description": "GET list of notifications response schema",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"properties": {
|
|
|
|
|
"notifications": {
|
|
|
|
|
"type": "array",
|
2023-08-29 14:54:30 -07:00
|
|
|
"items": {"type": "object", "$ref": "#/definitions/notification"},
|
2016-11-25 16:46:19 +00:00
|
|
|
},
|
|
|
|
|
"links": {
|
|
|
|
|
"type": "object",
|
2023-08-29 14:54:30 -07:00
|
|
|
"properties": {"current": {"type": "string"}, "next": {"type": "string"}},
|
2016-11-25 16:46:19 +00:00
|
|
|
"additionalProperties": False,
|
2023-08-29 14:54:30 -07:00
|
|
|
"required": ["current"],
|
|
|
|
|
},
|
2016-11-25 16:46:19 +00:00
|
|
|
},
|
|
|
|
|
"additionalProperties": False,
|
2017-11-16 14:44:28 +00:00
|
|
|
"required": ["notifications", "links"],
|
2023-08-29 14:54:30 -07:00
|
|
|
"definitions": {"notification": get_notification_response},
|
2016-11-25 16:46:19 +00:00
|
|
|
}
|
|
|
|
|
|
2016-10-25 14:53:31 +01:00
|
|
|
post_sms_request = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-10-25 14:53:31 +01:00
|
|
|
"description": "POST sms notification schema",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"title": "POST v2/notifications/sms",
|
|
|
|
|
"properties": {
|
|
|
|
|
"reference": {"type": "string"},
|
2016-11-14 13:56:09 +00:00
|
|
|
"phone_number": {"type": "string", "format": "phone_number"},
|
2016-10-25 14:53:31 +01:00
|
|
|
"template_id": uuid,
|
2017-05-15 15:02:38 +01:00
|
|
|
"personalisation": personalisation,
|
2023-08-29 14:54:30 -07:00
|
|
|
"scheduled_for": {
|
|
|
|
|
"type": ["string", "null"],
|
|
|
|
|
"format": "datetime_within_next_day",
|
|
|
|
|
},
|
|
|
|
|
"sms_sender_id": uuid,
|
2016-10-25 14:53:31 +01:00
|
|
|
},
|
2017-11-23 16:57:17 +00:00
|
|
|
"required": ["phone_number", "template_id"],
|
2023-08-29 14:54:30 -07:00
|
|
|
"additionalProperties": False,
|
2016-10-25 14:53:31 +01:00
|
|
|
}
|
|
|
|
|
|
2016-11-14 13:56:09 +00:00
|
|
|
sms_content = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-11-14 13:56:09 +00:00
|
|
|
"description": "content schema for SMS notification response schema",
|
2016-10-25 14:53:31 +01:00
|
|
|
"type": "object",
|
|
|
|
|
"title": "notification content",
|
2023-08-29 14:54:30 -07:00
|
|
|
"properties": {"body": {"type": "string"}, "from_number": {"type": "string"}},
|
|
|
|
|
"required": ["body", "from_number"],
|
2016-10-25 14:53:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
post_sms_response = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-10-25 14:53:31 +01:00
|
|
|
"description": "POST sms notification response schema",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"title": "response v2/notifications/sms",
|
|
|
|
|
"properties": {
|
|
|
|
|
"id": uuid,
|
2016-11-21 17:32:36 +00:00
|
|
|
"reference": {"type": ["string", "null"]},
|
2016-11-14 13:56:09 +00:00
|
|
|
"content": sms_content,
|
2016-12-15 16:37:40 +00:00
|
|
|
"uri": {"type": "string", "format": "uri"},
|
2017-05-15 15:02:38 +01:00
|
|
|
"template": template,
|
2023-08-29 14:54:30 -07:00
|
|
|
"scheduled_for": {"type": ["string", "null"]},
|
2016-11-14 13:56:09 +00:00
|
|
|
},
|
2023-08-29 14:54:30 -07:00
|
|
|
"required": ["id", "content", "uri", "template"],
|
2016-11-14 13:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
post_email_request = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-11-14 13:56:09 +00:00
|
|
|
"description": "POST email notification schema",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"title": "POST v2/notifications/email",
|
|
|
|
|
"properties": {
|
|
|
|
|
"reference": {"type": "string"},
|
|
|
|
|
"email_address": {"type": "string", "format": "email_address"},
|
|
|
|
|
"template_id": uuid,
|
2017-05-15 15:02:38 +01:00
|
|
|
"personalisation": personalisation,
|
2023-08-29 14:54:30 -07:00
|
|
|
"scheduled_for": {
|
|
|
|
|
"type": ["string", "null"],
|
|
|
|
|
"format": "datetime_within_next_day",
|
|
|
|
|
},
|
|
|
|
|
"email_reply_to_id": uuid,
|
2016-11-14 13:56:09 +00:00
|
|
|
},
|
2017-11-23 16:57:17 +00:00
|
|
|
"required": ["email_address", "template_id"],
|
2023-08-29 14:54:30 -07:00
|
|
|
"additionalProperties": False,
|
2016-11-14 13:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
email_content = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2016-11-14 13:56:09 +00:00
|
|
|
"description": "Email content for POST email notification",
|
|
|
|
|
"type": "object",
|
|
|
|
|
"title": "notification email content",
|
|
|
|
|
"properties": {
|
|
|
|
|
"from_email": {"type": "string", "format": "email_address"},
|
|
|
|
|
"body": {"type": "string"},
|
2023-08-29 14:54:30 -07:00
|
|
|
"subject": {"type": "string"},
|
2016-11-14 13:56:09 +00:00
|
|
|
},
|
2023-08-29 14:54:30 -07:00
|
|
|
"required": ["body", "from_email", "subject"],
|
2016-11-14 13:56:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
post_email_response = {
|
2022-04-08 17:05:59 +01:00
|
|
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
2017-09-11 11:10:45 +01:00
|
|
|
"description": "POST email notification response schema",
|
2016-11-14 13:56:09 +00:00
|
|
|
"type": "object",
|
|
|
|
|
"title": "response v2/notifications/email",
|
|
|
|
|
"properties": {
|
|
|
|
|
"id": uuid,
|
2016-11-21 17:32:36 +00:00
|
|
|
"reference": {"type": ["string", "null"]},
|
2016-11-14 13:56:09 +00:00
|
|
|
"content": email_content,
|
2016-12-15 16:37:40 +00:00
|
|
|
"uri": {"type": "string", "format": "uri"},
|
2017-05-15 15:02:38 +01:00
|
|
|
"template": template,
|
2023-08-29 14:54:30 -07:00
|
|
|
"scheduled_for": {"type": ["string", "null"]},
|
2016-10-25 14:53:31 +01:00
|
|
|
},
|
2023-08-29 14:54:30 -07:00
|
|
|
"required": ["id", "content", "uri", "template"],
|
2016-10-25 14:53:31 +01:00
|
|
|
}
|