Files
virtual-banker/backend/tools/banking/account_status.go

69 lines
1.6 KiB
Go

package banking
import (
"context"
"github.com/explorer/virtual-banker/backend/tools"
)
// AccountStatusTool gets account status
type AccountStatusTool struct {
client *BankingClient
}
// NewAccountStatusTool creates a new account status tool
func NewAccountStatusTool() *AccountStatusTool {
return &AccountStatusTool{
client: NewBankingClient(getBankingAPIURL()),
}
}
// getBankingAPIURL gets the banking API URL from environment
func getBankingAPIURL() string {
// Default to main API URL
return "http://localhost:8080"
}
// Name returns the tool name
func (t *AccountStatusTool) Name() string {
return "get_account_status"
}
// Description returns the tool description
func (t *AccountStatusTool) Description() string {
return "Get the status of a bank account including balance, transactions, and account details"
}
// Execute executes the tool
func (t *AccountStatusTool) Execute(ctx context.Context, params map[string]interface{}) (*tools.ToolResult, error) {
accountID, ok := params["account_id"].(string)
if !ok || accountID == "" {
return &tools.ToolResult{
Success: false,
Error: "account_id is required",
}, nil
}
// Call banking service
data, err := t.client.GetAccountStatus(ctx, accountID)
if err != nil {
// Fallback to mock data if service unavailable
return &tools.ToolResult{
Success: true,
Data: map[string]interface{}{
"account_id": accountID,
"balance": 10000.00,
"currency": "USD",
"status": "active",
"type": "checking",
"note": "Using fallback data - banking service unavailable",
},
}, nil
}
return &tools.ToolResult{
Success: true,
Data: data,
}, nil
}