UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

154 lines 6.3 kB
import { deserializeHubDocumentPagesV2025R0 } from '../schemas/v2025R0/hubDocumentPagesV2025R0.js'; import { deserializeHubDocumentBlocksV2025R0 } from '../schemas/v2025R0/hubDocumentBlocksV2025R0.js'; import { NetworkSession } from '../networking/network.js'; import { FetchOptions } from '../networking/fetchOptions.js'; import { prepareParams } from '../internal/utils.js'; import { toString } from '../internal/utils.js'; export class GetHubDocumentPagesV2025R0Optionals { headers = new GetHubDocumentPagesV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } export class GetHubDocumentBlocksV2025R0Optionals { headers = new GetHubDocumentBlocksV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } export class GetHubDocumentPagesV2025R0Headers { /** * Version header. */ boxVersion = '2025.0'; /** * Extra headers that will be included in the HTTP request. */ extraHeaders = {}; constructor(fields) { if (fields.boxVersion !== undefined) { this.boxVersion = fields.boxVersion; } if (fields.extraHeaders !== undefined) { this.extraHeaders = fields.extraHeaders; } } } export class GetHubDocumentBlocksV2025R0Headers { /** * Version header. */ boxVersion = '2025.0'; /** * Extra headers that will be included in the HTTP request. */ extraHeaders = {}; constructor(fields) { if (fields.boxVersion !== undefined) { this.boxVersion = fields.boxVersion; } if (fields.extraHeaders !== undefined) { this.extraHeaders = fields.extraHeaders; } } } export class HubDocumentManager { auth; networkSession = new NetworkSession({}); constructor(fields) { 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>} */ async getHubDocumentPagesV2025R0(queryParams, optionalsInput = {}) { const optionals = new GetHubDocumentPagesV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const queryParamsMap = prepareParams({ ['hub_id']: toString(queryParams.hubId), ['marker']: toString(queryParams.marker), ['limit']: toString(queryParams.limit), }); const headersMap = prepareParams({ ...{ ['box-version']: toString(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new 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 { ...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>} */ async getHubDocumentBlocksV2025R0(queryParams, optionalsInput = {}) { const optionals = new GetHubDocumentBlocksV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const queryParamsMap = prepareParams({ ['hub_id']: toString(queryParams.hubId), ['page_id']: toString(queryParams.pageId), ['marker']: toString(queryParams.marker), ['limit']: toString(queryParams.limit), }); const headersMap = prepareParams({ ...{ ['box-version']: toString(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new 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 { ...deserializeHubDocumentBlocksV2025R0(response.data), rawData: response.data, }; } } //# sourceMappingURL=hubDocument.js.map