Add full monorepo: virtual-banker, backend, frontend, docs, scripts, deployment
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
68
backend/tools/banking/account_status.go
Normal file
68
backend/tools/banking/account_status.go
Normal file
@@ -0,0 +1,68 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user