{
    "$schema": "http://json-schema.org/draft-04/schema",
    "title": "Event",
    "description": "Describes information about events",
    "type": "object",
    "properties": {
        "scope": {
            "description": "scope of the revenue result",
            "enum": [
                "company",
                "city",
                "station",
                "pump",
                "tank"
            ]
        },
        "id": {
            "description": "unique identifier for the scope of the event list",
            "type": "string"
        },
        "events": {
            "description": "list of events",
            "type": "array",
            "items": {
                "description": "type of event being reported",
                "type": "object",
                "oneOf": [
                    {
                        "$ref": "#/definitions/pumpfail"
                    },
                    {
                        "$ref": "#/definitions/pumpactive"
                    },
                    {
                        "$ref": "#/definitions/pumpinactive"
                    },
                    {
                        "$ref": "#/definitions/tankleak"
                    },
                    {
                        "$ref": "#/definitions/tankactive"
                    },
                    {
                        "$ref": "#/definitions/tankinactive"
                    },
                    {
                        "$ref": "#/definitions/tankfill"
                    }
                ]
            }
        }
    },
    "required": [
        "scope",
        "id",
        "events"
    ],
    "definitions": {
        "pumpfail": {
            "properties": {
                "type": {
                    "enum": [
                        "pumpfail"
                    ]
                },
                "id": {
                    "description": "unique identifier of the pump for this event",
                    "type": "string"
                },
                "when": {
                    "description": "whethis event occurred",
                    "type": "string"
                }
            },
            "required": [
                "type",
                "id",
                "when"
            ]
        },
        "pumpactive": {
            "properties": {
                "type": {
                    "enum": [
                        "pumprepaired"
                    ]
                },
                "id": {
                    "description": "unique identifier of the pump for this event",
                    "type": "string"
                },
                "when": {
                    "description": "when this event occurred",
                    "type": "string"
                }
            },
            "required": [
                "type",
                "id",
                "when"
            ]
        },
        "pumpinactive": {
            "properties": {
                "type": {
                    "enum": [
                        "pumprepaired"
                    ]
                },
                "id": {
                    "description": "unique identifier of the pump for this event",
                    "type": "string"
                },
                "when": {
                    "description": "when this event occurred",
                    "type": "string"
                }
            },
            "required": [
                "type",
                "id",
                "when"
            ]
        },
        "tankleak": {
            "properties": {
                "type": {
                    "enum": [
                        "tankleak"
                    ]
                },
                "id": {
                    "description": "unique identifier of the tank for this event",
                    "type": "string"
                },
                "rate": {
                    "description": "leakage rate that was detected",
                    "type": "number"
                },
                "when": {
                    "description": "when this event occurred",
                    "type": "string"
                }
            },
            "required": [
                "type",
                "id",
                "rate",
                "when"
            ]
        },
        "tankactive": {
            "properties": {
                "type": {
                    "enum": [
                        "tankrepaired"
                    ]
                },
                "id": {
                    "description": "unique identifier of the tank for this event",
                    "type": "string"
                },
                "when": {
                    "description": "when this event occurred",
                    "type": "string"
                }
            },
            "required": [
                "type",
                "id",
                "when"
            ]
        },
        "tankinactive": {
            "properties": {
                "type": {
                    "enum": [
                        "tankrepaired"
                    ]
                },
                "id": {
                    "description": "unique identifier of the tank for this event",
                    "type": "string"
                },
                "when": {
                    "description": "when this event occurred",
                    "type": "string"
                }
            },
            "required": [
                "type",
                "id",
                "when"
            ]
        },
        "tankfill": {
            "properties": {
                "type": {
                    "enum": [
                        "tankfill"
                    ]
                },
                "id": {
                    "description": "unique identifier of the tank for this event",
                    "type": "string"
                },
                "when": {
                    "description": "when this event occurred",
                    "type": "string"
                }
            },
            "required": [
                "type",
                "id",
                "when"
            ]
        }
    }
}