#!/bin/bash # Script di Test API NetGescon # Uso: ./test-api.sh echo "🔄 NETGESCON - Test API REST" echo "============================" BASE_URL="http://192.168.0.200/api/netgescon/v1" API_KEY="netgescon_api_2025_secure_key_v1" echo "🌐 Base URL: $BASE_URL" echo "🔑 API Key: $API_KEY" echo "" # 1. Test Ping echo "📡 1. TEST PING" echo "---------------" curl -s -X GET "$BASE_URL/ping" | jq '.' || echo "❌ Errore ping" echo "" # 2. Test Status echo "📊 2. TEST STATUS" echo "-----------------" curl -s -X GET "$BASE_URL/soggetti/status" \ -H "Content-Type: application/json" \ -d "{\"api_key\":\"$API_KEY\"}" | jq '.' || echo "❌ Errore status" echo "" # 3. Test Send (recupera soggetti) echo "📤 3. TEST SEND (Recupera Soggetti)" echo "-----------------------------------" curl -s -X GET "$BASE_URL/soggetti/send?api_key=$API_KEY&limit=5" | jq '.' || echo "❌ Errore send" echo "" # 4. Test Receive (inserisce soggetti) echo "📥 4. TEST RECEIVE (Inserisce Soggetti)" echo "---------------------------------------" curl -s -X POST "$BASE_URL/soggetti/receive" \ -H "Content-Type: application/json" \ -d '{ "api_key": "'$API_KEY'", "soggetti": [ { "old_id": 999, "nome": "Test", "cognome": "ApiRest", "codice_fiscale": "TSTAPI85A01H501Z", "email": "test.api@netgescon.it", "telefono": "333.TEST.API", "indirizzo": "Via Test API 1", "cap": "20121", "citta": "Milano", "provincia": "MI", "tipo": "persona_fisica" } ] }' | jq '.' || echo "❌ Errore receive" echo "" echo "✅ Test API completati!" echo "" echo "🔧 COMANDI UTILI:" echo "Ping: curl -X GET $BASE_URL/ping" echo "Status: curl -X GET '$BASE_URL/soggetti/status' -H 'Content-Type: application/json' -d '{\"api_key\":\"$API_KEY\"}'" echo "Lista Soggetti: curl -X GET '$BASE_URL/soggetti/send?api_key=$API_KEY&limit=10'"