"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JISInfotextsController = void 0;
const JISInfotextsJsonSchema_1 = require("../../../schema-definitions/jis/datasources/JISInfotextsJsonSchema");
const controllers_1 = require("@golemio/core/dist/input-gateway/controllers");
const golemio_errors_1 = require("@golemio/core/dist/shared/golemio-errors");
const golemio_validator_1 = require("@golemio/core/dist/shared/golemio-validator");
class JISInfotextsController extends controllers_1.BaseController {
    constructor() {
        super("jis", new golemio_validator_1.JSONSchemaValidator("JISInfotextsDataValidation", JISInfotextsJsonSchema_1.jisInfotextsJsonSchema));
        this.processData = async (inputData) => {
            try {
                await this.validator.Validate(inputData);
                await this.sendMessageToExchange("input." + this.queuePrefix + ".refreshJISInfotexts", JSON.stringify(inputData));
            }
            catch (err) {
                if (err instanceof golemio_errors_1.AbstractGolemioError) {
                    throw err;
                }
                else {
                    throw new golemio_errors_1.GeneralError("Error while validating input data.", this.constructor.name, err, 422);
                }
            }
        };
        this.name = "JISInfotextsController";
    }
}
exports.JISInfotextsController = JISInfotextsController;
//# sourceMappingURL=JISInfotextsController.js.map