{
  "openapi": "3.1.0",
  "info": {
    "title": "Cape May Beach Houses booking API",
    "version": "1.0.0",
    "description": "Check availability, price a stay, and send a request to book a Cape May vacation home for a guest. Requests are emailed to that house's owners, who confirm by email; nothing is charged through this API. Responses carry `API-Version: 1`; breaking changes ship under /api/v2 with at least 90 days' notice on https://capemaybeachhouses.com/developers.",
    "contact": {
      "name": "Cape May Beach Houses",
      "url": "https://capemaybeachhouses.com/contact"
    }
  },
  "externalDocs": {
    "url": "https://capemaybeachhouses.com/developers"
  },
  "servers": [
    {
      "url": "https://capemaybeachhouses.com"
    }
  ],
  "paths": {
    "/api/availability": {
      "get": {
        "operationId": "getAvailability",
        "summary": "Booked date ranges for a house",
        "parameters": [
          {
            "name": "house",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "824-stockton",
                "220-south-lafayette",
                "918-columbia"
              ]
            }
          },
          {
            "name": "format",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "json",
                "md"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Booked ranges",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Availability"
                }
              },
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Problem details",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/quote": {
      "get": {
        "operationId": "getQuote",
        "summary": "Price and rule check for a stay",
        "parameters": [
          {
            "name": "house",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "824-stockton",
                "220-south-lafayette",
                "918-columbia"
              ]
            }
          },
          {
            "name": "checkin",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2027-09-11"
            }
          },
          {
            "name": "checkout",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2027-09-11"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Quote (null for houses quoted by email) and rule check",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteResponse"
                }
              }
            }
          },
          "400": {
            "description": "Problem details",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/inquire": {
      "post": {
        "operationId": "requestToBook",
        "summary": "Send a request to book (only with the guest's permission)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Inquiry"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Request sent to the house's owners",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InquiryResult"
                }
              }
            }
          },
          "400": {
            "description": "Problem details",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "409": {
            "description": "Problem details",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "502": {
            "description": "Problem details",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "503": {
            "description": "Problem details",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Range": {
        "type": "object",
        "required": [
          "start",
          "end"
        ],
        "properties": {
          "start": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11",
            "description": "First booked night"
          },
          "end": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11",
            "description": "Checkout day; free again"
          }
        }
      },
      "Availability": {
        "type": "object",
        "properties": {
          "house": {
            "type": "string"
          },
          "property": {
            "type": "string"
          },
          "updated": {
            "type": "string",
            "format": "date-time"
          },
          "lastBookableNight": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11"
          },
          "booked": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Range"
            }
          },
          "calendarsSynced": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "complete": {
            "type": "boolean",
            "description": "False when the house's live calendar isn't connected yet"
          }
        }
      },
      "PlatformPrice": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "total": {
            "type": "integer",
            "description": "Guest total on that platform for the dates, with its cleaning and service fees, before taxes"
          }
        }
      },
      "Quote": {
        "type": "object",
        "properties": {
          "house": {
            "type": "string"
          },
          "checkin": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11"
          },
          "checkout": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11"
          },
          "nights": {
            "type": "integer"
          },
          "directNights": {
            "type": "integer"
          },
          "directCleaning": {
            "type": "integer"
          },
          "directTotal": {
            "type": "integer"
          },
          "compareTo": {
            "type": "string"
          },
          "platformTotal": {
            "type": "integer",
            "description": "Total on the cheapest platform (compareTo)"
          },
          "platforms": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PlatformPrice"
            },
            "description": "Every platform's total, cheapest first"
          },
          "savings": {
            "type": "integer"
          },
          "currency": {
            "type": "string"
          },
          "note": {
            "type": "string"
          }
        }
      },
      "QuoteResponse": {
        "type": "object",
        "properties": {
          "house": {
            "type": "string"
          },
          "checkin": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11"
          },
          "checkout": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11"
          },
          "available": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "problems": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "quote": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Quote"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "Inquiry": {
        "type": "object",
        "required": [
          "house",
          "checkin",
          "checkout",
          "guests",
          "name",
          "email",
          "phone"
        ],
        "properties": {
          "house": {
            "type": "string",
            "enum": [
              "824-stockton",
              "220-south-lafayette",
              "918-columbia"
            ]
          },
          "checkin": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11"
          },
          "checkout": {
            "type": "string",
            "format": "date",
            "example": "2027-09-11"
          },
          "guests": {
            "type": "integer",
            "minimum": 1,
            "maximum": 18
          },
          "name": {
            "type": "string",
            "maxLength": 120
          },
          "email": {
            "type": "string",
            "format": "email"
          },
          "phone": {
            "type": "string",
            "maxLength": 40
          },
          "message": {
            "type": "string",
            "maxLength": 3000
          }
        }
      },
      "InquiryResult": {
        "type": "object",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "message": {
            "type": "string"
          },
          "quote": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/Quote"
              },
              {
                "type": "null"
              }
            ]
          }
        }
      },
      "Problem": {
        "type": "object",
        "required": [
          "type",
          "title",
          "status"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "problems": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    }
  }
}