"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AutomateWorkflowsManager = exports.CreateAutomateWorkflowStartV2026R0Headers = exports.GetAutomateWorkflowsV2026R0Headers = exports.CreateAutomateWorkflowStartV2026R0Optionals = exports.GetAutomateWorkflowsV2026R0Optionals = void 0;
const automateWorkflowsV2026R0_1 = require("../schemas/v2026R0/automateWorkflowsV2026R0.js");
const automateWorkflowStartRequestV2026R0_1 = require("../schemas/v2026R0/automateWorkflowStartRequestV2026R0.js");
const network_1 = require("../networking/network.js");
const fetchOptions_1 = require("../networking/fetchOptions.js");
const utils_1 = require("../internal/utils.js");
const utils_2 = require("../internal/utils.js");
class GetAutomateWorkflowsV2026R0Optionals {
    constructor(fields) {
        this.headers = new GetAutomateWorkflowsV2026R0Headers({});
        this.cancellationToken = void 0;
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetAutomateWorkflowsV2026R0Optionals = GetAutomateWorkflowsV2026R0Optionals;
class CreateAutomateWorkflowStartV2026R0Optionals {
    constructor(fields) {
        this.headers = new CreateAutomateWorkflowStartV2026R0Headers({});
        this.cancellationToken = void 0;
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.CreateAutomateWorkflowStartV2026R0Optionals = CreateAutomateWorkflowStartV2026R0Optionals;
class GetAutomateWorkflowsV2026R0Headers {
    constructor(fields) {
        /**
         * Version header. */
        this.boxVersion = '2026.0';
        /**
         * Extra headers that will be included in the HTTP request. */
        this.extraHeaders = {};
        if (fields.boxVersion !== undefined) {
            this.boxVersion = fields.boxVersion;
        }
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetAutomateWorkflowsV2026R0Headers = GetAutomateWorkflowsV2026R0Headers;
class CreateAutomateWorkflowStartV2026R0Headers {
    constructor(fields) {
        /**
         * Version header. */
        this.boxVersion = '2026.0';
        /**
         * Extra headers that will be included in the HTTP request. */
        this.extraHeaders = {};
        if (fields.boxVersion !== undefined) {
            this.boxVersion = fields.boxVersion;
        }
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.CreateAutomateWorkflowStartV2026R0Headers = CreateAutomateWorkflowStartV2026R0Headers;
class AutomateWorkflowsManager {
    constructor(fields) {
        this.networkSession = new network_1.NetworkSession({});
        if (fields.auth !== undefined) {
            this.auth = fields.auth;
        }
        if (fields.networkSession !== undefined) {
            this.networkSession = fields.networkSession;
        }
    }
    /**
     * Returns workflow actions from Automate for a folder, using the
     * `WORKFLOW` action category.
     * @param {GetAutomateWorkflowsV2026R0QueryParams} queryParams Query parameters of getAutomateWorkflowsV2026R0 method
     * @param {GetAutomateWorkflowsV2026R0OptionalsInput} optionalsInput
     * @returns {Promise<AutomateWorkflowsV2026R0>}
     */
    getAutomateWorkflowsV2026R0(queryParams_1) {
        return __awaiter(this, arguments, void 0, function* (queryParams, optionalsInput = {}) {
            const optionals = new GetAutomateWorkflowsV2026R0Optionals({
                headers: optionalsInput.headers,
                cancellationToken: optionalsInput.cancellationToken,
            });
            const headers = optionals.headers;
            const cancellationToken = optionals.cancellationToken;
            const queryParamsMap = (0, utils_1.prepareParams)({
                ['folder_id']: (0, utils_2.toString)(queryParams.folderId),
                ['limit']: (0, utils_2.toString)(queryParams.limit),
                ['marker']: (0, utils_2.toString)(queryParams.marker),
            });
            const headersMap = (0, utils_1.prepareParams)(Object.assign({ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, headers.extraHeaders));
            const response = yield this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
                url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/automate_workflows'),
                method: 'GET',
                params: queryParamsMap,
                headers: headersMap,
                responseFormat: 'json',
                auth: this.auth,
                networkSession: this.networkSession,
                cancellationToken: cancellationToken,
            }));
            return Object.assign(Object.assign({}, (0, automateWorkflowsV2026R0_1.deserializeAutomateWorkflowsV2026R0)(response.data)), { rawData: response.data });
        });
    }
    /**
       * Starts an Automate workflow manually by using a workflow action ID and file IDs.
       * @param {string} workflowId The ID of the workflow.
      Example: "12345"
       * @param {AutomateWorkflowStartRequestV2026R0} requestBody Request body of createAutomateWorkflowStartV2026R0 method
       * @param {CreateAutomateWorkflowStartV2026R0OptionalsInput} optionalsInput
       * @returns {Promise<undefined>}
       */
    createAutomateWorkflowStartV2026R0(workflowId_1, requestBody_1) {
        return __awaiter(this, arguments, void 0, function* (workflowId, requestBody, optionalsInput = {}) {
            const optionals = new CreateAutomateWorkflowStartV2026R0Optionals({
                headers: optionalsInput.headers,
                cancellationToken: optionalsInput.cancellationToken,
            });
            const headers = optionals.headers;
            const cancellationToken = optionals.cancellationToken;
            const headersMap = (0, utils_1.prepareParams)(Object.assign({ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, headers.extraHeaders));
            const response = yield this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
                url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/automate_workflows/', (0, utils_2.toString)(workflowId), '/start'),
                method: 'POST',
                headers: headersMap,
                data: (0, automateWorkflowStartRequestV2026R0_1.serializeAutomateWorkflowStartRequestV2026R0)(requestBody),
                contentType: 'application/json',
                responseFormat: 'no_content',
                auth: this.auth,
                networkSession: this.networkSession,
                cancellationToken: cancellationToken,
            }));
            return void 0;
        });
    }
}
exports.AutomateWorkflowsManager = AutomateWorkflowsManager;
//# sourceMappingURL=automateWorkflows.js.map