UNPKG

box-node-sdk

Version:

Official SDK for Box Plaform APIs

63 lines 2.64 kB
"use strict"; /** * @fileoverview Manager for the Box Collection Resource */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var url_path_1 = __importDefault(require("../util/url-path")); // ----------------------------------------------------------------------------- // Typedefs // ----------------------------------------------------------------------------- // ------------------------------------------------------------------------------ // Private // ------------------------------------------------------------------------------ var BASE_PATH = '/collections'; // ------------------------------------------------------------------------------ // Public // ------------------------------------------------------------------------------ /** * Simple manager for interacting with all 'Collection' endpoints and actions. * * @constructor * @param {BoxClient} client - The Box API Client that is responsible for making calls to the API * @returns {void} */ var Collections = /** @class */ (function () { function Collections(client) { this.client = client; } /** * Requests all of a user's collection objects. * * API Endpoint: '/collections' * Method: GET * * @param {Function} [callback] - Called with a collection of collections if successful * @returns {Promise<Object>} A promise resolving to the collection of collections */ Collections.prototype.getAll = function (callback) { return this.client.wrapWithDefaultHandler(this.client.get)(BASE_PATH, {}, callback); }; /** * Requests the items in the collection object with a given ID. * * API Endpoint: '/collections/:collectionID/items' * Method: GET * * @param {string} collectionID - Box ID of the collection with items being requested * @param {Object} [options] - Additional options for the request. Can be left null in most cases. * @param {Function} [callback] - Passed the items information if they were acquired successfully * @returns {Promise<Object>} A promise resolving to the collection of items in the collection */ Collections.prototype.getItems = function (collectionID, options, callback) { var params = { qs: options, }; var apiPath = (0, url_path_1.default)(BASE_PATH, collectionID, 'items'); return this.client.wrapWithDefaultHandler(this.client.get)(apiPath, params, callback); }; return Collections; }()); module.exports = Collections; //# sourceMappingURL=collections.js.map