{
  "$schema": "http://json-schema.org/draft-04/hyper-schema",
  "title": "TME Dealer Finder - Marketing Domain Outlet Schema",
  "description": "this schema describes an outlet in the marketing domain in the Toyota Motor Europe dealer network",
  "id": "https://a2d-api.toyota-europe.com/docs/dealer-schema-v5-marketing/schema.json",
  "type": "object",
  "required": [
    "uuid",
    "status",
    "name",
    "brand",
    "address",
    "nmsc",
    "operations",
    "contactInformation",
    "tags",
    "lastModificationDate"
  ],
  "properties": {
    "uuid": {
      "description": "The unique identifier of the outlet. This value should be used to identify a dealer.",
      "type": "string"
    },
    "status": {
      "description": "Whether this outlet is currently active or inactive (= not an official outlet)",
      "type": ["string"],
      "enum": ["Open", "Closed"]
    },
    "name": {
      "description": "Name of the outlet",
      "type": "string"
    },
    "brand": {
      "description": "The brand this outlet sells",
      "type": ["string"],
      "enum": ["Toyota", "Lexus"]
    },
    "address": {
      "description": "The address associated with this outlet",
      "type": "object",
      "items": { "$ref": "#/definitions/address" }
    },
    "nmsc": {
      "description": "Information about the NMSC associated with this outlet",
      "type": "string",
      "example": "TNO"
    },
    "operations": {
      "$ref": "#/definitions/operations"
    },
    "contactInformation": {
      "$ref": "#/definitions/contactInformation"
    },
    "tags": {
      "description": "Information about the services this outlet provides",
      "type": "object",
      "properties": {
        "web": {
          "description": "A list of tags detailing the available services of an outlet",
          "type": ["string"],
          "enum": [
            "OnlineServiceBooking",
            "OnlineRetailing",
            "TestDrive",
            "TradeInAppraisal",
            "CommercialVehicleCenter",
            "PaintShop",
            "ToyotaRentCars",
            "UsedCars"
          ]
        },
        "functional": {
          "description": "A list of tags that are used by third party systems",
          "type": ["string"],
          "enum": [
            "OnlineServiceBooking",
            "OnlineRetailingNewCars",
            "OnlineRetailingUsedCars",
            "UsedCarsDelivery"
          ]
        }
      }
    },
    "lastModificationDate": {
      "description": "Timestamp of the last modification to this outlet",
      "type": "string",
      "pattern": "^[0-3][0-9]\/[0-1][0-9]\/[1-9][0-9]{3} [0-2][0-9]:[0-5][0-9]:[0-5][0-9].[0-9]{3}$"
    }
  },
  "definitions": {
    "address": {
      "required": ["street", "number", "zip", "city", "country", "geoLocation"],
      "description": "The official address of the outlet",
      "type": "object",
      "properties": {
        "street": {
          "description": "The street of the address",
          "type": "string"
        },
        "number": {
          "description": "The house number of the address",
          "type": "string"
        },
        "box": {
          "description": "The box number of the address, if applicable",
          "type": ["string", "null"]
        },
        "zip": {
          "description": "The zip code for the city of the address",
          "type": "string"
        },
        "city": {
          "description": "The city of the address",
          "type": "string"
        },
        "country": {
          "description": "The country of the address",
          "type": "string"
        },
        "geoLocation": {
          "description": "Longitude and latitude of the outlet location",
          "type": "object",
          "properties": {
            "lon": { "type": "string" },
            "lat": { "type": "string" }
          },
          "additionalProperties": false
        }
      }
    },
    "operations": {
      "description": "a list of operations",
      "type": "array",
      "items": { "$ref": "#/definitions/operation" }
    },
    "operation": {
      "type": "object",
      "properties": {
        "operation": {
          "description": "a representation of an operation",
          "type": "string"
        },
        "openingHours": {
          "description": "A list of the standard opening hours for an operation",
          "type": "array",
          "items": {
            "$ref": "#/definitions/openingHour"
          }
        },
        "exceptionalOpeningHours": {
          "description": "A list of opening hours that deviate from the standard opening hours for an operation",
          "type": "array",
          "items": {
            "$ref": "#/definitions/exceptionalOpeningHour"
          }
        },
        "closures": {
          "description": "A list of periods when the operation is closed",
          "type": "array",
          "items": {
            "$ref": "#/definitions/closure"
          }
        }
      }
    },
    "openingHour": {
      "description": "A representation of a weekday and time period when an operation is open",
      "type": "object",
      "properties": {
        "dayOfWeek": {
          "description": "A day of the week",
          "type": "string",
          "enum": ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
        },
        "fromTime": {
          "description": "The starting timestamp of a time period",
          "type": "string",
          "enum": [
            "12 AM",
            "12:30 AM",
            "1 AM",
            "1:30 AM",
            "2 AM",
            "2:30 AM",
            "3 AM",
            "3:30 AM",
            "4 AM",
            "4:30 AM",
            "5 AM",
            "5:30 AM",
            "6 AM",
            "6:30 AM",
            "7 AM",
            "7:30 AM",
            "8 AM",
            "8:30 AM",
            "9 AM",
            "9:30 AM",
            "10 AM",
            "10:30 AM",
            "11 AM",
            "11:30 AM",
            "12 PM",
            "12:30 PM",
            "1 PM",
            "1:30 PM",
            "2 PM",
            "2:30 PM",
            "3 PM",
            "3:30 PM",
            "4 PM",
            "4:30 PM",
            "5 PM",
            "5:30 PM",
            "6 PM",
            "6:30 PM",
            "7 PM",
            "7:30 PM",
            "8 PM",
            "8:30 PM",
            "9 PM",
            "9:30 PM",
            "10 PM",
            "10:30 PM",
            "11 PM",
            "11:30 PM",
            "6:15 AM",
            "6:45 AM",
            "7:15 AM",
            "7:45 AM",
            "8:15 AM",
            "8:45 AM",
            "9:15 AM",
            "9:45 AM",
            "10:15 AM",
            "10:45 AM",
            "11:15 AM",
            "11:45 AM",
            "12:15 PM",
            "12:45 PM",
            "1:15 PM",
            "1:45 PM",
            "2:15 PM",
            "2:45 PM",
            "3:15 PM",
            "3:45 PM",
            "4:15 PM",
            "4:45 PM",
            "5:15 PM",
            "5:45 PM",
            "6:15 PM",
            "6:45 PM",
            "7:15 PM",
            "7:45 PM",
            "8:15 PM",
            "8:45 PM"
          ],
          "example": "7:30AM"
        },
        "toTime": {
          "description": "The end timestamp of a time period",
          "type": "string",
          "enum": [
            "12 AM",
            "12:30 AM",
            "1 AM",
            "1:30 AM",
            "2 AM",
            "2:30 AM",
            "3 AM",
            "3:30 AM",
            "4 AM",
            "4:30 AM",
            "5 AM",
            "5:30 AM",
            "6 AM",
            "6:30 AM",
            "7 AM",
            "7:30 AM",
            "8 AM",
            "8:30 AM",
            "9 AM",
            "9:30 AM",
            "10 AM",
            "10:30 AM",
            "11 AM",
            "11:30 AM",
            "12 PM",
            "12:30 PM",
            "1 PM",
            "1:30 PM",
            "2 PM",
            "2:30 PM",
            "3 PM",
            "3:30 PM",
            "4 PM",
            "4:30 PM",
            "5 PM",
            "5:30 PM",
            "6 PM",
            "6:30 PM",
            "7 PM",
            "7:30 PM",
            "8 PM",
            "8:30 PM",
            "9 PM",
            "9:30 PM",
            "10 PM",
            "10:30 PM",
            "11 PM",
            "11:30 PM",
            "6:15 AM",
            "6:45 AM",
            "7:15 AM",
            "7:45 AM",
            "8:15 AM",
            "8:45 AM",
            "9:15 AM",
            "9:45 AM",
            "10:15 AM",
            "10:45 AM",
            "11:15 AM",
            "11:45 AM",
            "12:15 PM",
            "12:45 PM",
            "1:15 PM",
            "1:45 PM",
            "2:15 PM",
            "2:45 PM",
            "3:15 PM",
            "3:45 PM",
            "4:15 PM",
            "4:45 PM",
            "5:15 PM",
            "5:45 PM",
            "6:15 PM",
            "6:45 PM",
            "7:15 PM",
            "7:45 PM",
            "8:15 PM",
            "8:45 PM"
          ],
          "example": "5 PM"
        }
      }
    },
    "exceptionalOpeningHour": {
      "description": "A representation of a period when the operation has different opening hours",
      "type": "object",
      "properties": {
        "label": {
          "description": "A description for the exceptional opening hour",
          "type": "string",
          "example": "National Holiday"
        },
        "fromTime": {
          "description": "The starting date of a time period",
          "type": "string",
          "example": "14/01/2000"
        },
        "toTime": {
          "description": "The end date of a time period",
          "type": "string",
          "example": "16/01/2000"
        },
        "openingHours": {
          "description": "A list of opening hours",
          "type": "array",
          "items": {
            "$ref": "#/definitions/openingHour"
          }
        }
      }
    },
    "closure": {
      "description": "A representation of a period when the operation has closed",
      "type": "object",
      "properties": {
        "label": {
          "description": "A description for the closure",
          "type": "string",
          "example": "National Holiday"
        },
        "validFrom": {
          "description": "The starting date of a time period",
          "type": "string",
          "example": "14/01/2000"
        },
        "validTo": {
          "description": "The end date of a time period",
          "type": "string",
          "example": "16/01/2000"
        }
      }
    },
    "contactInformation": {
      "description": "All contact information of an outlet",
      "type": "object",
      "properties": {
        "email": {
          "description": "A list of email addresses for an outlet",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "description": "The usage of the email address",
                "type": ["string"],
                "enum": ["main"]
              },
              "value": {
                "description": "A valid email address for an outlet",
                "type": "string"
              }
            }
          }
        },
        "phoneNumber": {
          "description": "A list of phone numbers for an outlet",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "description": "The usage of the phone number",
                "type": ["string"],
                "enum": ["main", "whatsapp"]
              },
              "value": {
                "description": "A valid phone number for an outlet",
                "type": "string"
              }
            }
          }
        },
        "url": {
          "description": "A list of urls for an outlet",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "description": "The usage of the url",
                "type": ["string"],
                "enum": ["main"]
              },
              "value": {
                "description": "A valid url for an outlet",
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
