{
    "swagger": "2.0",
    "info": {
        "title": "Calendar data export API",
        "version": "1.0.0",
        "description": "Legacy feed-scoped JSON export contract. Existing integrations remain supported; new customer integrations should use the account-scoped JSON API v2 documented at https://calovo.de/integrationen/json-api.",
        "contact": {
            "name": "calovo Support",
            "url": "https://calovo.de/kontakt",
            "email": "contact@calovo.com"
        },
        "termsOfService": "https://calovo.de/agb"
    },
    "host": "cal.to",
    "schemes": ["https"],
    "produces": ["application/json"],
    "paths": {
        "/json/{id}": {
            "get": {
                "operationId": "ExportJson",
                "summary": "Export calendar data as JSON",
                "produces": [
                    "application/json"
                ],
                "parameters": [
                    {
                        "name": "id",
                        "in": "path",
                        "description": "ID of calendar to export",
                        "required": true,
                        "type": "integer"
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "description": "The requested Page",
                        "required": false,
                        "type": "integer",
                        "default": 1,
                        "minimum": 1
                    },
                    {
                        "name": "limit",
                        "in": "query",
                        "description": "Max number of records to be returned, default is 100",
                        "required": false,
                        "type": "integer",
                        "default": 100,
                        "minimum": 1,
                        "maximum": 100
                    },
                    {
                        "name": "date_from",
                        "in": "query",
                        "description": "First day of the event overlap period. Defaults to today.",
                        "required": false,
                        "type": "string",
                        "format": "date"
                    },
                    {
                        "name": "date_to",
                        "in": "query",
                        "description": "Last day of the event overlap period. Defaults to 18 months from today.",
                        "required": false,
                        "type": "string",
                        "format": "date"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Request processed formally successful",
                        "schema": {"$ref": "#/definitions/JsonResponse"}
                    },
                    "403": {
                        "description": "JSON Export is not allowed for that calfeed",
                        "schema": {"$ref": "#/definitions/Error"}
                    },
                    "404": {
                        "description": "The requested calfeed could not be found",
                        "schema": {"$ref": "#/definitions/Error"}
                    }
                }
            }
        }
    },
    "definitions": {
        "JsonResponse": {
            "type": "object",
            "required": [
                "status",
                "data",
                "current_page",
                "last_page"
            ],
            "properties": {
                "status": {
                    "type": "string",
                    "enum": ["success"],
                    "description": "indicates if request was successful or not"
                },
                "data": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/CalendarEntry"
                    },
                    "description": "contains all the events"
                },
                "current_page": {
                    "type": "integer",
                    "description": "The current page number"
                },
                "last_page": {
                    "type": "integer",
                    "description": "The number of last page that contains any elements in current setup"
                }
            }
        },
        "CalendarEntry": {
            "type": "object",
            "required": [
                "title", "description", "html_description", "location", "url", "all_day", "start_date", "end_date"
            ],
            "properties": {
                "title": {
                    "type": "string",
                    "description": "The event name"
                },
                "description": {
                    "type": "string",
                    "description": "The event description in plain text"
                },
                "html_description": {
                    "type": "string",
                    "description": "The event description in html"
                },
                "location": {
                    "type": "string",
                    "description": "The event location (may be empty)"
                },
                "url": {
                    "type": "string",
                    "description": "The event url"
                },
                "all_day": {
                    "type": "boolean",
                    "description": "indicates if event is an all-day event"
                },
                "start_date": {
                    "type": "string",
                    "format": "date-time",
                    "description": "The event start datetime"
                },
                "end_date": {
                    "type": "string",
                    "format": "date-time",
                    "description": "The event end datetime"
                },
                "tv": {
                    "type": "string",
                    "description": "Optional TV channel"
                },
                "links": {
                    "type": "array",
                    "description": "Optional visible event links. The legacy shape mirrors calovo description-block objects and must be consumed forwards-compatibly.",
                    "items": {
                        "type": "object",
                        "additionalProperties": true
                    }
                },
                "end_score": {
                    "type": "object",
                    "required": ["home", "away"],
                    "properties": {
                        "home": {
                            "type": "string",
                            "description": "The hometeam end score"
                        },
                        "away": {
                            "type": "string",
                            "description": "The awayteam end score"
                        }
                    },
                    "description": "Information about the end scores"
                },
                "teams": {
                    "type": "object",
                    "required": ["home", "away"],
                    "properties": {
                        "home": {
                            "type": "object",
                            "required": ["name", "nick"],
                            "properties": {
                                "name": {
                                    "type": "string",
                                    "description": "The full Name of the hometeam"
                                },
                                "nick": {
                                    "type": "string",
                                    "description": "The nickname of the hometeam"
                                }
                            },
                            "description": "Information about the home team"
                        },
                        "away": {
                            "type": "object",
                            "required": ["name", "nick"],
                            "properties": {
                                "name": {
                                    "type": "string",
                                    "description": "The full Name of the awayteam"
                                },
                                "nick": {
                                    "type": "string",
                                    "description": "The nickname of the awayteam"
                                }
                            },
                            "description": "Information about the away team"
                        }
                    },
                    "description": "For sports events. Contains the teams of the game."
                }
            },
            "example": {
                "title":"Reformationstag",
                "description":"Der Reformationstag ist in folgenden Bundesl\u00e4ndern ein gesetzlicher Feiertag: Brandenburg, Mecklenburg-Vorpommern, Sachsen, Sachsen-Anhalt, Th\u00fcringen und seit 2018 auch in Schleswig-Holstein, Hamburg, Bremen und Niedersachsen.",
                "html_description":"Der Reformationstag ist in folgenden Bundesl\u00e4ndern ein gesetzlicher Feiertag: Brandenburg, Mecklenburg-Vorpommern, Sachsen, Sachsen-Anhalt, Th\u00fcringen und seit 2018 auch in Schleswig-Holstein, Hamburg, Bremen und Niedersachsen.",
                "location":"BB,HB,HH,MV,NI,SH,SN,ST,TH",
                "url":"https:\/\/calovo.de\/e\/demo-calovo\/demo-calfeed\/reformationstag-9",
                "all_day":true,
                "start_date":"2019-10-31T00:00:00+00:00",
                "end_date":"2019-10-31T23:59:59+00:00"
            }
        },
        "Error": {
            "type": "object",
            "required": [
                "status",
                "message"
            ],
            "properties": {
                "status": {
                    "type": "string",
                    "enum": ["error"],
                    "description": "indicates if request was successful or not"
                },
                "message": {
                    "type": "string",
                    "description": "The error occurred"
                }
            },
            "example": {
                "status" : "error",
                "message" : "calfeed not found"
            }
        }
    }
}
