"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.HubDocumentManager = exports.GetHubDocumentBlocksV2025R0Headers = exports.GetHubDocumentPagesV2025R0Headers = exports.GetHubDocumentBlocksV2025R0Optionals = exports.GetHubDocumentPagesV2025R0Optionals = void 0;
const hubDocumentPagesV2025R0_1 = require("../schemas/v2025R0/hubDocumentPagesV2025R0.js");
const hubDocumentBlocksV2025R0_1 = require("../schemas/v2025R0/hubDocumentBlocksV2025R0.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 GetHubDocumentPagesV2025R0Optionals {
    constructor(fields) {
        this.headers = new GetHubDocumentPagesV2025R0Headers({});
        this.cancellationToken = void 0;
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetHubDocumentPagesV2025R0Optionals = GetHubDocumentPagesV2025R0Optionals;
class GetHubDocumentBlocksV2025R0Optionals {
    constructor(fields) {
        this.headers = new GetHubDocumentBlocksV2025R0Headers({});
        this.cancellationToken = void 0;
        if (fields.headers !== undefined) {
            this.headers = fields.headers;
        }
        if (fields.cancellationToken !== undefined) {
            this.cancellationToken = fields.cancellationToken;
        }
    }
}
exports.GetHubDocumentBlocksV2025R0Optionals = GetHubDocumentBlocksV2025R0Optionals;
class GetHubDocumentPagesV2025R0Headers {
    constructor(fields) {
        /**
         * Version header. */
        this.boxVersion = '2025.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.GetHubDocumentPagesV2025R0Headers = GetHubDocumentPagesV2025R0Headers;
class GetHubDocumentBlocksV2025R0Headers {
    constructor(fields) {
        /**
         * Version header. */
        this.boxVersion = '2025.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.GetHubDocumentBlocksV2025R0Headers = GetHubDocumentBlocksV2025R0Headers;
class HubDocumentManager {
    constructor(fields) {
        this.networkSession = new network_1.NetworkSession({});
        if (fields.auth !== undefined) {
            this.auth = fields.auth;
        }
        if (fields.networkSession !== undefined) {
            this.networkSession = fields.networkSession;
        }
    }
    /**
     * Retrieves a list of Hub Document Pages for the specified hub.
     * Includes both root-level pages and sub pages.
     * @param {GetHubDocumentPagesV2025R0QueryParams} queryParams Query parameters of getHubDocumentPagesV2025R0 method
     * @param {GetHubDocumentPagesV2025R0OptionalsInput} optionalsInput
     * @returns {Promise<HubDocumentPagesV2025R0>}
     */
    getHubDocumentPagesV2025R0(queryParams_1) {
        return __awaiter(this, arguments, void 0, function* (queryParams, optionalsInput = {}) {
            const optionals = new GetHubDocumentPagesV2025R0Optionals({
                headers: optionalsInput.headers,
                cancellationToken: optionalsInput.cancellationToken,
            });
            const headers = optionals.headers;
            const cancellationToken = optionals.cancellationToken;
            const queryParamsMap = (0, utils_1.prepareParams)({
                ['hub_id']: (0, utils_2.toString)(queryParams.hubId),
                ['marker']: (0, utils_2.toString)(queryParams.marker),
                ['limit']: (0, utils_2.toString)(queryParams.limit),
            });
            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/hub_document_pages'),
                method: 'GET',
                params: queryParamsMap,
                headers: headersMap,
                responseFormat: 'json',
                auth: this.auth,
                networkSession: this.networkSession,
                cancellationToken: cancellationToken,
            }));
            return Object.assign(Object.assign({}, (0, hubDocumentPagesV2025R0_1.deserializeHubDocumentPagesV2025R0)(response.data)), { rawData: response.data });
        });
    }
    /**
     * Retrieves a sorted list of all Hub Document Blocks on a specified page in the hub document, excluding items.
     * Blocks are hierarchically organized by their `parent_id`.
     * Blocks are sorted in order based on user specification in the user interface.
     * The response will only include content blocks that belong to the specified page. This will not include sub pages or sub page content blocks.
     * @param {GetHubDocumentBlocksV2025R0QueryParams} queryParams Query parameters of getHubDocumentBlocksV2025R0 method
     * @param {GetHubDocumentBlocksV2025R0OptionalsInput} optionalsInput
     * @returns {Promise<HubDocumentBlocksV2025R0>}
     */
    getHubDocumentBlocksV2025R0(queryParams_1) {
        return __awaiter(this, arguments, void 0, function* (queryParams, optionalsInput = {}) {
            const optionals = new GetHubDocumentBlocksV2025R0Optionals({
                headers: optionalsInput.headers,
                cancellationToken: optionalsInput.cancellationToken,
            });
            const headers = optionals.headers;
            const cancellationToken = optionals.cancellationToken;
            const queryParamsMap = (0, utils_1.prepareParams)({
                ['hub_id']: (0, utils_2.toString)(queryParams.hubId),
                ['page_id']: (0, utils_2.toString)(queryParams.pageId),
                ['marker']: (0, utils_2.toString)(queryParams.marker),
                ['limit']: (0, utils_2.toString)(queryParams.limit),
            });
            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/hub_document_blocks'),
                method: 'GET',
                params: queryParamsMap,
                headers: headersMap,
                responseFormat: 'json',
                auth: this.auth,
                networkSession: this.networkSession,
                cancellationToken: cancellationToken,
            }));
            return Object.assign(Object.assign({}, (0, hubDocumentBlocksV2025R0_1.deserializeHubDocumentBlocksV2025R0)(response.data)), { rawData: response.data });
        });
    }
}
exports.HubDocumentManager = HubDocumentManager;
//# sourceMappingURL=hubDocument.js.map