Add get all templates schema

This commit is contained in:
Ken Tsang
2017-03-24 10:23:47 +00:00
parent ddda2bd158
commit f5da3574b5
3 changed files with 161 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
from app.models import SMS_TYPE, TEMPLATE_TYPES
from app.schema_validation.definitions import uuid, personalisation
from app.v2.template_schema import template
get_template_by_id_request = {
@@ -67,6 +68,51 @@ post_template_preview_response = {
"required": ["id", "type", "version", "body"]
}
get_all_template_request = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "request schema for parameters allowed when getting all templates",
"type": "object",
"properties": {
"type": {"enum": TEMPLATE_TYPES},
},
"required": ["type"],
"additionalProperties": False,
}
get_all_template_response = {
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "GET response schema when getting all templates",
"type": "object",
"properties": {
"links": {
"type": "object",
"properties": {
"self": {
"type": "string",
"format": "uri"
},
"next": {
"type": "string",
"format": "uri"
}
},
"additionalProperties": False,
"required": ["self"],
},
"templates": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/template"
}
}
},
"required": ["links", "templates"],
"definitions": {
"template": template
}
}
def create_post_template_preview_response(template, template_object):
subject = template_object.subject if template.template_type != SMS_TYPE else None