"use strict";
Object.defineProperty(exports, "__esModule", {
    value: true
});
function _export(target, all) {
    for(var name in all)Object.defineProperty(target, name, {
        enumerable: true,
        get: all[name]
    });
}
_export(exports, {
    BatchCallController: function() {
        return BatchCallController;
    },
    default: function() {
        return _default;
    }
});
const _awilixexpress = require("awilix-express");
const _validators = require("../handlers/validators");
const _batchcontrollervalidation = require("./validation/batch-controller.validation");
const _serverconstants = require("../server.constants");
const _authenticate = require("../middleware/authenticate");
const _authorizationconstants = require("../constants/authorization.constants");
class BatchCallController {
    batchCallService;
    isTypeormMode;
    constructor({ batchCallService, isTypeormMode }){
        this.batchCallService = batchCallService;
        this.isTypeormMode = isTypeormMode;
    }
    async batchSettingsGet(req, res) {
        const { printerIds } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrinterRules)(this.isTypeormMode));
        const results = await this.batchCallService.batchSettingsGet(printerIds);
        res.send(results);
    }
    async batchConnectUsb(req, res) {
        const { printerIds } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrinterRules)(this.isTypeormMode));
        const results = await this.batchCallService.batchConnectUsb(printerIds);
        res.send(results);
    }
    async batchConnectSocket(req, res) {
        const { printerIds } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrinterRules)(this.isTypeormMode));
        this.batchCallService.batchConnectSocket(printerIds);
        res.send({});
    }
    async getLastPrintedFiles(req, res) {
        const { printerIds } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrinterRules)(this.isTypeormMode));
        const files = await this.batchCallService.getBatchPrinterReprintFile(printerIds);
        res.send(files);
    }
    async batchReprintFiles(req, res) {
        const { prints } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.executeBatchRePrinterRule)(this.isTypeormMode));
        const files = await this.batchCallService.batchReprintCalls(prints);
        res.send(files);
    }
    async batchTogglePrintersEnabled(req, res) {
        const { printerIds, enabled } = await (0, _validators.validateInput)(req.body, (0, _batchcontrollervalidation.batchPrintersEnabledRules)(this.isTypeormMode));
        const results = await this.batchCallService.batchTogglePrintersEnabled(printerIds, enabled);
        res.send(results);
    }
}
const _default = (0, _awilixexpress.createController)(BatchCallController).prefix(_serverconstants.AppConstants.apiRoute + "/batch").before([
    (0, _authenticate.authenticate)(),
    (0, _authenticate.authorizeRoles)([
        _authorizationconstants.ROLES.ADMIN,
        _authorizationconstants.ROLES.OPERATOR
    ])
]).post("/settings/get", "batchSettingsGet").post("/connect/usb", "batchConnectUsb").post("/connect/socket", "batchConnectSocket").post("/reprint/list", "getLastPrintedFiles").post("/reprint/execute", "batchReprintFiles").post("/toggle-enabled", "batchTogglePrintersEnabled");

//# sourceMappingURL=batch-call.controller.js.map