{
  "$schema": "http://json-schema.org/draft-04/hyper-schema",
  "title": "TME Dealer Finder - Outlet Schema",
  "description": "this schema describes an outlet in the Toyota Motor Europe dealer network",
  "id": "https://a2d-api.toyota-europe.com/docs/dealer-schema-v4/schema.json",
  "type": "object",
  "required": [
    "name",
    "uuid",
    "addresses",
    "applications",
    "brands",
    "country",
    "dealerProfession",
    "defaultAddress",
    "defaultEmail",
    "defaultPhoneNumber",
    "email",
    "language",
    "lastModificationDate",
    "latinName",
    "openDays",
    "operatingCompany",
    "operations",
    "outletAfterSales",
    "outletMarketing",
    "phoneNumber",
    "primaryOutlet",
    "region",
    "status",
    "url"
  ],
  "properties": {
    "addresses": {
      "description": "A list of addresses associated with this outlet",
      "type": "array",
      "items": { "$ref": "#/definitions/address" }
    },
    "applications": {
      "description": "A mapping table of IDs for this outlet in other systems",
      "type": "object",
      "properties": {
        "DF": { "$ref": "#/definitions/application" },
        "NMSC": { "$ref": "#/definitions/application" },
        "NPA": { "$ref": "#/definitions/application" },
        "TARS": { "$ref": "#/definitions/application" },
        "DOA": { "$ref": "#/definitions/application" }
      },
      "additionalProperties": false
    },
    "brands": {
      "description": "The brands this outlet sells",
      "type": "array",
      "items": {
        "enum": ["Toyota", "Lexus"]
      }
    },
    "country": {
      "$ref": "#/definitions/countryCode"
    },
    "dealerProfession": {
      "type": ["string", "null"]
    },
    "defaultAddress": {
      "description": "Easy access to the default address of this outlet",
      "$ref": "#/definitions/address"
    },
    "defaultEmail": {
      "description": "Easy access to the default email address of this outlet",
      "type": ["string", "null"],
      "format": "email"
    },
    "defaultPhoneNumber": {
      "description": "Easy access to the default phone number of this outlet",
      "type": ["string", "null"]
    },
    "email": {
      "$ref": "#/definitions/emails"
    },
    "language": {
      "$ref": "#/definitions/languageCode"
    },
    "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}$"
    },
    "name": {
      "description": "Name of the outlet",
      "type": "string"
    },
    "latinName": {
      "description": "Representation of the name in latin characters",
      "type": ["string", "null"]
    },
    "introduction": {
      "description": "Introduction",
      "type": ["string", "null"]
    },
    "registryNumber": {
      "description": "Registry number: This information is often mandatory on official documents and communication on behalf of the dealer.",
      "type": ["string", "null"]
    },
    "openDays": {
      "type": "array",
      "items": { "$ref": "#/definitions/openDay" }
    },
    "operatingCompany": {
      "$ref": "#/definitions/operatingCompany"
    },
    "operations": {
      "$ref": "#/definitions/operations"
    },
    "outletAfterSales": {
      "description": "Aftersales specific information",
      "type": "object",
      "properties": {
        "hybridServiceFlag": {
          "description": "Whether this dealer is certified to service hybrid vehicles",
          "type": "boolean"
        },
        "onLineBookingFlag": {
          "description": "Whether this dealer participates in the online service booking program, which allows you to reserve service from the website",
          "type": "boolean"
        }
      }
    },
    "outletMarketing": {
      "type": "object",
      "properties": {
        "rsbUrl": {
          "description": "Url to a dealer information page",
          "type": ["string", "null"]
        },
        "openingHours": {
          "description": "A plain text description of the opening hours. DEPRECATED! Use the OpenDays attribute if possible",
          "type": ["string", "null"]
        },
        "areas": { "type": ["string", "null"] },
        "nmscId": {
          "description": "An id in the local NMSC system. DEPRECATED! Use the externalId attribute if possible",
          "type": ["string", "null"]
        },
        "marketingName": {
          "description": "The marketing name used on the website",
          "type": "string"
        }
      }
    },
    "phoneNumber": {
      "$ref": "#/definitions/phoneNumbers"
    },
    "primaryOutlet": {
      "description": "Indicates whether this is the primary outlet of the operating company",
      "type": "boolean"
    },
    "primaryOutletUuid": {
      "description": "The reference to the uuid of the primary outlet of this outlet(branch). A way to ",
      "type": "string"
    },
    "region": {
      "description": "The region for which this outlet is responsible in the dealer network",
      "type": ["string", "null"]
    },
    "status": {
      "description": "Whether this outlet is currently active or inactive (= not an official outlet)",
      "type": ["string"],
      "enum": ["Open", "Closed"]
    },
    "url": {
      "$ref": "#/definitions/urls"
    },
    "uuid": {
      "description": "The unique identifier of the outlet. This value should be used to identify a dealer.",
      "type": "string"
    }
  },
  "definitions": {
    "address": {
      "required": [
        "addressCode",
        "addressCountry",
        "addressLine1",
        "addressLine2",
        "authorisedRepairer",
        "authorisedRetailer",
        "city",
        "defaultAddress",
        "endDate",
        "geoLocation",
        "language",
        "operations",
        "province",
        "region",
        "startDate",
        "status",
        "vatRegion",
        "zip"
      ],
      "description": "a representation of an address",
      "type": "object",
      "properties": {
        "addressCode": {
          "description": "Unique ID of the address",
          "type": ["string", "null"]
        },
        "addressCountry": {
          "$ref": "#/definitions/countryCode"
        },
        "addressLine1": {
          "type": ["string", "null"]
        },
        "addressLine2": {
          "type": ["string", "null"]
        },
        "authorisedRepairer": {
          "type": "boolean"
        },
        "authorisedRetailer": {
          "type": "boolean"
        },
        "city": {
          "type": "string"
        },
        "defaultAddress": {
          "type": "boolean"
        },
        "endDate": {
          "description": "The date on which this party stopped operating at this address",
          "type": ["string", "null"]
        },
        "geoLocation": {
          "description": "Longitude and latitude of the outlet location",
          "type": "object",
          "properties": {
            "lat": { "type": "string" },
            "lon": { "type": "string" }
          },
          "additionalProperties": false
        },
        "language": {
          "$ref": "#/definitions/languageCode"
        },
        "operations": {
          "$ref": "#/definitions/operations"
        },
        "province": {
          "type": ["string", "null"]
        },
        "region": {
          "type": "string"
        },
        "startDate": {
          "description": "The date on which the party started operating at this address",
          "type": ["string", "null"]
        },
        "status": {
          "type": "string",
          "enum": ["Active", "Inactive"]
        },
        "vatRegion": {
          "description": "TODO_CLARIFY",
          "type": ["string", "null"]
        },
        "zip": {
          "type": "string"
        }
      }
    },
    "application": {
      "description": "a representation of a TME application",
      "type": "object",
      "required": ["applicationCode", "applicationName", "externalID"],
      "properties": {
        "applicationCode": { "type": "string" },
        "applicationName": { "type": "string" },
        "externalID": { "type": "string" }
      },
      "additionalProperties": false
    },
    "operatingCompany": {
      "required": [
        "addresses",
        "applications",
        "brands",
        "defaultAddress",
        "name",
        "nmsc",
        "primaryOutlet",
        "status",
        "taxOffice",
        "uuid",
        "vat"
      ],
      "description": "a representation of an operating company",
      "type": "object",
      "properties": {
        "addresses": {
          "description": "A list of addresses associated with this operating company",
          "type": "array",
          "items": { "$ref": "#/definitions/address" }
        },
        "applications": {
          "description": "A mapping table of IDs for this operating company in other systems",
          "type": "object",
          "properties": {
            "DF": { "$ref": "#/definitions/application" },
            "NMSC": { "$ref": "#/definitions/application" },
            "NPA": { "$ref": "#/definitions/application" },
            "TARS": { "$ref": "#/definitions/application" },
            "DOA": { "$ref": "#/definitions/application" }
          }
        },
        "brands": {
          "description": "The brands this outlet sells",
          "type": "array",
          "items": {
            "enum": ["Toyota", "Lexus"]
          }
        },
        "defaultAddress": {
          "description": "Easy access to the default address of this outlet",
          "oneOf": [{ "$ref": "#/definitions/address" }, { "type": "null" }]
        },
        "email": {
          "oneOf": [{ "$ref": "#/definitions/emails" }, { "type": "null" }]
        },
        "name": {
          "type": "string"
        },
        "nmsc": {
          "description": "Information about the NMSC associated with this operating company",
          "$ref": "#/definitions/nmsc"
        },
        "nmscCode": {
          "description": "DEPRECATED! Use the nmsc.nmscCode attribute instead.",
          "type": "string"
        },
        "phoneNumber": {
          "oneOf": [{ "$ref": "#/definitions/phoneNumbers" }, { "type": "null" }]
        },
        "primaryOutletUuids": {
          "description": "A list of UUIDs of the primary outlets for this operating company",
          "type": "array",
          "items": {
            "type": "string",
            "format": "uuid"
          }
        },
        "registryNumber": {
          "description": "Registry number: This information is often mandatory on official documents and communication on behalf of the dealer.",
          "type": ["string", "null"]
        },
        "status": {
          "description": "Whether this outlet is currently active or inactive (= not an official outlet)",
          "type": "string",
          "enum": ["Open", "Closed"]
        },
        "taxOffice": {
          "description": "TODO_CLARIFY",
          "type": ["string", "null"]
        },
        "uuid": {
          "description": "The unique identifier of this operating company. Use this to reference.",
          "type": "string"
        },
        "vat": {
          "description": "TODO_CLARIFY",
          "type": ["string", "null"]
        }
      }
    },
    "countryCode": {
      "description": "2 digit country ISO code in upper case",
      "type": "string",
      "enum": [
        "AF",
        "AL",
        "DZ",
        "AS",
        "AD",
        "AO",
        "AI",
        "AQ",
        "AG",
        "AR",
        "AM",
        "AW",
        "AU",
        "AT",
        "AZ",
        "BS",
        "BH",
        "BD",
        "BB",
        "BY",
        "BE",
        "BZ",
        "BJ",
        "BM",
        "BT",
        "BO",
        "BQ",
        "BA",
        "BW",
        "BV",
        "BR",
        "IO",
        "BN",
        "BG",
        "BF",
        "BI",
        "KH",
        "CM",
        "CA",
        "CV",
        "KY",
        "CF",
        "TD",
        "CL",
        "CN",
        "CX",
        "CC",
        "CO",
        "KM",
        "CG",
        "CD",
        "CK",
        "CR",
        "HR",
        "CU",
        "CW",
        "CY",
        "CZ",
        "CI",
        "DK",
        "DJ",
        "DM",
        "DO",
        "EC",
        "EG",
        "SV",
        "GQ",
        "ER",
        "EE",
        "ET",
        "FK",
        "FO",
        "FJ",
        "FI",
        "FR",
        "GF",
        "PF",
        "TF",
        "GA",
        "GM",
        "GE",
        "DE",
        "GH",
        "GI",
        "GR",
        "GL",
        "GD",
        "GP",
        "GU",
        "GT",
        "GG",
        "GN",
        "GW",
        "GY",
        "HT",
        "HM",
        "VA",
        "HN",
        "HK",
        "HU",
        "IS",
        "IN",
        "ID",
        "IR",
        "IQ",
        "IE",
        "IM",
        "IL",
        "IT",
        "JM",
        "JP",
        "JE",
        "JO",
        "KZ",
        "KE",
        "KI",
        "KP",
        "KR",
        "KW",
        "KG",
        "LA",
        "LV",
        "LB",
        "LS",
        "LR",
        "LY",
        "LI",
        "LT",
        "LU",
        "MO",
        "MK",
        "MG",
        "MW",
        "MY",
        "MV",
        "ML",
        "MT",
        "MH",
        "MQ",
        "MR",
        "MU",
        "YT",
        "MX",
        "FM",
        "MD",
        "MC",
        "MN",
        "ME",
        "MS",
        "MA",
        "MZ",
        "MM",
        "NA",
        "NR",
        "NP",
        "NL",
        "NC",
        "NZ",
        "NI",
        "NE",
        "NG",
        "NU",
        "NF",
        "MP",
        "NO",
        "OM",
        "PK",
        "PW",
        "PS",
        "PA",
        "PG",
        "PY",
        "PE",
        "PH",
        "PN",
        "PL",
        "PT",
        "PR",
        "QA",
        "RO",
        "RU",
        "RW",
        "RE",
        "BL",
        "SH",
        "KN",
        "LC",
        "MF",
        "PM",
        "VC",
        "WS",
        "SM",
        "ST",
        "SA",
        "SN",
        "RS",
        "SC",
        "SL",
        "SG",
        "SX",
        "SK",
        "SI",
        "SB",
        "SO",
        "ZA",
        "GS",
        "SS",
        "ES",
        "LK",
        "SD",
        "SR",
        "SJ",
        "SZ",
        "SE",
        "CH",
        "SY",
        "TW",
        "TJ",
        "TZ",
        "TH",
        "TL",
        "TG",
        "TK",
        "TO",
        "TT",
        "TN",
        "TR",
        "TM",
        "TC",
        "TV",
        "UG",
        "UA",
        "AE",
        "GB",
        "US",
        "UM",
        "UY",
        "UZ",
        "VU",
        "VE",
        "VN",
        "VG",
        "VI",
        "WF",
        "EH",
        "YE",
        "ZM",
        "ZW",
        "AX"
      ]
    },
    "languageCode": {
      "description": "2 digit language iso code in lower case",
      "type": ["string", "null"],
      "enum": [
        "ab",
        "aa",
        "af",
        "sq",
        "am",
        "ar",
        "an",
        "hy",
        "as",
        "ay",
        "az",
        "ba",
        "eu",
        "bn",
        "dz",
        "bh",
        "bi",
        "br",
        "bg",
        "my",
        "be",
        "km",
        "ca",
        "zh",
        "co",
        "hr",
        "cs",
        "da",
        "nl",
        "en",
        "eo",
        "et",
        "fo",
        "fa",
        "fj",
        "fi",
        "fr",
        "fy",
        "gl",
        "gd",
        "gv",
        "ka",
        "de",
        "el",
        "kl",
        "gn",
        "gu",
        "ht",
        "ha",
        "he",
        "iw",
        "hi",
        "hu",
        "is",
        "io",
        "id",
        "in",
        "ia",
        "ie",
        "iu",
        "ik",
        "ga",
        "it",
        "ja",
        "jv",
        "kn",
        "ks",
        "kk",
        "rw",
        "ky",
        "rn",
        "ko",
        "ku",
        "lo",
        "la",
        "lv",
        "li",
        "ln",
        "lt",
        "mk",
        "mg",
        "ms",
        "ml",
        "mt",
        "mi",
        "mr",
        "mo",
        "mn",
        "na",
        "ne",
        "no",
        "oc",
        "or",
        "om",
        "ps",
        "pl",
        "pt",
        "pa",
        "qu",
        "rm",
        "ro",
        "ru",
        "sm",
        "sg",
        "sa",
        "sr",
        "sh",
        "st",
        "tn",
        "sn",
        "ii",
        "sd",
        "si",
        "ss",
        "sk",
        "sl",
        "so",
        "es",
        "su",
        "sw",
        "sv",
        "tl",
        "tg",
        "ta",
        "tt",
        "te",
        "th",
        "bo",
        "ti",
        "to",
        "ts",
        "tr",
        "tk",
        "tw",
        "ug",
        "uk",
        "ur",
        "uz",
        "vi",
        "vo",
        "wa",
        "cy",
        "wo",
        "xh",
        "yi",
        "ji",
        "yo",
        "zu",
        null
      ]
    },
    "operation": {
      "description": "a representation of an operation",
      "example": "BodyShop",
      "type": "string",
      "enum": [
        "BodyShop",
        "BusinessCenter",
        "Carwash",
        "CommercialVehicleCenter",
        "DealerTool",
        "FastFit",
        "ISO4001",
        "ISO9001",
        "MiraiDealer",
        "MotabilityAffiliated",
        "OnlineRetailing",
        "OnlineServiceBooking",
        "PaintShop",
        "PartsShop",
        "PriusDealer",
        "PriusPlug-InCharging",
        "RapidResponseEnabled",
        "ShowRoom",
        "TestDrive",
        "TopCar",
        "ToyotaGazooRacing",
        "ToyotaRentCars",
        "TradeInAppraisal",
        "TSMCertification",
        "UsedCars",
        "WorkShop",
        "YarisGRMN"
      ]
    },
    "operations": {
      "description": "a list of operations",
      "example": "['BodyShop', 'ShowRoom']",
      "type": "array",
      "items": { "$ref": "#/definitions/operation" }
    },
    "day": {
      "description": "the name of a day",
      "example": "MON",
      "type": "string",
      "enum": ["MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN"]
    },
    "openDay": {
      "description": "a range of days on which a certain opening hour is valid",
      "type": "object",
      "required": ["endDay", "startDay", "operation", "validFrom", "validTo"],
      "properties": {
        "endDay": {
          "description": "The final day on which the range of opening hours is valid",
          "$ref": "#/definitions/day"
        },
        "startDay": {
          "description": "The first day on which the range of opening hours is valid",
          "$ref": "#/definitions/day"
        },
        "operation": {
          "description": "The operation this set of opening hours applied to",
          "$ref": "#/definitions/operation"
        },
        "validFrom": {
          "description": "The date in DD/MM/YYYY on which these opening hours became valid",
          "type": "string",
          "pattern": "^[0-3][0-9]\/[0-1][0-9]\/[1-9][0-9]{3}$"
        },
        "validTo": {
          "description": "The date in DD/MM/YYYY until which these opening hours are valid",
          "type": "string",
          "pattern": "^[0-3][0-9]\/[0-1][0-9]\/[1-9][0-9]{3}$"
        },
        "openingHours": {
          "type": "array",
          "items": {
            "type": "object",
            "required": ["openFrom", "openTo"],
            "properties": {
              "openFrom": {
                "description": "Start hour of the opening time",
                "$ref": "#/definitions/time"
              },
              "openTo": {
                "description": "End hour of the opening time",
                "$ref": "#/definitions/time"
              }
            },
            "additionalProperties": false
          }
        }
      },
      "additionalProperties": false
    },
    "time": {
      "description": "a acceptable opening hour start or stop time",
      "example": "8:30 AM",
      "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"
      ]
    },
    "emails": {
      "type": "object",
      "description": "The emails associated with this outlet grouped by usage",
      "properties": {
        "BodyShop": { "$ref": "#/definitions/email" },
        "Brochure": { "$ref": "#/definitions/email" },
        "CallMe": { "$ref": "#/definitions/email" },
        "CarRental": { "$ref": "#/definitions/email" },
        "Carwash": { "$ref": "#/definitions/email" },
        "ContactUs": { "$ref": "#/definitions/email" },
        "OSB": { "$ref": "#/definitions/email" },
        "PaintShop": { "$ref": "#/definitions/email" },
        "PartShop": { "$ref": "#/definitions/email" },
        "SendToDealer": { "$ref": "#/definitions/email" },
        "ShowRoom": { "$ref": "#/definitions/email" },
        "TestDrive": { "$ref": "#/definitions/email" },
        "ToyotaRentCars": { "$ref": "#/definitions/email" },
        "UsedCars": { "$ref": "#/definitions/email" },
        "Workshop": { "$ref": "#/definitions/email" }
      },
      "additionalProperties": false
    },
    "nmsc": {
      "type": "object",
      "description": "Information about the NMSC, mainly mapping codes",
      "properties": {
        "nmscCode": {
          "type": "string",
          "example": "TNO"
        },
        "npaCode": {
          "type": "string",
          "example": "94203"
        }
      }
    },
    "phoneNumbers": {
      "type": "object",
      "description": "The phone numbers associated with this outlet grouped by usage",
      "properties": {
        "BodyShop": { "$ref": "#/definitions/phoneNumber" },
        "Brochure": { "$ref": "#/definitions/phoneNumber" },
        "Carwash": { "$ref": "#/definitions/phoneNumber" },
        "ContactUs": { "$ref": "#/definitions/phoneNumber" },
        "Fax1": { "$ref": "#/definitions/phoneNumber" },
        "Fax2": { "$ref": "#/definitions/phoneNumber" },
        "International Number": { "$ref": "#/definitions/phoneNumber" },
        "Mobile": { "$ref": "#/definitions/phoneNumber" },
        "OSB": { "$ref": "#/definitions/phoneNumber" },
        "PaintShop": { "$ref": "#/definitions/phoneNumber" },
        "PartShop": { "$ref": "#/definitions/phoneNumber" },
        "SendToDealer": { "$ref": "#/definitions/phoneNumber" },
        "ShowRoom": { "$ref": "#/definitions/phoneNumber" },
        "TestDrive": { "$ref": "#/definitions/phoneNumber" },
        "ToyotaRentCars": { "$ref": "#/definitions/phoneNumber" },
        "UsedCars": { "$ref": "#/definitions/phoneNumber" },
        "Workshop": { "$ref": "#/definitions/phoneNumber" }
      },
      "additionalProperties": false
    },
    "urls": {
      "type": "object",
      "description": "The urls associated with this outlet grouped by usage",
      "properties": {
        "BusinessCardURL": { "$ref": "#/definitions/url" },
        "RouteURL": { "$ref": "#/definitions/url" },
        "RSBURL": { "$ref": "#/definitions/url" },
        "ShortURL": { "$ref": "#/definitions/url" },
        "UsedCarsURL": { "$ref": "#/definitions/url" },
        "WebsiteURL": { "$ref": "#/definitions/url" }
      },
      "additionalProperties": false
    },
    "email": {
      "description": "A list of email address.",
      "example": "[\"test@example.com\"]",
      "type": "array",
      "items": {
        "type": "string",
        "format": "email"
      }
    },
    "phoneNumber": {
      "description": "A list of phone numbers",
      "example": "[+32 3 456 78 98]",
      "type": "array",
      "items": { "type": "string" }
    },
    "url": {
      "description": "A list of urls",
      "example": "[\"http://www.example.com\"]",
      "type": "array",
      "items": {
        "type": "string",
        "format": "uri"
      }
    }
  }
}
