{
    "$schema": "http://json-schema.org/draft-06/schema#",
    "title": "Notification",
    "description": "Notification data model",
    "definitions": {
        "Message": {
            "description": "a message that should be delivered",
            "type": "object",
            "properties": {
                "guid": {
                    "description": "global identifier",
                    "type": "string",
                    "format": "uuid"
                },
                "title": {
                    "description": "title of the message",
                    "type": "string"
                },
                "text": {
                    "description": "message text",
                    "type": "string"
                },
                "priority": {
                    "description": "priority of the message",
                    "type": "string",
                    "enum": [
                        "normal",
                        "high",
                        "hot"
                    ]
                },
                "sender": {
                    "$ref": "#/definitions/Sender"
                }
            },
            "required": [
                "guid",
                "title",
                "text",
                "sender"
            ]
        },
        "NotifyJob": {
            "description": "a job to deliver message",
            "type": "object",
            "properties": {
                "guid": {
                    "description": "global identifier",
                    "type": "string",
                    "format": "uuid"
                },
                "message": {
                    "$ref": "#/definitions/Message",
                    "example": "bar-chart"
                },
                "type": {
                    "description": "how should the message be delivered",
                    "type": "string",
                    "enum": [
                        "email",
                        "sms",
                        "webhook"
                    ]
                },
                "receiver": {
                    "description": "who should receive the message",
                    "type": "array",
                    "items": {
                        "type": "string"
                    }
                },
                "times": {
                    "type": "object",
                    "properties": {
                        "to_send": {
                            "description": "what time it should be sent",
                            "type": "string",
                            "format": "date-time"
                        },
                        "sended": {
                            "description": "When was it sent",
                            "type": "string",
                            "format": "date-time"
                        },
                        "last_trial": {
                            "description": "In case of error when was the last delivery trial",
                            "type": "string",
                            "format": "date-time"
                        }
                    }
                },
                "topics": {
                    "type": "object",
                    "properties": {
                        "success": {
                            "description": "a topic name to notify the sender about success",
                            "type": "string"
                        },
                        "error": {
                            "description": "a topic name to notify the sender about delivery errors",
                            "type": "string"
                        }
                    }
                }
            },
            "required": [
                "message",
                "type",
                "receiver"
            ]
        },
        "Sender": {
            "description": "which service is the source of the message/job",
            "type": "object",
            "properties": {
                "guid": {
                    "description": "global identifier",
                    "type": "string",
                    "format": "uuid"
                },
                "name": {
                    "description": "text to display",
                    "type": "string"
                },
                "event_id": {
                    "description": "global id that allows the sender to link a message/job with an interal event",
                    "type": "string",
                    "format": "uuid"
                }
            }
        }
    },
    "properties": {
        "Message": {
            "$ref": "#/definitions/Message"
        },
        "NotifyJob": {
            "$ref": "#/definitions/NotifyJob"
        },
        "Sender": {
            "$ref": "#/definitions/Sender"
        }
    },
    "required": [
        "Message",
        "NotifyJob",
        "Sender"
    ]
}