add POST response tests

assert that the response for emails and sms is formatted as expected

also moved schemas into subdirectory to make folder more legible
This commit is contained in:
Leo Hemsted
2016-08-31 12:33:45 +01:00
parent fabbb8b01b
commit c91358673f
11 changed files with 105 additions and 7 deletions
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "GET notification return schema - for email notifications",
"type" : "object",
"properties": {
"data": {
"type": "object",
"properties": {
"notification": {"$ref": "email_notification.json"}
},
"additionalProperties": false,
"required": ["notification"]
}
},
"additionalProperties": false,
"required": ["data"]
}
@@ -0,0 +1,17 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "GET notification return schema - for sms notifications",
"type" : "object",
"properties": {
"data": {
"type": "object",
"properties": {
"notification": {"$ref": "sms_notification.json"}
},
"additionalProperties": false,
"required": ["notification"]
}
},
"additionalProperties": false,
"required": ["data"]
}
@@ -0,0 +1,26 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "GET notification return schema - for sms notifications",
"type" : "object",
"properties": {
"notifications": {
"type": "array",
"items": {
"oneOf": [
{"$ref": "sms_notification.json"},
{"$ref": "email_notification.json"}
]
}
},
"links": {
"type": "object",
"additionalProperties": false
},
"page_size": {"type": "number"},
"total": {"type": "number"}
},
"additionalProperties": false,
"required": [
"notifications", "links", "page_size", "total"
]
}
@@ -0,0 +1,27 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "POST notification return schema - for email notifications",
"type" : "object",
"properties": {
"data": {
"type": "object",
"properties": {
"notification": {
"type": "object",
"properties": {
"id": {"$ref": "definitions.json#/uuid"}
},
"additionalProperties": false,
"required": ["id"]
},
"body": {"type": "string"},
"template_version": {"type": "number"},
"subject": {"type": "string"}
},
"additionalProperties": false,
"required": ["notification", "body", "template_version", "subject"]
}
},
"additionalProperties": false,
"required": ["data"]
}
@@ -0,0 +1,26 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "POST notification return schema - for sms notifications",
"type" : "object",
"properties": {
"data": {
"type": "object",
"properties": {
"notification": {
"type": "object",
"properties": {
"id": {"$ref": "definitions.json#/uuid"}
},
"additionalProperties": false,
"required": ["id"]
},
"body": {"type": "string"},
"template_version": {"type": "number"}
},
"additionalProperties": false,
"required": ["notification", "body", "template_version"]
}
},
"additionalProperties": false,
"required": ["data"]
}
@@ -0,0 +1,12 @@
{
"$schema": "http://json-schema.org/draft-04/schema#",
"description": "Common definitions - usage example: {'$ref': 'definitions.json#/uuid'} (swap quotes for double quotes)",
"uuid": {
"type": "string",
"pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$"
},
"datetime": {
"type": "string",
"format": "date-time"
}
}
@@ -0,0 +1,106 @@
{
"description": "Single email notification schema - as returned by GET /notification and GET /notification/{}",
"type": "object",
"properties": {
"id": {"$ref": "definitions.json#/uuid"},
"to": {"type": "string", "format": "email"},
"job_row_number": {"oneOf":[
{"type": "number"},
{"type": "null"}
]},
"template_version": {"type": "number"},
"billable_units": {"type": "number"},
"notification_type": {
"type": "string",
"enum": ["email"]
},
"created_at": {"$ref": "definitions.json#/datetime"},
"sent_at": {"oneOf":[
{"$ref": "definitions.json#/datetime"},
{"type": "null"}
]},
"sent_by": {"oneOf":[
{"type": "string"},
{"type": "null"}
]},
"updated_at": {"oneOf":[
{"$ref": "definitions.json#/datetime"},
{"type": "null"}
]},
"status": {
"type": "string",
"enum": [
"created",
"sending",
"delivered",
"pending",
"failed",
"technical-failure",
"temporary-failure",
"permanent-failure"
]
},
"reference": {"oneOf":[
{"type": "string"},
{"type": "null"}
]},
"template": {
"type": "object",
"properties": {
"id": {"$ref": "definitions.json#/uuid"},
"name": {"type": "string"},
"template_type": {
"type": "string",
"enum": ["email"]
},
"version": {"type": "number"}
},
"additionalProperties": false,
"required": ["id", "name", "template_type", "version"]
},
"service": {"$ref": "definitions.json#/uuid"},
"job": {
"oneOf": [
{
"type": "object",
"properties": {
"id": {"$ref": "definitions.json#/uuid"},
"original_file_name": {"type": "string"}
},
"additionalProperties": false,
"required": ["id", "original_file_name"]
},
{"type": "null"}
]
},
"api_key": {"oneOf":[
{"$ref": "definitions.json#/uuid"},
{"type": "null"}
]},
"body": {"type": "string"},
"content_char_count": {"type": "null"},
"subject": {"type": "string"}
},
"additionalProperties": false,
"required": [
"id",
"to",
"job_row_number",
"template_version",
"billable_units",
"notification_type",
"created_at",
"sent_at",
"sent_by",
"updated_at",
"status",
"reference",
"template",
"service",
"job",
"api_key",
"body",
"content_char_count",
"subject"
]
}
@@ -0,0 +1,104 @@
{
"description": "Single sms notification schema - as returned by GET /notification and GET /notification/{}",
"type": "object",
"properties": {
"id": {"$ref": "definitions.json#/uuid"},
"to": {"type": "string"},
"job_row_number": {"oneOf":[
{"type": "number"},
{"type": "null"}
]},
"template_version": {"type": "number"},
"billable_units": {"type": "number"},
"notification_type": {
"type": "string",
"enum": ["sms"]
},
"created_at": {"$ref": "definitions.json#/datetime"},
"sent_at": {"oneOf":[
{"$ref": "definitions.json#/datetime"},
{"type": "null"}
]},
"sent_by": {"oneOf":[
{"type": "string"},
{"type": "null"}
]},
"updated_at": {"oneOf":[
{"$ref": "definitions.json#/datetime"},
{"type": "null"}
]},
"status": {
"type": "string",
"enum": [
"created",
"sending",
"delivered",
"pending",
"failed",
"technical-failure",
"temporary-failure",
"permanent-failure"
]
},
"reference": {"oneOf":[
{"type": "string"},
{"type": "null"}
]},
"template": {
"type": "object",
"properties": {
"id": {"$ref": "definitions.json#/uuid"},
"name": {"type": "string"},
"template_type": {
"type": "string",
"enum": ["sms"]
},
"version": {"type": "number"}
},
"additionalProperties": false,
"required": ["id", "name", "template_type", "version"]
},
"service": {"$ref": "definitions.json#/uuid"},
"job": {
"oneOf": [
{
"type": "object",
"properties": {
"id": {"$ref": "definitions.json#/uuid"},
"original_file_name": {"type": "string"}
},
"additionalProperties": false,
"required": ["id", "original_file_name"]
},
{"type": "null"}
]
},
"api_key": {"oneOf":[
{"$ref": "definitions.json#/uuid"},
{"type": "null"}
]},
"body": {"type": "string"},
"content_char_count": {"type": "number"}
},
"additionalProperties": false,
"required": [
"id",
"to",
"job_row_number",
"template_version",
"billable_units",
"notification_type",
"created_at",
"sent_at",
"sent_by",
"updated_at",
"status",
"reference",
"template",
"service",
"job",
"api_key",
"body",
"content_char_count"
]
}