box-node-sdk
Version:
Official SDK for Box Plaform APIs
174 lines (173 loc) • 9.15 kB
TypeScript
/**
* @fileoverview Manager for the Box Collaboration Resource
*/
import BoxClient from '../box-client';
import { Collaboration, CollaborationAccesibleBy, CollaborationRole, CollaborationStatus, CollaborationUpdate } from '../schemas';
type ItemType = 'file' | 'folder';
/**
* Simple manager for interacting with all 'Collaboration' endpoints and actions.
*
* @constructor
* @param {BoxClient} client - The Box API Client that is responsible for making calls to the API
* @returns {void}
*/
declare class Collaborations {
client: BoxClient;
constructor(client: BoxClient);
/**
* Requests a collaboration object with a given ID.
*
* API Endpoint: '/collaborations/:collaborationID'
* Method: GET
*
* @param {string} collaborationID - Box ID of the collaboration being requested
* @param {Object} [options] - Additional options for the request. Can be left null in most cases.
* @param {Function} [callback] - Passed the collaboration information if it was acquired successfully
* @returns {Promise<Collaboration>} A promise resolving to the collaboration object
*/
get(collaborationID: string, options?: Record<string, any>, callback?: Function): Promise<Collaboration>;
/**
* Gets a user's pending collaborations
*
* API Endpoint: '/collaborations'
* Method: GET
*
* @param {Function} [callback] - Called with a collection of pending collaborations if successful
* @returns {Promise<Collaborations>} A promise resolving to the collection of pending collaborations
*/
getPending(callback?: Function): Promise<Collaborations>;
private updateInternal;
/**
* Update some information about a given collaboration.
*
* API Endpoint: '/collaborations/:collaborationID'
* Method: PUT
*
* @param {string} collaborationID - Box ID of the collaboration being requested
* @param {CollaborationUpdate} updates - Fields of the collaboration to be updated
* @param {Function} [callback] - Passed the updated collaboration information if it was acquired successfully
* @returns {Promise<Collaboration>} A promise resolving to the updated collaboration object
*/
update(collaborationID: string, updates: CollaborationUpdate, callback?: Function): Promise<Collaboration>;
/**
* Update the status of a pending collaboration.
*
* API Endpoint: '/collaborations/:collaborationID'
* Method: PUT
*
* @param {string} collaborationID - Box ID of the collaboration being requested
* @param {CollaborationStatus} newStatus - The new collaboration status ('accepted'/'rejected')
* @param {Function} [callback] - Passed the updated collaboration information if it was acquired successfully
* @returns {Promise<Collaboration>} A promise resolving to the accepted collaboration object
*/
respondToPending(collaborationID: string, newStatus: CollaborationStatus, callback?: Function): Promise<Collaboration>;
/**
* Invite a collaborator to a folder. You'll have to create the 'accessible_by' input object
* yourself, but the method allows for multiple types of collaborator invites. See
* {@link http://developers.box.com/docs/#collaborations-add-a-collaboration} for formatting
* help.
*
* API Endpoint: '/collaborations
* Method: POST
*
* @param {CollaborationAccesibleBy} accessibleBy - The accessible_by object expected by the API
* @param {string} itemID - Box ID of the item to which the user should be invited
* @param {CollaborationRole} role - The role which the invited collaborator should have
* @param {Object} [options] - Optional parameters for the collaboration
* @param {ItemType} [options.type=folder] - Type of object to be collaborated
* @param {boolean} [options.notify] - Determines if the user or group will receive email notifications
* @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
* @param {boolean} [options.is_access_only] - WARN: Feature not yet available.
* Do not display collaborated items on collaborator's All Files Pages
* and suppress notifications sent to collaborators regarding access-only content.
* This feature is going to be released in Q4. Watch our
* [announcements](https://developer.box.com/changelog/) to learn about its availability.
* @param {Function} [callback] - Called with the new collaboration if successful
* @returns {Promise<Collaboration>} A promise resolving to the created collaboration object
*/
create(accessibleBy: CollaborationAccesibleBy, itemID: string, role: CollaborationRole, options?: {
type?: ItemType;
notify?: boolean;
can_view_path?: boolean;
is_access_only?: boolean;
} | Function, callback?: Function): Promise<Collaboration>;
/**
* Invite a user to collaborate on an item via their user ID.
*
* API Endpoint: '/collaborations
* Method: POST
*
* @param {int | string} userID - The ID of the user you'll invite as a collaborator
* @param {string} itemID - Box ID of the item to which the user should be invited
* @param {CollaborationRole} role - The role which the invited collaborator should have
* @param {Object} [options] - Optional parameters for the collaboration
* @param {ItemType} [options.type=folder] - Type of object to be collaborated
* @param {boolean} [options.notify] - Determines if the user will receive email notifications
* @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
* @param {Function} [callback] - Called with the new collaboration if successful
* @returns {Promise<Collaboration>} A promise resolving to the created collaboration object
*/
createWithUserID(userID: number | string, itemID: string, role: CollaborationRole, options?: {
type?: ItemType;
notify?: boolean;
can_view_path?: boolean;
} | Function, callback?: Function): Promise<Collaboration>;
/**
* Invite a user to collaborate on an item via their user login email address.
*
* API Endpoint: '/collaborations
* Method: POST
*
* @param {string} email - The collaborator's email address
* @param {string} itemID - Box ID of the item to which the user should be invited
* @param {CollaborationRole} role - The role which the invited collaborator should have
* @param {Object} [options] - Optional parameters for the collaboration
* @param {ItemType} [options.type=folder] - Type of object to be collaborated
* @param {boolean} [options.notify] - Determines if the user will receive email notifications
* @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
* @param {Function} [callback] - Called with the new collaboration if successful
* @returns {Promise<Collaboration>} A promise resolving to the created collaboration object
*/
createWithUserEmail(email: string, itemID: string, role: CollaborationRole, options?: {
type?: ItemType;
notify?: boolean;
can_view_path?: boolean;
} | Function, callback?: Function): Promise<Collaboration>;
/**
* Invite a group to collaborate on an item via their group ID.
*
* API Endpoint: '/collaborations
* Method: POST
*
* @param {int | string} groupID - The ID of the group you'll invite as a collaborator
* @param {string} itemID - Box ID of the item to which the group should be invited
* @param {CollaborationRole} role - The role which the invited collaborator should have
* @param {Object} [options] - Optional parameters for the collaboration
* @param {ItemType} [options.type=folder] - Type of object to be collaborated
* @param {boolean} [options.notify] - Determines if the group will receive email notifications
* @param {boolean} [options.can_view_path] - Whether view path collaboration feature is enabled or not
* @param {Function} [callback] - Called with the new collaboration if successful
* @returns {Promise<Collaboration>} A promise resolving to the created collaboration object
*/
createWithGroupID(groupID: number | string, itemID: string, role: CollaborationRole, options?: {
type?: ItemType;
notify?: boolean;
can_view_path?: boolean;
} | Function, callback?: Function): Promise<Collaboration>;
/**
* Delete a given collaboration.
*
* API Endpoint: '/collaborations/:collaborationID'
* Method: DELETE
*
* @param {string} collaborationID - Box ID of the collaboration being requested
* @param {Function} [callback] - Empty response body passed if successful.
* @returns {Promise<void>} A promise resolving to nothing
*/
delete(collaborationID: string, callback?: Function): Promise<void>;
}
/**
* @module box-node-sdk/lib/managers/collaborations
* @see {@Link Collaborations}
*/
export = Collaborations;