"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileVersionRetentionsManager = exports.GetFileVersionRetentionByIdHeaders = exports.GetFileVersionRetentionsHeaders = exports.GetFileVersionRetentionByIdOptionals = void 0;
exports.serializeGetFileVersionRetentionsQueryParamsDispositionActionField = serializeGetFileVersionRetentionsQueryParamsDispositionActionField;
exports.deserializeGetFileVersionRetentionsQueryParamsDispositionActionField = deserializeGetFileVersionRetentionsQueryParamsDispositionActionField;
const fileVersionRetentions_1 = require("../schemas/fileVersionRetentions");
const fileVersionRetention_1 = require("../schemas/fileVersionRetention");
const errors_1 = require("../box/errors");
const network_1 = require("../networking/network");
const fetchOptions_1 = require("../networking/fetchOptions");
const utils_1 = require("../internal/utils");
const utils_2 = require("../internal/utils");
const json_1 = require("../serialization/json");
class GetFileVersionRetentionByIdOptionals {
    headers = new GetFileVersionRetentionByIdHeaders({});
    cancellationToken = void 0;
    constructor(fields) {
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetFileVersionRetentionByIdOptionals = GetFileVersionRetentionByIdOptionals;
class GetFileVersionRetentionsHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetFileVersionRetentionsHeaders = GetFileVersionRetentionsHeaders;
class GetFileVersionRetentionByIdHeaders {
    /**
     * Extra headers that will be included in the HTTP request. */
    extraHeaders = {};
    constructor(fields) {
        if (fields.extraHeaders !== undefined) {
            this.extraHeaders = fields.extraHeaders;
        }
    }
}
exports.GetFileVersionRetentionByIdHeaders = GetFileVersionRetentionByIdHeaders;
class FileVersionRetentionsManager {
    auth;
    networkSession = new network_1.NetworkSession({});
    constructor(fields) {
        if (fields.auth !== undefined) {
            this.auth = fields.auth;
        }
        if (fields.networkSession !== undefined) {
            this.networkSession = fields.networkSession;
        }
    }
    /**
     * Retrieves all file version retentions for the given enterprise.
     *
     * **Note**:
     * File retention API is now **deprecated**.
     * To get information about files and file versions under retention,
     * see [files under retention](https://developer.box.com/reference/get-retention-policy-assignments-id-files-under-retention) or [file versions under retention](https://developer.box.com/reference/get-retention-policy-assignments-id-file-versions-under-retention) endpoints.
     * @param {GetFileVersionRetentionsQueryParams} queryParams Query parameters of getFileVersionRetentions method
     * @param {GetFileVersionRetentionsHeadersInput} headersInput Headers of getFileVersionRetentions method
     * @param {CancellationToken} cancellationToken Token used for request cancellation.
     * @returns {Promise<FileVersionRetentions>}
     */
    async getFileVersionRetentions(queryParams = {}, headersInput = new GetFileVersionRetentionsHeaders({}), cancellationToken) {
        const headers = new GetFileVersionRetentionsHeaders({
            extraHeaders: headersInput.extraHeaders,
        });
        const queryParamsMap = (0, utils_1.prepareParams)({
            ['file_id']: (0, utils_2.toString)(queryParams.fileId),
            ['file_version_id']: (0, utils_2.toString)(queryParams.fileVersionId),
            ['policy_id']: (0, utils_2.toString)(queryParams.policyId),
            ['disposition_action']: (0, utils_2.toString)(queryParams.dispositionAction),
            ['disposition_before']: (0, utils_2.toString)(queryParams.dispositionBefore),
            ['disposition_after']: (0, utils_2.toString)(queryParams.dispositionAfter),
            ['limit']: (0, utils_2.toString)(queryParams.limit),
            ['marker']: (0, utils_2.toString)(queryParams.marker),
        });
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/file_version_retentions'),
            method: 'GET',
            params: queryParamsMap,
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, fileVersionRetentions_1.deserializeFileVersionRetentions)(response.data),
            rawData: response.data,
        };
    }
    /**
       * Returns information about a file version retention.
       *
       * **Note**:
       * File retention API is now **deprecated**.
       * To get information about files and file versions under retention,
       * see [files under retention](https://developer.box.com/reference/get-retention-policy-assignments-id-files-under-retention) or [file versions under retention](https://developer.box.com/reference/get-retention-policy-assignments-id-file-versions-under-retention) endpoints.
       * @param {string} fileVersionRetentionId The ID of the file version retention.
      Example: "3424234"
       * @param {GetFileVersionRetentionByIdOptionalsInput} optionalsInput
       * @returns {Promise<FileVersionRetention>}
       */
    async getFileVersionRetentionById(fileVersionRetentionId, optionalsInput = {}) {
        const optionals = new GetFileVersionRetentionByIdOptionals({
            headers: optionalsInput.headers,
            cancellationToken: optionalsInput.cancellationToken,
        });
        const headers = optionals.headers;
        const cancellationToken = optionals.cancellationToken;
        const headersMap = (0, utils_1.prepareParams)({ ...{}, ...headers.extraHeaders });
        const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({
            url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/file_version_retentions/', (0, utils_2.toString)(fileVersionRetentionId)),
            method: 'GET',
            headers: headersMap,
            responseFormat: 'json',
            auth: this.auth,
            networkSession: this.networkSession,
            cancellationToken: cancellationToken,
        }));
        return {
            ...(0, fileVersionRetention_1.deserializeFileVersionRetention)(response.data),
            rawData: response.data,
        };
    }
}
exports.FileVersionRetentionsManager = FileVersionRetentionsManager;
function serializeGetFileVersionRetentionsQueryParamsDispositionActionField(val) {
    return val;
}
function deserializeGetFileVersionRetentionsQueryParamsDispositionActionField(val) {
    if (val == 'permanently_delete') {
        return val;
    }
    if (val == 'remove_retention') {
        return val;
    }
    if ((0, json_1.sdIsString)(val)) {
        return val;
    }
    throw new errors_1.BoxSdkError({
        message: "Can't deserialize GetFileVersionRetentionsQueryParamsDispositionActionField",
    });
}
//# sourceMappingURL=fileVersionRetentions.js.map