{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "title": "Trip",
  "type": "object",
  "properties": {
    "connectionId": {
      "type": "string",
      "description": "The ID of the connection that this record belongs to."
    },
    "id": {
      "title": "TripId",
      "type": "string",
      "format": "ulid"
    },
    "sourceId": {
      "title": "SourceId",
      "type": "string",
      "description": "The ID used to represent the entity in the source system."
    },
    "driver": {
      "description": "The driver that was driving during the trip.",
      "title": "DriverId",
      "type": "string",
      "format": "ulid",
      "pattern": "^drv_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "vehicle": {
      "description": "The vehicle that was involved in the trip.",
      "title": "VehicleId",
      "type": "string",
      "format": "ulid",
      "pattern": "^vcl_[0-9A-HJKMNP-TV-Z]{26}$"
    },
    "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)."
    },
    "startedAt": {
      "description": "The time the trip started",
      "title": "ISODateTime",
      "type": "string",
      "format": "date-time"
    },
    "endedAt": {
      "description": "The time the trip ended",
      "title": "ISODateTime",
      "type": "string",
      "format": "date-time"
    },
    "startLocation": {
      "title": "Coordinates",
      "type": "object",
      "properties": {
        "longitude": {
          "type": "number"
        },
        "latitude": {
          "type": "number"
        }
      },
      "required": ["longitude", "latitude"]
    },
    "endLocation": {
      "title": "Coordinates",
      "type": "object",
      "properties": {
        "longitude": {
          "type": "number"
        },
        "latitude": {
          "type": "number"
        }
      },
      "required": ["longitude", "latitude"]
    },
    "distance": {
      "title": "Distance In Kilometers",
      "type": "number",
      "format": "double",
      "description": "Distance in kilometers"
    },
    "duration": {
      "minimum": 0,
      "title": "DurationInMS",
      "type": "integer",
      "description": "Duration in MS"
    },
    "metadata": {
      "title": "DeletableEntityMetadata",
      "type": "object",
      "description": "Internal metadata about the record.",
      "required": ["addedAt", "modifiedAt"],
      "properties": {
        "addedAt": {
          "title": "AddedAt",
          "type": "string",
          "format": "date-time",
          "description": "The date and time the record was ingested into Terminal. Note: this is not the date and time the record was created in the provider's system."
        },
        "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."
        },
        "deletedAt": {
          "title": "DeletedAt",
          "type": "string",
          "format": "date-time",
          "description": "The date and time the record was deleted from Terminal. Note: this is not the date and time the record was deleted 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",
    "sourceId",
    "vehicle",
    "startedAt",
    "endedAt",
    "duration",
    "metadata"
  ]
}
