UNPKG

box-node-sdk

Version:

Official SDK for Box Platform APIs

344 lines 15.2 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HubCollaborationsManager = exports.DeleteHubCollaborationByIdV2025R0Headers = exports.UpdateHubCollaborationByIdV2025R0Headers = exports.GetHubCollaborationByIdV2025R0Headers = exports.CreateHubCollaborationV2025R0Headers = exports.GetHubCollaborationsV2025R0Headers = exports.DeleteHubCollaborationByIdV2025R0Optionals = exports.UpdateHubCollaborationByIdV2025R0Optionals = exports.GetHubCollaborationByIdV2025R0Optionals = exports.CreateHubCollaborationV2025R0Optionals = exports.GetHubCollaborationsV2025R0Optionals = void 0; const hubCollaborationsV2025R0_1 = require("../schemas/v2025R0/hubCollaborationsV2025R0"); const hubCollaborationV2025R0_1 = require("../schemas/v2025R0/hubCollaborationV2025R0"); const hubCollaborationCreateRequestV2025R0_1 = require("../schemas/v2025R0/hubCollaborationCreateRequestV2025R0"); const hubCollaborationUpdateRequestV2025R0_1 = require("../schemas/v2025R0/hubCollaborationUpdateRequestV2025R0"); const network_1 = require("../networking/network"); const fetchOptions_1 = require("../networking/fetchOptions"); const utils_1 = require("../internal/utils"); const utils_2 = require("../internal/utils"); class GetHubCollaborationsV2025R0Optionals { headers = new GetHubCollaborationsV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.GetHubCollaborationsV2025R0Optionals = GetHubCollaborationsV2025R0Optionals; class CreateHubCollaborationV2025R0Optionals { headers = new CreateHubCollaborationV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.CreateHubCollaborationV2025R0Optionals = CreateHubCollaborationV2025R0Optionals; class GetHubCollaborationByIdV2025R0Optionals { headers = new GetHubCollaborationByIdV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.GetHubCollaborationByIdV2025R0Optionals = GetHubCollaborationByIdV2025R0Optionals; class UpdateHubCollaborationByIdV2025R0Optionals { headers = new UpdateHubCollaborationByIdV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.UpdateHubCollaborationByIdV2025R0Optionals = UpdateHubCollaborationByIdV2025R0Optionals; class DeleteHubCollaborationByIdV2025R0Optionals { headers = new DeleteHubCollaborationByIdV2025R0Headers({}); cancellationToken = void 0; constructor(fields) { if (fields.headers !== undefined) { this.headers = fields.headers; } if (fields.cancellationToken !== undefined) { this.cancellationToken = fields.cancellationToken; } } } exports.DeleteHubCollaborationByIdV2025R0Optionals = DeleteHubCollaborationByIdV2025R0Optionals; class GetHubCollaborationsV2025R0Headers { /** * 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; } } } exports.GetHubCollaborationsV2025R0Headers = GetHubCollaborationsV2025R0Headers; class CreateHubCollaborationV2025R0Headers { /** * 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; } } } exports.CreateHubCollaborationV2025R0Headers = CreateHubCollaborationV2025R0Headers; class GetHubCollaborationByIdV2025R0Headers { /** * 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; } } } exports.GetHubCollaborationByIdV2025R0Headers = GetHubCollaborationByIdV2025R0Headers; class UpdateHubCollaborationByIdV2025R0Headers { /** * 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; } } } exports.UpdateHubCollaborationByIdV2025R0Headers = UpdateHubCollaborationByIdV2025R0Headers; class DeleteHubCollaborationByIdV2025R0Headers { /** * 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; } } } exports.DeleteHubCollaborationByIdV2025R0Headers = DeleteHubCollaborationByIdV2025R0Headers; class HubCollaborationsManager { 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 collaborations for a Box Hub. * @param {GetHubCollaborationsV2025R0QueryParams} queryParams Query parameters of getHubCollaborationsV2025R0 method * @param {GetHubCollaborationsV2025R0OptionalsInput} optionalsInput * @returns {Promise<HubCollaborationsV2025R0>} */ async getHubCollaborationsV2025R0(queryParams, optionalsInput = {}) { const optionals = new GetHubCollaborationsV2025R0Optionals({ 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)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/hub_collaborations'), method: 'GET', params: queryParamsMap, headers: headersMap, responseFormat: 'json', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return { ...(0, hubCollaborationsV2025R0_1.deserializeHubCollaborationsV2025R0)(response.data), rawData: response.data, }; } /** * Adds a collaboration for a single user or a single group to a Box Hub. * * Collaborations can be created using email address, user IDs, or group IDs. * @param {HubCollaborationCreateRequestV2025R0} requestBody Request body of createHubCollaborationV2025R0 method * @param {CreateHubCollaborationV2025R0OptionalsInput} optionalsInput * @returns {Promise<HubCollaborationV2025R0>} */ async createHubCollaborationV2025R0(requestBody, optionalsInput = {}) { const optionals = new CreateHubCollaborationV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/hub_collaborations'), method: 'POST', headers: headersMap, data: (0, hubCollaborationCreateRequestV2025R0_1.serializeHubCollaborationCreateRequestV2025R0)(requestBody), contentType: 'application/json', responseFormat: 'json', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return { ...(0, hubCollaborationV2025R0_1.deserializeHubCollaborationV2025R0)(response.data), rawData: response.data, }; } /** * Retrieves details for a Box Hub collaboration by collaboration ID. * @param {string} hubCollaborationId The ID of the hub collaboration. Example: "1234" * @param {GetHubCollaborationByIdV2025R0OptionalsInput} optionalsInput * @returns {Promise<HubCollaborationV2025R0>} */ async getHubCollaborationByIdV2025R0(hubCollaborationId, optionalsInput = {}) { const optionals = new GetHubCollaborationByIdV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/hub_collaborations/', (0, utils_2.toString)(hubCollaborationId)), method: 'GET', headers: headersMap, responseFormat: 'json', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return { ...(0, hubCollaborationV2025R0_1.deserializeHubCollaborationV2025R0)(response.data), rawData: response.data, }; } /** * Updates a Box Hub collaboration. * Can be used to change the Box Hub role. * @param {string} hubCollaborationId The ID of the hub collaboration. Example: "1234" * @param {HubCollaborationUpdateRequestV2025R0} requestBody Request body of updateHubCollaborationByIdV2025R0 method * @param {UpdateHubCollaborationByIdV2025R0OptionalsInput} optionalsInput * @returns {Promise<HubCollaborationV2025R0>} */ async updateHubCollaborationByIdV2025R0(hubCollaborationId, requestBody, optionalsInput = {}) { const optionals = new UpdateHubCollaborationByIdV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/hub_collaborations/', (0, utils_2.toString)(hubCollaborationId)), method: 'PUT', headers: headersMap, data: (0, hubCollaborationUpdateRequestV2025R0_1.serializeHubCollaborationUpdateRequestV2025R0)(requestBody), contentType: 'application/json', responseFormat: 'json', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return { ...(0, hubCollaborationV2025R0_1.deserializeHubCollaborationV2025R0)(response.data), rawData: response.data, }; } /** * Deletes a single Box Hub collaboration. * @param {string} hubCollaborationId The ID of the hub collaboration. Example: "1234" * @param {DeleteHubCollaborationByIdV2025R0OptionalsInput} optionalsInput * @returns {Promise<undefined>} */ async deleteHubCollaborationByIdV2025R0(hubCollaborationId, optionalsInput = {}) { const optionals = new DeleteHubCollaborationByIdV2025R0Optionals({ headers: optionalsInput.headers, cancellationToken: optionalsInput.cancellationToken, }); const headers = optionals.headers; const cancellationToken = optionals.cancellationToken; const headersMap = (0, utils_1.prepareParams)({ ...{ ['box-version']: (0, utils_2.toString)(headers.boxVersion) }, ...headers.extraHeaders, }); const response = await this.networkSession.networkClient.fetch(new fetchOptions_1.FetchOptions({ url: ''.concat(this.networkSession.baseUrls.baseUrl, '/2.0/hub_collaborations/', (0, utils_2.toString)(hubCollaborationId)), method: 'DELETE', headers: headersMap, responseFormat: 'no_content', auth: this.auth, networkSession: this.networkSession, cancellationToken: cancellationToken, })); return void 0; } } exports.HubCollaborationsManager = HubCollaborationsManager; //# sourceMappingURL=hubCollaborations.js.map