#include <iostream>
#include <cstdlib>
#include <string>

using namespace std;

int main() {
    // 1. URL DEL TUO WEBHOOK (Assicurati che sia il TEST URL)
    string url = "http://e...content-available-to-author-only...s.org:5678/webhook-test/8845bae0-9e81-423a-adc5-8c523733140e";
    string nome;

    cout << "--- SKIFIDOR PLUS: TEST INVIO POST ---" << endl;
    cout << "Inserisci nome: ";
    getline(cin, nome);

    // 2. COMANDO POST AGGIORNATO
    // -i: mostra l'intestazione della risposta (per vedere se riceve 200 OK o 404)
    // -X POST: forza il metodo POST
    // -H: dice a n8n che stiamo inviando JSON
    string comando = "curl -i -X POST " + url + 
                     " -H \"Content-Type: application/json\" " + 
                     " -d \"{\\\"nome\\\":\\\"" + nome + "\\\"}\"";

    cout << "\n[DEBUG] Comando inviato: " << comando << endl;
    cout << "\n--- RISPOSTA DAL SERVER ---" << endl;

    // Esecuzione
    int exitCode = system(comando.c_str());

    cout << "\n---------------------------" << endl;
    cout << "[DEBUG] Codice d'uscita sistema: " << exitCode << endl;
    
    if(exitCode != 0) {
        cout << "[ERRORE] Il comando curl non è riuscito a connettersi a internet." << endl;
    }

    return 0;
}