{
  "openapi": "3.1.0",
  "info": {
    "title": "Iliana Apartments Crete — Availability & Direct Booking API",
    "version": "1.0.0",
    "description": "Public API for AI travel assistants and booking agents to inspect apartments, check live iCal-synced availability, calculate seasonal quotes, and submit direct reservations at Iliana Apartments in Platanos, Falasarna, Crete.",
    "contact": {
      "name": "Fotios — Host at Iliana Apartments",
      "url": "https://ilianaapartments.gr/",
      "email": "fotiosvol@yahoo.gr"
    }
  },
  "servers": [
    {
      "url": "https://ilianaapartments.gr",
      "description": "Production server"
    },
    {
      "url": "http://localhost:8000",
      "description": "Local development server"
    }
  ],
  "paths": {
    "/api/index.php": {
      "get": {
        "operationId": "getAvailabilityOrQuote",
        "summary": "Get all apartments & occupied date ranges (action=public) or calculate a live price quote (action=quote)",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["public", "quote"]
            },
            "description": "Use 'public' to fetch all 5 apartments and occupied date ranges, or 'quote' to compute pricing and availability for specific dates."
          },
          {
            "name": "checkIn",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2026-07-10"
            },
            "description": "Check-in date in YYYY-MM-DD format (required when action=quote)."
          },
          {
            "name": "checkOut",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "date",
              "example": "2026-07-15"
            },
            "description": "Check-out date in YYYY-MM-DD format (required when action=quote)."
          },
          {
            "name": "guests",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 6,
              "default": 2
            },
            "description": "Number of guests."
          },
          {
            "name": "room",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "enum": ["koutris", "rapanas", "ligia", "platanos", "selia"]
            },
            "description": "Optional apartment slug. If omitted when action=quote, quotes for all 5 apartments are returned."
          }
        ],
        "responses": {
          "200": {
            "description": "Successful availability or quote response"
          }
        }
      },
      "post": {
        "operationId": "createDirectBooking",
        "summary": "Submit a direct reservation or booking request (action=book)",
        "parameters": [
          {
            "name": "action",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": ["book"]
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["roomSlug", "checkIn", "checkOut", "guests", "guestName", "guestEmail", "guestPhone"],
                "properties": {
                  "roomSlug": {
                    "type": "string",
                    "enum": ["koutris", "rapanas", "ligia", "platanos", "selia"],
                    "description": "Target apartment slug."
                  },
                  "checkIn": {
                    "type": "string",
                    "format": "date",
                    "example": "2026-07-10"
                  },
                  "checkOut": {
                    "type": "string",
                    "format": "date",
                    "example": "2026-07-15"
                  },
                  "guests": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 4,
                    "default": 2
                  },
                  "guestName": {
                    "type": "string",
                    "description": "Full name of the primary guest."
                  },
                  "guestEmail": {
                    "type": "string",
                    "format": "email",
                    "description": "Guest email address."
                  },
                  "guestPhone": {
                    "type": "string",
                    "description": "Guest phone or WhatsApp number with country code."
                  },
                  "notes": {
                    "type": "string",
                    "description": "Optional arrival time, baby cot request, or special notes."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Reservation created and host notified immediately."
          },
          "400": {
            "description": "Selected dates unavailable or minimum stay not met."
          }
        }
      }
    }
  }
}
