"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.CheckForNewEventsTask = void 0;
const models_1 = require("../../models");
const integration_engine_1 = require("@golemio/core/dist/integration-engine");
const RopidVYMIApiHelper_1 = __importDefault(require("./helpers/RopidVYMIApiHelper"));
class CheckForNewEventsTask extends integration_engine_1.AbstractEmptyTask {
    constructor(queuePrefix) {
        super(queuePrefix);
        this.queueName = "checkForNewEvents";
        this.queueTtl = 1 * 60 * 1000; // 1 minute;
        this.modelVYMIMeta = new models_1.RopidVYMIMetadataModel();
    }
    async execute() {
        const lastDigest = await this.modelVYMIMeta.getDigest(models_1.DatasetEnum.EVENTS);
        const { digest, data } = await RopidVYMIApiHelper_1.default.getInstance().getAllEvents();
        if (digest !== lastDigest) {
            await integration_engine_1.QueueManager.sendMessageToExchange(this.queuePrefix, "fetchAndProcessEvents", { digest, data });
        }
    }
}
exports.CheckForNewEventsTask = CheckForNewEventsTask;
//# sourceMappingURL=CheckForNewEventsTask.js.map