box-node-sdk
Version:
Official SDK for Box Plaform APIs
90 lines • 5.04 kB
JavaScript
;
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var url_path_1 = __importDefault(require("../util/url-path"));
var FileRequestsManager = /** @class */ (function () {
function FileRequestsManager(client) {
// Attach the client, for making API calls
this.client = client;
}
/**
* Gets File Request by ID.
* @param {string} fileRequestId File Request ID
* @param {Function} [callback] passed the user info if it was acquired successfully
* @returns {Promise<FileRequest>} a promise with FileRequest details
*/
FileRequestsManager.prototype.getById = function (fileRequestId, callback) {
var apiPath = (0, url_path_1.default)('file_requests', fileRequestId);
return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, callback);
};
/**
* Delete File Request.
* @param {string} fileRequestId File Request ID
* @param {Function} [callback] passed the user info if it was acquired successfully
* @returns {Promise<void>} Returns a promise resolving to nothing
*/
FileRequestsManager.prototype.delete = function (fileRequestId, callback) {
var apiPath = (0, url_path_1.default)('file_requests', fileRequestId);
return this.client.wrapWithDefaultHandler(this.client.del)(apiPath, callback);
};
/**
* Copies existing FileRequest to new folder
* @param {string} fileRequestIdToCopy ID of file request to copy
* @param copyRequest copy request details
* @param {string} copyRequest.folder.id ID of folder to which file request will be copied
* @param {string} copyRequest.folder.type type of folder. Value is always 'folder'
* @param {string} [copyRequest.title] new title of file request
* @param {string} [copyRequest.description] new description of file request
* @param {string} [copyRequest.expires_at] new date when file request expires
* @param {boolean} [copyRequest.is_description_required] is file request submitter required to provide a description
* of the files they are submitting
* @param {boolean} [copyRequest.is_email_required] is file request submitter required to provide their email address
* @param {string} [copyRequest.status] new status of file request
* @param {Function} [callback] passed the user info if it was acquired successfully
* @returns {Promise<FileRequest>} Returns a promise with FileRequest details
*/
FileRequestsManager.prototype.copy = function (fileRequestIdToCopy, copyRequest, callback) {
var apiPath = (0, url_path_1.default)('file_requests', fileRequestIdToCopy, 'copy');
return this.client.wrapWithDefaultHandler(this.client.post)(apiPath, { body: copyRequest }, callback);
};
/**
* Update existing file request
* @param {string} fileRequestId ID of file request
* @param {string} fileRequestChange change of file request
* @param {string} [fileRequestChange.description] new description of file request
* @param {string} [fileRequestChange.expires_at] new date when file request expires
* @param {boolean} [fileRequestChange.is_description_required] is file request submitter required to provide a
* description of the files they are submitting
* @param {boolean} [fileRequestChange.is_email_required] is file request submitter required to provide their
* email address
* @param {string} [fileRequestChange.status] new status of file request
* @param {string} [fileRequestChange.title] new title of file request
* @param {string} [originalRequestEtag] pass in the item's last observed etag value into this header and
* the endpoint will fail with a 412 Precondition Failed if it has changed since.
* @param {Function} callback passed the user info if it was acquired successfully
* @returns {Promise<FileRequest>} Returns a promise with FileRequest details
*/
FileRequestsManager.prototype.update = function (fileRequestId, fileRequestChange, originalRequestEtag, callback) {
var apiPath = (0, url_path_1.default)('file_requests', fileRequestId);
var params = { body: fileRequestChange };
if (originalRequestEtag) {
params = __assign(__assign({}, params), { headers: { 'if-match': originalRequestEtag } });
}
return this.client.wrapWithDefaultHandler(this.client.put)(apiPath, params, callback);
};
return FileRequestsManager;
}());
module.exports = FileRequestsManager;
//# sourceMappingURL=file-requests-manager.js.map