{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/viatovia/json-schema/viatovia-booking-resource-schema.json",
  "title": "BookingResource",
  "x-generated": "2026-12-04",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/booking-openapi.json#/components/schemas/BookingResource",
  "type": "object",
  "properties": {
    "reservation_no": {
      "type": "string"
    },
    "status": {
      "$ref": "#/$defs/BookingStatus"
    },
    "pickup_location": {
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string",
          "enum": [
            "AIRPORT",
            "PLACE"
          ]
        }
      },
      "required": [
        "name",
        "type"
      ]
    },
    "dropoff_location": {
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": "string",
          "enum": [
            "AIRPORT",
            "PLACE"
          ]
        }
      },
      "required": [
        "name",
        "type"
      ]
    },
    "pickup_datetime": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "Local time at the airport (between two places: at the pickup), as sent in the search. The trailing `Z` does not make it UTC."
    },
    "flight_number": {
      "type": [
        "string",
        "null"
      ]
    },
    "passengers": {
      "type": "object",
      "properties": {
        "adult": {
          "type": "integer"
        },
        "children": {
          "type": "integer"
        },
        "infant": {
          "type": "integer"
        }
      },
      "required": [
        "adult",
        "children",
        "infant"
      ]
    },
    "passenger": {
      "type": "object",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "surname": {
          "type": [
            "string",
            "null"
          ]
        },
        "email": {
          "type": [
            "string",
            "null"
          ]
        },
        "phone": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "surname",
        "email",
        "phone"
      ]
    },
    "vehicle": {
      "type": "object",
      "properties": {
        "make": {
          "type": [
            "string",
            "null"
          ]
        },
        "model": {
          "type": [
            "string",
            "null"
          ]
        },
        "type": {
          "type": [
            "string",
            "null"
          ]
        },
        "image": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "make",
        "model",
        "type",
        "image"
      ]
    },
    "driver": {
      "type": [
        "object",
        "null"
      ],
      "description": "Null until a driver is assigned.",
      "properties": {
        "name": {
          "type": [
            "string",
            "null"
          ]
        },
        "phone": {
          "type": [
            "string",
            "null"
          ]
        },
        "vehicle_plate": {
          "type": [
            "string",
            "null"
          ]
        },
        "vehicle_make": {
          "type": [
            "string",
            "null"
          ]
        },
        "vehicle_model": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "name",
        "phone",
        "vehicle_plate",
        "vehicle_make",
        "vehicle_model"
      ]
    },
    "price": {
      "type": "object",
      "properties": {
        "total": {
          "description": "Price of the transfer; extra services are priced in `extra_services`.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            }
          ]
        },
        "currency": {
          "type": "string"
        },
        "converted_total": {
          "description": "The total in the currency asked for in the search; charging stays in `currency`.",
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "number"
            },
            {
              "type": "null"
            }
          ]
        },
        "converted_currency": {
          "type": [
            "string",
            "null"
          ]
        }
      },
      "required": [
        "total",
        "currency",
        "converted_total",
        "converted_currency"
      ]
    },
    "distance_km": {
      "type": "integer",
      "description": "The route distance in metres, despite its name; kept as it is for existing integrations."
    },
    "booking_type": {
      "type": "string"
    },
    "is_cancelable": {
      "type": "boolean",
      "description": "Whether the status allows a cancellation. The 48-hour limit is checked when you cancel."
    },
    "extra_services": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "id": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "price": {
            "type": "number"
          }
        },
        "required": [
          "id",
          "name",
          "quantity",
          "price"
        ]
      }
    }
  },
  "required": [
    "reservation_no",
    "status",
    "pickup_location",
    "dropoff_location",
    "pickup_datetime",
    "flight_number",
    "passengers",
    "passenger",
    "vehicle",
    "driver",
    "price",
    "distance_km",
    "booking_type",
    "is_cancelable",
    "extra_services"
  ],
  "$defs": {
    "BookingStatus": {
      "type": "string",
      "enum": [
        "PENDING",
        "PENDING_APPROVAL",
        "APPROVED",
        "CANCELLED",
        "FAILED",
        "DECLINED",
        "REFUNDED",
        "COMPLETED",
        "DEFAULT"
      ],
      "title": "BookingStatus"
    }
  }
}