{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/viatovia/json-schema/viatovia-fleet-booking-resource-schema.json",
  "title": "FleetBookingResource",
  "x-generated": "2026-12-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/fleet-openapi.json#/components/schemas/FleetBookingResource",
  "type": "object",
  "properties": {
    "reservation_no": {
      "type": "string"
    },
    "booking_reference": {
      "type": [
        "string",
        "null"
      ]
    },
    "status": {
      "$ref": "#/$defs/BookingStatus"
    },
    "cancellation_requested": {
      "type": "boolean"
    },
    "pickup_location": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "POINT"
            },
            "lat": {
              "type": [
                "number",
                "null"
              ]
            },
            "lng": {
              "type": [
                "number",
                "null"
              ]
            },
            "address": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "type",
            "lat",
            "lng",
            "address"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "AIRPORT"
            },
            "iata": {
              "type": "string"
            },
            "lat": {
              "type": [
                "number",
                "null"
              ]
            },
            "lng": {
              "type": [
                "number",
                "null"
              ]
            }
          },
          "required": [
            "type",
            "iata",
            "lat",
            "lng"
          ]
        }
      ]
    },
    "dropoff_location": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "POINT"
            },
            "lat": {
              "type": [
                "number",
                "null"
              ]
            },
            "lng": {
              "type": [
                "number",
                "null"
              ]
            },
            "address": {
              "type": [
                "string",
                "null"
              ]
            }
          },
          "required": [
            "type",
            "lat",
            "lng",
            "address"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "const": "AIRPORT"
            },
            "iata": {
              "type": "string"
            },
            "lat": {
              "type": [
                "number",
                "null"
              ]
            },
            "lng": {
              "type": [
                "number",
                "null"
              ]
            }
          },
          "required": [
            "type",
            "iata",
            "lat",
            "lng"
          ]
        }
      ]
    },
    "pickup_datetime": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Local time at the airport (between two places: at the pickup). The trailing `Z` does not make it UTC."
    },
    "flight_number": {
      "type": [
        "string",
        "null"
      ]
    },
    "passenger": {
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "surname": {
          "type": [
            "string",
            "null"
          ]
        },
        "phone": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": "string"
        }
      },
      "required": [
        "name",
        "surname",
        "phone",
        "email"
      ]
    },
    "passengers": {
      "type": "object",
      "properties": {
        "adult": {
          "type": "integer"
        },
        "children": {
          "type": "integer"
        },
        "infant": {
          "type": "integer"
        }
      },
      "required": [
        "adult",
        "children",
        "infant"
      ]
    },
    "services": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "unit_price": {
            "type": "number"
          },
          "total_price": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "name",
          "quantity",
          "unit_price",
          "total_price"
        ]
      }
    },
    "total": {
      "type": "string"
    },
    "currency": {
      "type": "string"
    },
    "driver": {
      "anyOf": [
        {
          "$ref": "#/$defs/FleetDriverResource"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "required": [
    "reservation_no",
    "booking_reference",
    "status",
    "cancellation_requested",
    "pickup_location",
    "dropoff_location",
    "pickup_datetime",
    "flight_number",
    "passenger",
    "passengers",
    "services",
    "total",
    "currency",
    "driver"
  ],
  "$defs": {
    "BookingStatus": {
      "type": "string",
      "enum": [
        "PENDING",
        "PENDING_APPROVAL",
        "APPROVED",
        "CANCELLED",
        "FAILED",
        "DECLINED",
        "REFUNDED",
        "COMPLETED",
        "DEFAULT"
      ],
      "title": "BookingStatus"
    },
    "FleetDriverResource": {
      "type": "object",
      "properties": {
        "driver_name": {
          "type": [
            "string",
            "null"
          ]
        },
        "driver_phone": {
          "type": [
            "string",
            "null"
          ]
        },
        "vehicle_plate": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "driver_name",
        "driver_phone",
        "vehicle_plate"
      ],
      "title": "FleetDriverResource"
    }
  }
}