{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Vehicle Location",
  "type": "object",
  "properties": {
    "connectionId": {
      "type": "string",
      "description": "The ID of the connection that this record belongs to."
    },
    "id": {
      "title": "VehicleLocationId",
      "description": "Unique identifier for the vehicle location in Terminal.",
      "type": "string",
      "format": "ulid"
    },
    "sourceId": {
      "title": "SourceId",
      "type": "string",
      "description": "The ID used to represent the entity in the source system."
    },
    "provider": {
      "type": "string",
      "description": "Every provider has a unique code to identify it across Terminal's system. You can find each provider's code under [provider details](/providers)."
    },
    "vehicle": {
      "description": "The vehicle that the location is tracking.",
      "title": "VehicleId",
      "type": "string",
      "format": "ulid",
      "pattern": "^vcl_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "driver": {
      "description": "The driver that was driving the vehicle at the time of this location.",
      "title": "DriverId",
      "type": "string",
      "format": "ulid",
      "pattern": "^drv_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "locatedAt": {
      "title": "ISODateTime",
      "type": "string",
      "format": "date-time",
      "description": "[ISO 8601](https://www.w3.org/TR/NOTE-datetime) date"
    },
    "location": {
      "title": "Coordinates",
      "type": "object",
      "properties": {
        "longitude": {
          "type": "number"
        },
        "latitude": {
          "type": "number"
        }
      },
      "required": ["longitude", "latitude"]
    },
    "address": {
      "type": "object",
      "description": "Reverse geocoded address details for locations when available at the source.",
      "properties": {
        "formatted": {
          "type": "string"
        }
      }
    },
    "heading": {
      "title": "Heading In Degrees",
      "type": "number",
      "description": "Heading in degrees"
    },
    "speed": {
      "title": "Speed In KPH",
      "type": "number",
      "description": "Speed in KPH rounded to 2 decimal places."
    },
    "metadata": {
      "title": "TimeSeriesMetadata",
      "type": "object",
      "description": "Internal metadata about the time series.",
      "required": ["modifiedAt"],
      "properties": {
        "modifiedAt": {
          "title": "ModifiedAt",
          "type": "string",
          "format": "date-time",
          "description": "The date and time the record was last updated in Terminal. Note: this is not the date and time the record was updated in the provider's system."
        }
      }
    },
    "raw": {
      "title": "RawDataList",
      "type": "array",
      "items": {
        "title": "RawData",
        "type": "object",
        "properties": {
          "provider": {
            "type": "string"
          },
          "schema": {
            "type": "string"
          },
          "extractedAt": {
            "type": "string"
          },
          "data": {
            "type": "object"
          }
        },
        "required": ["provider", "schema", "extractedAt", "data"]
      }
    }
  },
  "required": [
    "connectionId",
    "id",
    "provider",
    "vehicle",
    "locatedAt",
    "location",
    "metadata"
  ]
}
