{
  "openapi": "3.1.0",
  "info": {
    "title": "WG Luxury Restrooms API",
    "version": "1.0.0",
    "summary": "Agent-facing API for quoting, booking, and paying for luxury restroom trailer rentals.",
    "description": "Machine-readable API for WG Luxury Restrooms. Payable operations declare MPP (Machine Payment Protocol) metadata via the `x-payment-info` extension so agents can complete HTTP-native payments.",
    "contact": {
      "name": "WG Luxury Restrooms",
      "email": "info@wgluxrestrooms.com",
      "url": "https://www.wgluxrestrooms.com/contact"
    },
    "termsOfService": "https://www.wgluxrestrooms.com/terms"
  },
  "servers": [
    {
      "url": "https://jdbducppgebfnlyxazgo.supabase.co/functions/v1",
      "description": "Production API"
    }
  ],
  "x-mpp": {
    "version": "0.1",
    "supportedMethods": ["stripe", "card"],
    "currency": "USD",
    "receiptEndpoint": "/verify-checkout-session"
  },
  "tags": [
    { "name": "pricing", "description": "Quote and price lookup" },
    { "name": "payments", "description": "Checkout and payment verification" }
  ],
  "paths": {
    "/get-stripe-price": {
      "post": {
        "operationId": "getRentalPrice",
        "tags": ["pricing"],
        "summary": "Get a price quote for a restroom trailer rental",
        "description": "Returns the current rental price for a given date range and options. Free to call.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/PriceRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Price quote",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/PriceResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" }
        }
      }
    },
    "/create-checkout": {
      "post": {
        "operationId": "createBookingCheckout",
        "tags": ["payments"],
        "summary": "Create a payment session for a booking deposit or balance",
        "description": "Creates a hosted checkout session for a rental deposit or remaining balance. Returns a URL the payer (human or agent) completes the payment at.",
        "x-payment-info": {
          "intent": "session",
          "method": "stripe",
          "currency": "USD",
          "amount": "dynamic",
          "amountSource": "$request.body#/amountInCents",
          "amountUnit": "cents",
          "minimumAmount": 50,
          "maximumAmount": 5000000,
          "description": "Luxury restroom trailer rental — booking deposit or balance payment.",
          "settlement": "hosted-checkout",
          "receiptOperationId": "verifyCheckoutSession"
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/CheckoutRequest" }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Checkout session created",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CheckoutResponse" }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/verify-checkout-session": {
      "post": {
        "operationId": "verifyCheckoutSession",
        "tags": ["payments"],
        "summary": "Verify a completed payment and retrieve the receipt",
        "description": "Confirms whether a checkout session was paid and returns the resulting booking reference. Free to call.",
        "x-payment-info": {
          "intent": "charge",
          "method": "stripe",
          "amount": 0,
          "currency": "USD",
          "description": "Receipt lookup for a previously created checkout session. No charge."
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["sessionId"],
                "properties": {
                  "sessionId": { "type": "string", "description": "Checkout session id returned by createBookingCheckout." }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Payment status",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "paid": { "type": "boolean" },
                    "amountInCents": { "type": "integer" },
                    "currency": { "type": "string" },
                    "bookingRequestId": { "type": "string", "format": "uuid" }
                  }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" }
        }
      }
    }
  },
  "components": {
    "responses": {
      "BadRequest": {
        "description": "Invalid request",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" }
          }
        }
      },
      "RateLimited": {
        "description": "Too many requests",
        "content": {
          "application/json": {
            "schema": { "$ref": "#/components/schemas/Error" }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": { "error": { "type": "string" } }
      },
      "PriceRequest": {
        "type": "object",
        "required": ["startDate", "endDate"],
        "properties": {
          "startDate": { "type": "string", "format": "date" },
          "endDate": { "type": "string", "format": "date" },
          "guestCount": { "type": "integer", "minimum": 1 },
          "eventType": {
            "type": "string",
            "enum": ["wedding", "corporate", "private", "festival", "other"]
          }
        }
      },
      "PriceResponse": {
        "type": "object",
        "properties": {
          "totalInCents": { "type": "integer" },
          "depositInCents": { "type": "integer" },
          "currency": { "type": "string", "default": "USD" },
          "days": { "type": "integer" }
        }
      },
      "CheckoutRequest": {
        "type": "object",
        "required": ["amountInCents", "customerEmail"],
        "properties": {
          "amountInCents": {
            "type": "integer",
            "minimum": 50,
            "maximum": 5000000,
            "description": "Amount to charge now, in USD cents."
          },
          "totalInCents": { "type": "integer", "description": "Full rental total in USD cents." },
          "depositPercent": { "type": "integer", "minimum": 1, "maximum": 100 },
          "description": { "type": "string", "maxLength": 200 },
          "customerEmail": { "type": "string", "format": "email" },
          "returnUrl": { "type": "string", "format": "uri" },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "booking_request_id": { "type": "string", "format": "uuid" }
            }
          }
        }
      },
      "CheckoutResponse": {
        "type": "object",
        "properties": {
          "url": { "type": "string", "format": "uri", "description": "Hosted checkout URL to complete payment." },
          "sessionId": { "type": "string" },
          "amountInCents": { "type": "integer" },
          "currency": { "type": "string", "default": "USD" }
        }
      }
    }
  }
}
