import { Request, Response, NextFunction } from 'express';
import { GetWalletBalancesForNetworkUseCase } from '../../application/use-cases/balance/get-wallet-balances-for-network.use-case';
import { GetAllWalletBalancesUseCase } from '../../application/use-cases/balance/get-all-wallet-balances.use-case';

export class BalanceController {
  constructor(
    private readonly getWalletBalancesForNetworkUseCase: GetWalletBalancesForNetworkUseCase,
    private readonly getAllWalletBalancesUseCase: GetAllWalletBalancesUseCase,
  ) {}

  getForNetwork = async (req: Request, res: Response, next: NextFunction): Promise<void> => {
    try {
      const balances = await this.getWalletBalancesForNetworkUseCase.execute(
        req.params.walletId as string,
        req.params.networkId as string,
      );
      res.status(200).json({ success: true, data: balances });
    } catch (error) {
      next(error);
    }
  };

  getAll = async (req: Request, res: Response, next: NextFunction): Promise<void> => {
    try {
      const balances = await this.getAllWalletBalancesUseCase.execute(
        req.params.walletId as string,
      );
      res.status(200).json({ success: true, data: balances });
    } catch (error) {
      next(error);
    }
  };
}
