"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.IncidentForwarder = void 0;
const cross_fetch_1 = __importDefault(require("cross-fetch"));
class IncidentForwarder {
    constructor(incidentEndpoint, passphrase) {
        this.incidentEndpoint = incidentEndpoint;
        this.passphrase = passphrase;
    }
    async dispatch(job, incident) {
        try {
            (0, cross_fetch_1.default)(this.incidentEndpoint, {
                method: "POST",
                body: JSON.stringify({
                    type: "incident",
                    job,
                    incident,
                }),
                headers: {
                    "Content-Type": "application/json",
                    Authorization: `Bearer ${this.passphrase}`,
                },
            });
        }
        catch (error) {
            console.error("Incident receiver is down: ", error);
        }
    }
}
exports.IncidentForwarder = IncidentForwarder;
//# sourceMappingURL=incident-forwarder.js.map