"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionController = void 0;
class TransactionController {
    createTransactionUseCase;
    getTransactionsUseCase;
    getTransactionByIdUseCase;
    updateTransactionUseCase;
    transactionRateUseCase;
    constructor(createTransactionUseCase, getTransactionsUseCase, getTransactionByIdUseCase, updateTransactionUseCase, transactionRateUseCase) {
        this.createTransactionUseCase = createTransactionUseCase;
        this.getTransactionsUseCase = getTransactionsUseCase;
        this.getTransactionByIdUseCase = getTransactionByIdUseCase;
        this.updateTransactionUseCase = updateTransactionUseCase;
        this.transactionRateUseCase = transactionRateUseCase;
    }
    create = async (req, res, next) => {
        try {
            const transaction = await this.createTransactionUseCase.execute(req.body);
            res.status(201).json({ success: true, data: transaction });
        }
        catch (error) {
            next(error);
        }
    };
    getAll = async (req, res, next) => {
        try {
            const transactions = await this.getTransactionsUseCase.execute(req.query);
            res.status(200).json({ success: true, data: transactions });
        }
        catch (error) {
            next(error);
        }
    };
    getById = async (req, res, next) => {
        try {
            const transaction = await this.getTransactionByIdUseCase.execute(req.params.id);
            res.status(200).json({ success: true, data: transaction });
        }
        catch (error) {
            next(error);
        }
    };
    update = async (req, res, next) => {
        try {
            const transaction = await this.updateTransactionUseCase.execute(req.params.id, req.body);
            res.status(200).json({ success: true, data: transaction });
        }
        catch (error) {
            next(error);
        }
    };
    rate = async (req, res, next) => {
        try {
            const rate = await this.transactionRateUseCase.execute(req.body);
            res.status(200).json({ success: true, data: rate });
        }
        catch (error) {
            next(error);
        }
    };
}
exports.TransactionController = TransactionController;
//# sourceMappingURL=transaction.controller.js.map