#!/bin/bash
echo "🏦 DIRECT BANK HAPOALIM TEST"
echo "============================"
echo ""
echo "Testing Bank Hapoalim recommendations with customer_account_key=16185"
echo ""
{
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{"roots":{"listChanged":true}},"clientInfo":{"name":"test","version":"1.0.0"}}}'
sleep 1
echo '{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"authenticate_user","arguments":{"username":"david+allcloud@umbrellacost.com","password":"B4*zcI7#F7poEC"}}}'
sleep 3
echo '{"jsonrpc":"2.0","id":3,"method":"tools/call","params":{"name":"api___recommendations_report","arguments":{"customer_account_key":"16185"}}}'
sleep 5
} | node dist/index.js 2>bank_stderr.log | tee bank_response.json
echo ""
echo "Checking stderr logs for API key..."
grep -E "(16185|customer API key|Built customer)" bank_stderr.log | head -5
echo ""
echo "Checking response for Bank Hapoalim data..."
if grep -q "903147367433" bank_response.json; then
echo "✅ Bank Hapoalim account 903147367433 found!"
else
echo "⚠️ Bank Hapoalim account not confirmed in response"
fi
echo ""
echo "Extracting recommendations count..."
grep -o "Results:.* recommendations" bank_response.json | head -1
echo ""
echo "Extracting total savings..."
grep -o "Total Potential Annual Savings:.* \\$[0-9.]*" bank_response.json | head -1
rm -f bank_stderr.log bank_response.json