"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.createScheduleJob = void 0;
const logger_1 = __importDefault(require("../../../logger"));
const scheduleJobsService_1 = require("../../services/scheduleJobsService");
const createScheduleJob = async (req, res) => {
    try {
        const { name, type, projectId, orgId, applicationId, libraryId, securityConfigId, startDate, runTime, timeZone, repeatEvery, repeatUnit, repeatOnDays, endsOn, endsDate, endsAfter, } = req.body;
        if (!type || !projectId || !startDate || !repeatEvery || !repeatUnit) {
            res.status(400).json({
                success: false,
                message: 'Missing required fields: type, projectId, startDate, repeatEvery, repeatUnit',
            });
            return;
        }
        const scheduleJob = await scheduleJobsService_1.scheduleJobsService.createScheduleJob({
            name,
            type,
            projectId,
            workspaceId: orgId,
            applicationId,
            libraryId,
            securityConfigId,
            startDate,
            runTime,
            timeZone,
            repeatEvery,
            repeatUnit,
            repeatOnDays,
            endsOn,
            endsDate,
            endsAfter,
        });
        res.json({
            success: true,
            data: scheduleJob,
        });
    }
    catch (error) {
        logger_1.default.error(`Error creating schedule job: ${error}`);
        res.status(500).json({
            success: false,
            message: 'Failed to create schedule job',
            error: error.message,
        });
    }
};
exports.createScheduleJob = createScheduleJob;
//# sourceMappingURL=create-schedule-job.js.map