UNPKG

box-node-sdk

Version:

Official SDK for Box Plaform APIs

47 lines 1.88 kB
"use strict"; /** * @fileoverview Manager for the Trash Resource */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; const url_path_1 = __importDefault(require("../util/url-path")); // ----------------------------------------------------------------------------- // Private // ----------------------------------------------------------------------------- // Trash is technically a folder, so it uses the folders endpoint const BASE_PATH = '/folders', TRASH_ID = 'trash', ITEMS_SUBRESOURCE = 'items'; // ----------------------------------------------------------------------------- // Public // ----------------------------------------------------------------------------- /** * Simple manager for interacting with all Trash endpoints and actions. * * @constructor * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API * @returns {void} */ class Trash { constructor(client) { this.client = client; } /** * Get items in the user's trash * * API Endpoint: '/folders/trash/items' * Method: GET * * @param {Object} [options] - Optional parameters, can be left null in most cases * @param {string} [options.fields] - Comma-delimited list of item fields to return * @param {Function} [callback] - Passed the list of trashed items if successful, error otherwise * @returns {Promise<Object>} A promise resolving to the collection of trashed items */ get(options, callback) { var apiPath = (0, url_path_1.default)(BASE_PATH, TRASH_ID, ITEMS_SUBRESOURCE), params = { qs: options, }; return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback); } } module.exports = Trash; //# sourceMappingURL=trash.js.map