{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://objectsgrid.com/.well-known/objects-catalog/Reservation/v1/schema.json",
  "title": "Reservation",
  "description": "Objects Grid Reservation Object. A booking of a table, a room, an event, or an appointment for a service. A private record of a customer: it has no JSON-LD document. The fields of a kind (additionalType) are refused on another kind. Modeled in compliance with https://schema.org/Reservation.",
  "x-objectsgrid-jsonLd": false,
  "type": "object",
  "properties": {
    "at_context": {
      "description": "Schema context",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "https://schema.org"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_type": {
      "description": "The object type",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "Reservation"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "at_id": {
      "description": "This Reservation's ObjectsGrid URL, https://apis.objectsgrid.com/<path>/<id>: its JSON-LD @id, which References point to. Set by the service.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "readOnly": true
    },
    "id": {
      "description": "The unique identifier for Reservation. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "identifier": {
      "description": "The unique identifier for Reservation. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "minLength": 0,
      "maxLength": 50,
      "readOnly": true
    },
    "additionalType": {
      "description": "The kind of reservation, a Schema.org subtype of Reservation: FoodEstablishmentReservation takes partySize, LodgingReservation checkinTime, checkoutTime, numAdults and numChildren and no startTime or endTime; EventReservation and a Reservation of no kind (an appointment, such as a Service at a time) take startTime and endTime. None for a Reservation.",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "FoodEstablishmentReservation",
            "LodgingReservation",
            "EventReservation"
          ]
        },
        {
          "type": "null"
        }
      ]
    },
    "url": {
      "description": "This Reservation URL. Assigned by the server.",
      "type": [
        "string",
        "null"
      ],
      "format": "uri",
      "minLength": 1,
      "readOnly": true
    },
    "reservationId": {
      "description": "The identifier of the reservation, e.g. a booking reference",
      "type": [
        "string",
        "null"
      ]
    },
    "reservationStatus": {
      "description": "The status of the reservation",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ReservationStatusType/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "bookingTime": {
      "description": "When the reservation was made",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "modifiedTime": {
      "description": "When the reservation was last changed",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "totalPrice": {
      "description": "The total price of the reservation",
      "type": [
        "number",
        "null"
      ],
      "minimum": 0
    },
    "priceCurrency": {
      "description": "The currency of totalPrice, ISO 4217",
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/CurrencyCodeEnumeration/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "startTime": {
      "description": "When the booking starts: a table, an appointment, a slot. Every kind but LodgingReservation, which has checkinTime. An appointment (no kind) with a provider, startTime and endTime holds the provider for that time: another one overlapping it is refused with 409",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "endTime": {
      "description": "When the booking ends, if it has an end. Every kind but LodgingReservation, which has checkoutTime",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "partySize": {
      "description": "FoodEstablishmentReservation: the number of people",
      "type": [
        "integer",
        "null"
      ],
      "minimum": 1
    },
    "checkinTime": {
      "description": "LodgingReservation: the earliest check-in",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "checkoutTime": {
      "description": "LodgingReservation: the latest check-out",
      "type": [
        "string",
        "null"
      ],
      "format": "date-time"
    },
    "numAdults": {
      "description": "LodgingReservation: the number of adults",
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    },
    "numChildren": {
      "description": "LodgingReservation: the number of children",
      "type": [
        "integer",
        "null"
      ],
      "minimum": 0
    },
    "reservationFor": {
      "description": "What is reserved: an Event, a Place such as a restaurant or hotel, an Accommodation (a room or unit: two LodgingReservations of one Accommodation can't overlap), a Service, a Product or an Organization",
      "x-objectsgrid-rangeIncludes": [
        "Event",
        "Place",
        "Service",
        "Product",
        "Organization",
        "Accommodation"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "underName": {
      "x-objectsgrid-erasure": "keep",
      "description": "The person or organization the reservation is for",
      "x-objectsgrid-rangeIncludes": [
        "Person",
        "Organization"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "provider": {
      "x-objectsgrid-erasure": "keep",
      "description": "The party providing what is reserved",
      "x-objectsgrid-rangeIncludes": [
        "Organization",
        "Person"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "broker": {
      "x-objectsgrid-erasure": "keep",
      "description": "An entity that arranged the reservation",
      "x-objectsgrid-rangeIncludes": [
        "Organization",
        "Person"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "reservedTicket": {
      "description": "The tickets of the reservation, with their seats",
      "type": [
        "array",
        "null"
      ],
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Ticket/v1/schema.json"
      },
      "maxItems": 100
    },
    "programMembershipUsed": {
      "description": "The membership the reservation was made with, e.g. for a member price",
      "x-objectsgrid-rangeIncludes": [
        "ProgramMembership"
      ],
      "anyOf": [
        {
          "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Reference/v1/schema.json"
        },
        {
          "type": "null"
        }
      ]
    },
    "tags": {
      "description": "Tags an ABAC policy can decide on. A name may repeat; the same name and value appear once. Every stored object has them: created empty when not sent, kept by a replacement (PUT) that does not mention them, unchanged by a patch that does not mention them, cleared by null or [].",
      "type": "array",
      "default": [],
      "uniqueItems": true,
      "maxItems": 50,
      "items": {
        "$ref": "https://objectsgrid.com/.well-known/objects-catalog/Tag/v1/schema.json"
      }
    },
    "meta": {
      "description": "System-managed metadata for the object (version, audit fields). Assigned by the server.",
      "$ref": "https://objectsgrid.com/.well-known/objects-catalog/ObjectMeta/v1/schema.json",
      "readOnly": true
    },
    "lodgingUnitType": {
      "description": "LodgingReservation: the category booked when the stay is of the hotel (reservationFor a Place), not of one Accommodation, e.g. 'Deluxe double'",
      "type": [
        "string",
        "null"
      ],
      "maxLength": 200
    },
    "lodgingUnitDescription": {
      "description": "LodgingReservation: a description of the unit booked",
      "type": [
        "string",
        "null"
      ],
      "maxLength": 2000
    },
    "checkIns": {
      "description": "Its check-ins. Computed, read-only: the objects whose CheckInAction.object points to this object, listed from that type; never stored or written. ObjectsGrid's, beyond Schema.org: attendance as a list; left out of JSON-LD documents.",
      "x-objectsgrid-inverseOf": "CheckInAction.object",
      "readOnly": true,
      "x-objectsgrid-extension": true
    }
  },
  "required": [
    "reservationFor",
    "underName"
  ],
  "allOf": [
    {
      "if": {
        "required": [
          "additionalType"
        ],
        "properties": {
          "additionalType": {
            "const": "FoodEstablishmentReservation"
          }
        }
      },
      "else": {
        "not": {
          "anyOf": [
            {
              "required": [
                "partySize"
              ]
            }
          ]
        }
      }
    },
    {
      "if": {
        "required": [
          "additionalType"
        ],
        "properties": {
          "additionalType": {
            "const": "LodgingReservation"
          }
        }
      },
      "else": {
        "not": {
          "anyOf": [
            {
              "required": [
                "checkinTime"
              ]
            },
            {
              "required": [
                "checkoutTime"
              ]
            },
            {
              "required": [
                "numAdults"
              ]
            },
            {
              "required": [
                "numChildren"
              ]
            },
            {
              "required": [
                "lodgingUnitType"
              ]
            },
            {
              "required": [
                "lodgingUnitDescription"
              ]
            }
          ]
        }
      }
    },
    {
      "if": {
        "required": [
          "additionalType"
        ],
        "properties": {
          "additionalType": {
            "const": "LodgingReservation"
          }
        }
      },
      "then": {
        "not": {
          "anyOf": [
            {
              "required": [
                "startTime"
              ]
            },
            {
              "required": [
                "endTime"
              ]
            }
          ]
        }
      }
    }
  ],
  "unevaluatedProperties": false
}
