{
  "openapi": "3.1.0",
  "info": {
    "title": "Decorato richieste autorizzate",
    "version": "1.0.0",
    "description": "Solo richieste desiderate dall’utente. Registrazione e invio email sono stati distinti. Nessuna prenotazione o contratto automatico."
  },
  "servers": [
    {
      "url": "https://traslochimilano.casa"
    }
  ],
  "paths": {
    "/api/preventivi": {
      "post": {
        "operationId": "richiediPreventivo",
        "summary": "Registra una richiesta autorizzata",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nome": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "email": {
                    "type": "string",
                    "maxLength": 300,
                    "format": "email"
                  },
                  "telefono": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "partenza": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "destinazione": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "messaggio": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "data": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "abitazione": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "piano_partenza": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "piano_arrivo": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "ascensore_partenza": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "ascensore_arrivo": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "sopralluogo": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "pagina": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "servizi": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "request_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Riutilizzare per ripetere la stessa richiesta senza duplicarla."
                  },
                  "consenso": {
                    "type": "boolean",
                    "const": true
                  },
                  "agente": {
                    "type": "boolean"
                  },
                  "autorizzazione_utente": {
                    "type": "boolean",
                    "description": "Deve essere true quando agente è true: autorizzazione esplicita ottenuta prima di inviare."
                  },
                  "website": {
                    "type": "string",
                    "maxLength": 0
                  }
                },
                "required": [
                  "nome",
                  "email",
                  "telefono",
                  "partenza",
                  "destinazione",
                  "consenso"
                ],
                "allOf": [
                  {
                    "if": {
                      "properties": {
                        "agente": {
                          "const": true
                        }
                      },
                      "required": [
                        "agente"
                      ]
                    },
                    "then": {
                      "properties": {
                        "autorizzazione_utente": {
                          "const": true
                        }
                      },
                      "required": [
                        "autorizzazione_utente"
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Richiesta già registrata: controllare notification."
          },
          "201": {
            "description": "Registrata: ok=true, id, notification (sent, failed, pending, sending, not_configured)."
          },
          "400": {
            "description": "Dati o consenso non validi."
          },
          "409": {
            "description": "request_id usato per dati diversi."
          },
          "413": {
            "description": "Corpo troppo grande."
          },
          "415": {
            "description": "Serve application/json."
          },
          "429": {
            "description": "Attendere 15 minuti."
          },
          "503": {
            "description": "Servizio da attivare o registrazione non confermata."
          }
        }
      }
    },
    "/api/contatti": {
      "post": {
        "operationId": "contattaDecorato",
        "summary": "Registra una richiesta autorizzata",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "nome": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "email": {
                    "type": "string",
                    "maxLength": 300,
                    "format": "email"
                  },
                  "telefono": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "partenza": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "destinazione": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "messaggio": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "data": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "abitazione": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "piano_partenza": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "piano_arrivo": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "ascensore_partenza": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "ascensore_arrivo": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "sopralluogo": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "pagina": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "servizi": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "note": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "request_id": {
                    "type": "string",
                    "format": "uuid",
                    "description": "Riutilizzare per ripetere la stessa richiesta senza duplicarla."
                  },
                  "consenso": {
                    "type": "boolean",
                    "const": true
                  },
                  "agente": {
                    "type": "boolean"
                  },
                  "autorizzazione_utente": {
                    "type": "boolean",
                    "description": "Deve essere true quando agente è true: autorizzazione esplicita ottenuta prima di inviare."
                  },
                  "website": {
                    "type": "string",
                    "maxLength": 0
                  }
                },
                "required": [
                  "nome",
                  "email",
                  "messaggio",
                  "consenso"
                ],
                "allOf": [
                  {
                    "if": {
                      "properties": {
                        "agente": {
                          "const": true
                        }
                      },
                      "required": [
                        "agente"
                      ]
                    },
                    "then": {
                      "properties": {
                        "autorizzazione_utente": {
                          "const": true
                        }
                      },
                      "required": [
                        "autorizzazione_utente"
                      ]
                    }
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Richiesta già registrata: controllare notification."
          },
          "201": {
            "description": "Registrata: ok=true, id, notification (sent, failed, pending, sending, not_configured)."
          },
          "400": {
            "description": "Dati o consenso non validi."
          },
          "409": {
            "description": "request_id usato per dati diversi."
          },
          "413": {
            "description": "Corpo troppo grande."
          },
          "415": {
            "description": "Serve application/json."
          },
          "429": {
            "description": "Attendere 15 minuti."
          },
          "503": {
            "description": "Servizio da attivare o registrazione non confermata."
          }
        }
      }
    }
  }
}