""" JSON Draft4 Schema Validators ============================= A collection of json_schema.Draft4Validators loaded with the different endpoint validation schemas for our API """ REPORTS_GET_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "periods": { "description": "The accounting period", "pattern": r"(^[0-9]+$)|(^([0-9])+(,[0-9]+)+$)", "type": "string"}, }, "required": ["periods"] } REPORT_GET_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "periods": { "description": "The accounting period", "pattern": r"(^[0-9]+$)|(^([0-9])+(,[0-9]+)+$)", "type": "string"}, "transaction_types": { "type": "string", "pattern": r"(^\w+$)|(^(\w)+(,\w+)+$)", "description": "Supported transactions"}, "number_format": { "type": "string", "pattern": r"^(en_US|es_ES)$", "minLength": 1}, "file_type": { "type": "string", "minLength": 1, "pattern": r"^(txt|xls|TXT|XLS)$", "maxLength": 255, "description": "Supported file types to be downloaded."} }, "required": ["periods", "transaction_types", "file_type", "number_format"] } REPORT_POST_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "definitions": { "user": { "type": "object", "properties": { "first_name": {"type": "string"}, "last_name": {"type": "string"}, "contact_email": { "type": "string", "format": "email"}, "contact_id": { "type": "integer", "minLength": 1} } } }, "properties": { "periods": { "description": "The accounting period", "pattern": r"(^[0-9]+$)|(^([0-9])+(,[0-9]+)+$)", "type": "string"}, "transaction_types": { "type": "string", "pattern": r"(^\w+$)|(^(\w)+(,\w+)+$)", "description": "Supported transactions"}, "number_format": { "type": "string", "pattern": r"^(en_US|es_ES)$", "minLength": 1}, "file_type": { "type": "string", "minLength": 1, "pattern": r"^(txt|xls|TXT|XLS)$", "maxLength": 255, "description": "Supported file types to be downloaded."}, "request_context": {"$ref": "#/definitions/user"} }, "required": [ "periods", "transaction_types", "number_format", "file_type", "request_context"] } TRANSACTION_TYPES_GET_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "periods": { "description": "The accounting period", "pattern": r"(^[0-9]+$)|(^([0-9])+(,[0-9]+)+$)", "type": "string"}, }, "additionalProperties": False, "required": ["periods"] } REVENUE_GET_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "recent": { "description": "Number of recent accounting intervals", "pattern": r"(^[0-9]+$)", "type": "string"}, }, "additionalProperties": False, "required": ["recent"] } PAYMENTS_GET_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "recent": { "description": "Number of recent accounting intervals", "pattern": r"(^[0-9]+$)", "type": "string"}, }, "additionalProperties": False, "required": ["recent"] } PAYMENT_HOLD_POST_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "status": { "type": "string", "pattern": r"^(active|inactive)$", "description": "Status of hold." }, "description": { "type": "string", "description": "Reason for the hold." } }, "additionalProperties": False, "required": ["status"] } ATTACHMENTS_GET_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "periods": { "description": "The accounting period", "pattern": r"(^[0-9]+$)|(^([0-9])+(,[0-9]+)+$)", "type": "string"}, }, "required": ["periods"] } ATTACHMENT_GET_VALIDATOR = { "$schema": "http://json-schema.org/draft-04/schema#", "properties": { "periods": { "description": "The accounting period", "pattern": r"(^[0-9]+$)|(^([0-9])+(,[0-9]+)+$)", "type": "string"}, "file_name": { "description": "Full file name with file type", "pattern": r"^([A-Za-z0-9-_.*'()]+)\.([a-zA-Z]+)(\(\d{3}\))?$", "type": "string"}, }, "required": ["periods", "file_name"] }