box-node-sdk
Version:
Official SDK for Box Platform APIs
175 lines (172 loc) • 7.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AppItemAssociationsManager = exports.GetFolderAppItemAssociationsHeaders = exports.GetFileAppItemAssociationsHeaders = exports.GetFolderAppItemAssociationsOptionals = exports.GetFileAppItemAssociationsOptionals = void 0;
const appItemAssociations_1 = require("../schemas/appItemAssociations");
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 GetFileAppItemAssociationsOptionals {
queryParams = {};
headers = new GetFileAppItemAssociationsHeaders({});
cancellationToken = void 0;
constructor(fields) {
if (fields.queryParams !== undefined) {
this.queryParams = fields.queryParams;
}
if (fields.headers !== undefined) {
this.headers = fields.headers;
}
if (fields.cancellationToken !== undefined) {
this.cancellationToken = fields.cancellationToken;
}
}
}
exports.GetFileAppItemAssociationsOptionals = GetFileAppItemAssociationsOptionals;
class GetFolderAppItemAssociationsOptionals {
queryParams = {};
headers = new GetFolderAppItemAssociationsHeaders({});
cancellationToken = void 0;
constructor(fields) {
if (fields.queryParams !== undefined) {
this.queryParams = fields.queryParams;
}
if (fields.headers !== undefined) {
this.headers = fields.headers;
}
if (fields.cancellationToken !== undefined) {
this.cancellationToken = fields.cancellationToken;
}
}
}
exports.GetFolderAppItemAssociationsOptionals = GetFolderAppItemAssociationsOptionals;
class GetFileAppItemAssociationsHeaders {
/**
* Extra headers that will be included in the HTTP request. */
extraHeaders = {};
constructor(fields) {
if (fields.extraHeaders !== undefined) {
this.extraHeaders = fields.extraHeaders;
}
}
}
exports.GetFileAppItemAssociationsHeaders = GetFileAppItemAssociationsHeaders;
class GetFolderAppItemAssociationsHeaders {
/**
* Extra headers that will be included in the HTTP request. */
extraHeaders = {};
constructor(fields) {
if (fields.extraHeaders !== undefined) {
this.extraHeaders = fields.extraHeaders;
}
}
}
exports.GetFolderAppItemAssociationsHeaders = GetFolderAppItemAssociationsHeaders;
class AppItemAssociationsManager {
auth;
networkSession = new network_1.NetworkSession({});
constructor(fields) {
if (fields.auth !== undefined) {
this.auth = fields.auth;
}
if (fields.networkSession !== undefined) {
this.networkSession = fields.networkSession;
}
}
/**
* **This is a beta feature, which means that its availability might be limited.**
* Returns all app items the file is associated with. This includes app items
* associated with ancestors of the file. Assuming the context user has access
* to the file, the type/ids are revealed even if the context user does not
* have **View** permission on the app item.
* @param {string} fileId The unique identifier that represents a file.
The ID for any file can be determined
by visiting a file in the web application
and copying the ID from the URL. For example,
for the URL `https://*.app.box.com/files/123`
the `file_id` is `123`.
Example: "12345"
* @param {GetFileAppItemAssociationsOptionalsInput} optionalsInput
* @returns {Promise<AppItemAssociations>}
*/
async getFileAppItemAssociations(fileId, optionalsInput = {}) {
const optionals = new GetFileAppItemAssociationsOptionals({
queryParams: optionalsInput.queryParams,
headers: optionalsInput.headers,
cancellationToken: optionalsInput.cancellationToken,
});
const queryParams = optionals.queryParams;
const headers = optionals.headers;
const cancellationToken = optionals.cancellationToken;
const queryParamsMap = (0, utils_1.prepareParams)({
['limit']: (0, utils_2.toString)(queryParams.limit),
['marker']: (0, utils_2.toString)(queryParams.marker),
['application_type']: (0, utils_2.toString)(queryParams.applicationType),
});
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/files/', (0, utils_2.toString)(fileId), '/app_item_associations'),
method: 'GET',
params: queryParamsMap,
headers: headersMap,
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}));
return {
...(0, appItemAssociations_1.deserializeAppItemAssociations)(response.data),
rawData: response.data,
};
}
/**
* **This is a beta feature, which means that its availability might be limited.**
* Returns all app items the folder is associated with. This includes app items
* associated with ancestors of the folder. Assuming the context user has access
* to the folder, the type/ids are revealed even if the context user does not
* have **View** permission on the app item.
* @param {string} folderId The unique identifier that represent a folder.
The ID for any folder can be determined
by visiting this folder in the web application
and copying the ID from the URL. For example,
for the URL `https://*.app.box.com/folder/123`
the `folder_id` is `123`.
The root folder of a Box account is
always represented by the ID `0`.
Example: "12345"
* @param {GetFolderAppItemAssociationsOptionalsInput} optionalsInput
* @returns {Promise<AppItemAssociations>}
*/
async getFolderAppItemAssociations(folderId, optionalsInput = {}) {
const optionals = new GetFolderAppItemAssociationsOptionals({
queryParams: optionalsInput.queryParams,
headers: optionalsInput.headers,
cancellationToken: optionalsInput.cancellationToken,
});
const queryParams = optionals.queryParams;
const headers = optionals.headers;
const cancellationToken = optionals.cancellationToken;
const queryParamsMap = (0, utils_1.prepareParams)({
['limit']: (0, utils_2.toString)(queryParams.limit),
['marker']: (0, utils_2.toString)(queryParams.marker),
['application_type']: (0, utils_2.toString)(queryParams.applicationType),
});
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/folders/', (0, utils_2.toString)(folderId), '/app_item_associations'),
method: 'GET',
params: queryParamsMap,
headers: headersMap,
responseFormat: 'json',
auth: this.auth,
networkSession: this.networkSession,
cancellationToken: cancellationToken,
}));
return {
...(0, appItemAssociations_1.deserializeAppItemAssociations)(response.data),
rawData: response.data,
};
}
}
exports.AppItemAssociationsManager = AppItemAssociationsManager;
//# sourceMappingURL=appItemAssociations.js.map