{
  "openapi": "3.1.0",
  "info": {
    "title": "TaxiMax — API de devis et de réservation",
    "version": "1.0.0",
    "description": "Chauffeur privé à Paris et en Île-de-France. Le prix est toujours calculé par le serveur. Une réservation envoyée est une DEMANDE : le chauffeur rappelle le client pour la confirmer. Paiement à bord (CB ou espèces). Les agents doivent obtenir l'accord explicite de l'utilisateur avant d'appeler /api/booking.php. Limites : 20 devis et 5 réservations par 10 minutes et par adresse IP.",
    "contact": { "email": "contact@taximax.fr", "url": "https://taximax.fr/contact.html" }
  },
  "servers": [{ "url": "https://taximax.fr" }],
  "paths": {
    "/api/quote.php": {
      "post": {
        "operationId": "getQuote",
        "summary": "Estimer la distance, la durée et le prix d'une course",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Trip" },
            "example": { "departure": "10 rue de Rivoli, 75004 Paris", "arrival": "Aéroport Paris-Charles de Gaulle Terminal 2E", "date": "2026-12-05", "time": "09:30", "passengers": 2, "luggage": 2, "vehicle": "berline", "child_seat": "aucun" } } }
        },
        "responses": {
          "200": { "description": "Estimation", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Quote" } } } },
          "422": { "$ref": "#/components/responses/Error" },
          "429": { "$ref": "#/components/responses/Error" },
          "503": { "description": "Estimation indisponible : la réservation reste possible, prix « sur devis ».", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    },
    "/api/booking.php": {
      "post": {
        "operationId": "requestBooking",
        "summary": "Envoyer une demande de réservation au chauffeur (confirmation par téléphone)",
        "requestBody": {
          "required": true,
          "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Booking" },
            "example": { "departure": "10 rue de Rivoli, 75004 Paris", "arrival": "Aéroport de Paris-Orly", "date": "2026-12-05", "time": "06:15", "passengers": 3, "luggage": 3, "vehicle": "berline", "child_seat": "cosy", "child_seats_count": 1, "name": "Marie Durand", "phone": "+33612345678", "flight": "AF1234", "notes": "Terminal 3" } } }
        },
        "responses": {
          "200": { "description": "Demande reçue, en attente de confirmation par le chauffeur", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/BookingResult" } } } },
          "422": { "$ref": "#/components/responses/Error" },
          "429": { "$ref": "#/components/responses/Error" },
          "502": { "description": "Le chauffeur n'a pas pu être prévenu : appeler le numéro indiqué sur le site.", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Trip": {
        "type": "object",
        "required": ["departure", "arrival"],
        "properties": {
          "departure": { "type": "string", "minLength": 3, "maxLength": 160, "description": "Adresse de prise en charge" },
          "arrival": { "type": "string", "minLength": 3, "maxLength": 160, "description": "Adresse de destination" },
          "date": { "type": "string", "format": "date", "description": "AAAA-MM-JJ, heure de Paris" },
          "time": { "type": "string", "pattern": "^\\d{2}:\\d{2}$", "description": "HH:MM, heure de Paris" },
          "passengers": { "type": "integer", "minimum": 1, "maximum": 7, "default": 1 },
          "luggage": { "type": "integer", "minimum": 0, "maximum": 7, "default": 0 },
          "vehicle": { "type": "string", "enum": ["eco", "berline", "van"], "default": "berline", "description": "eco : 1–3 passagers / 2 bagages ; berline : 1–4 / 3 ; van : jusqu'à 7 / 7. Relevée automatiquement si trop petite." },
          "child_seat": { "type": "string", "enum": ["aucun", "cosy", "siege", "rehausseur"], "default": "aucun", "description": "cosy : 0–13 kg ; siege : 9–18 kg ; rehausseur : 15–36 kg" },
          "child_seats_count": { "type": "integer", "minimum": 1, "maximum": 3, "default": 1 }
        }
      },
      "Booking": {
        "allOf": [
          { "$ref": "#/components/schemas/Trip" },
          {
            "type": "object",
            "required": ["date", "time", "name", "phone"],
            "properties": {
              "name": { "type": "string", "minLength": 2, "maxLength": 80 },
              "phone": { "type": "string", "pattern": "^\\+?[0-9 .()-]{8,20}$", "description": "Le chauffeur rappelle ce numéro pour confirmer" },
              "flight": { "type": "string", "maxLength": 40, "description": "N° de vol ou de train (facultatif)" },
              "notes": { "type": "string", "maxLength": 500 }
            }
          }
        ]
      },
      "Quote": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "km": { "type": "number" },
          "duration": { "type": "string" },
          "vehicle": { "type": "string", "enum": ["eco", "berline", "van"] },
          "price": { "type": "integer", "description": "Prix estimé TTC en euros pour la gamme retenue" },
          "prices": { "type": "object", "properties": { "eco": { "type": "integer" }, "berline": { "type": "integer" }, "van": { "type": "integer" } } },
          "notes": { "type": "array", "items": { "type": "string" } },
          "currency": { "type": "string", "const": "EUR" }
        }
      },
      "BookingResult": {
        "type": "object",
        "properties": {
          "ok": { "type": "boolean" },
          "reference": { "type": "string" },
          "status": { "type": "string", "const": "pending_confirmation" },
          "message": { "type": "string" },
          "vehicle": { "type": "string" },
          "price_estimate": { "type": ["integer", "null"] },
          "currency": { "type": "string" },
          "payment": { "type": "string" }
        }
      },
      "Error": {
        "type": "object",
        "properties": { "ok": { "type": "boolean", "const": false }, "error": { "type": "string" }, "message": { "type": "string" } }
      }
    },
    "responses": {
      "Error": { "description": "Erreur", "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } } }
    }
  }
}
