"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenController = void 0;
class TokenController {
    getTokenByIdUseCase;
    getTokenBySymbolUseCase;
    getTokensByNetworkUseCase;
    getAllTokensUseCase;
    getTokenChartUseCase;
    getTokenPricesUseCase;
    resolveTokenByContractUseCase;
    constructor(getTokenByIdUseCase, getTokenBySymbolUseCase, getTokensByNetworkUseCase, getAllTokensUseCase, getTokenChartUseCase, getTokenPricesUseCase, resolveTokenByContractUseCase) {
        this.getTokenByIdUseCase = getTokenByIdUseCase;
        this.getTokenBySymbolUseCase = getTokenBySymbolUseCase;
        this.getTokensByNetworkUseCase = getTokensByNetworkUseCase;
        this.getAllTokensUseCase = getAllTokensUseCase;
        this.getTokenChartUseCase = getTokenChartUseCase;
        this.getTokenPricesUseCase = getTokenPricesUseCase;
        this.resolveTokenByContractUseCase = resolveTokenByContractUseCase;
    }
    getById = async (req, res, next) => {
        try {
            const token = await this.getTokenByIdUseCase.execute(req.params.id);
            res.status(200).json({ success: true, data: token });
        }
        catch (error) {
            next(error);
        }
    };
    getBySymbol = async (req, res, next) => {
        try {
            const token = await this.getTokenBySymbolUseCase.execute(req.params.symbol);
            res.status(200).json({ success: true, data: token });
        }
        catch (error) {
            next(error);
        }
    };
    getByNetwork = async (req, res, next) => {
        try {
            const tokens = await this.getTokensByNetworkUseCase.execute(req.params.networkId);
            res.status(200).json({ success: true, data: tokens });
        }
        catch (error) {
            next(error);
        }
    };
    getAll = async (req, res, next) => {
        try {
            const tokens = await this.getAllTokensUseCase.execute(req.query);
            res.status(200).json({ success: true, data: tokens });
        }
        catch (error) {
            next(error);
        }
    };
    getChart = async (req, res, next) => {
        try {
            const points = await this.getTokenChartUseCase.execute({
                tokenId: req.params.id,
                timeframe: req.query.timeframe ?? '1D',
            });
            res.status(200).json({ success: true, data: points });
        }
        catch (error) {
            next(error);
        }
    };
    getPrices = async (req, res, next) => {
        try {
            const input = req.query;
            const symbols = input.symbols.split(',').map(s => s.trim()).filter(Boolean);
            const prices = await this.getTokenPricesUseCase.execute(symbols);
            res.status(200).json({ success: true, data: prices });
        }
        catch (error) {
            next(error);
        }
    };
    lookupByContract = async (req, res, next) => {
        try {
            const result = await this.resolveTokenByContractUseCase.execute(req.body);
            res.status(200).json({ success: true, data: result });
        }
        catch (error) {
            next(error);
        }
    };
}
exports.TokenController = TokenController;
//# sourceMappingURL=token.controller.js.map