"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RopidGtfsController = void 0;
const ropid_departures_presets_1 = require("../../schema-definitions/ropid-departures-presets");
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 RopidGtfsController extends controllers_1.BaseController {
    constructor() {
        super("RopidPresets", new golemio_validator_1.JSONSchemaValidator(ropid_departures_presets_1.RopidDeparturesPresets.name + "Controller", ropid_departures_presets_1.RopidDeparturesPresets.datasourceJsonSchema));
        this.processData = async (inputData) => {
            try {
                await this.validator.Validate(inputData);
                await this.sendMessageToExchange("input." + this.queuePrefix + ".savePresets", JSON.stringify(inputData), {
                    persistent: true,
                });
            }
            catch (err) {
                if (err instanceof golemio_errors_1.CustomError) {
                    throw err;
                }
                else {
                    throw new golemio_errors_1.CustomError("Error while validating input data.", true, this.name, 422, err);
                }
            }
        };
    }
}
exports.RopidGtfsController = RopidGtfsController;
//# sourceMappingURL=RopidGtfsController.js.map