/** * KB Media APIs * @namespace jibo.kb.media */ /** MediaModel Class. The Media Model subclass * * @example * jibo.kb.media#loadMedia( (err, media) => console.log(media) ); * @class MediaModel * @extends jibo.kb.Model * @memberof jibo.kb.media */ /** Create an Error with a good message from an AxiosError object * * @method jibo.kb.media.MediaModel#_processError * @param {AxiosError} err Axios error object. * @returns {Error} Error object. * @private */ /** Load media nodes in the media list. Deleted media nodes are * excluded. If callback is omitted a promise is returned instead. * * @method jibo.kb.media.MediaModel#loadMedia * @param {Function} [callback] Called with (err, media). If callback * is omitted a promise that resolves to `media` is returned * instead. * @returns {Promise} A promise that resolves with the list of * media nodes if the callback is omitted. */ /** Load all media nodes, including deleted ones. * * @method jibo.kb.media.MediaModel#loadMediaAll * @param {Function} [callback] Called with (err, media). If callback * is omitted a promise that resolves to `media` is returned * instead. * @returns {Promise} A promise that resolves with the list of * media nodes if the callback is omitted. */ /** Load the node for the thumbnail for a given media item node. * @method jibo.kb.media.MediaModel#loadThumbnail * @param {jibo.kb.media.MediaNode} mediaNode The media node you want the thumbnail to. * @param {jibo.media#ThumbnailType} [type=thumb_robot] Type of thumbnail. * @param {function} callback Called with the media node for the * thumbnail, or `undefined` if there is no thumbnail of that * type. */ /** Get the url for the thumbnail for a given media item node. * @method jibo.kb.media.MediaModel#getThumbnailUrl * @param {jibo.kb.media.MediaNode} mediaNode The media node you want the thumbnail to. * @param {jibo.media#ThumbnailType} [type=thumb_robot] Type of thumbnail. * @returns {string} Url for the thumbnail of that type, if any, * `undefined` otherwise. */ /** Download a list of thumbnails to the local image store. * * @method jibo.kb.media.MediaModel#downloadThumbnails * @param {string[]} ids Array of thumnails Content IDs to download. * @param {Function} [callback] Called with err object if there * was an error. If callback is omitted a promise is returned instead. * @returns {Promise} A promise that resolves when the operation is * finished. * @private */ /** Download a photo to the local image store. * * @method jibo.kb.media.MediaModel#downloadPhoto * @param {string} id Content ID of photo to download. * @param {Function} [callback] Called with err object if there * was an error. If callback is omitted a promise is returned instead. * @returns {Promise} A promise that resolves when the operation is * finished. * @private */ /** Filter out media items that have been deleted. * * @method jibo.kb.media.MediaModel#_onlyNotDeleted * @param {jibo.kb.media.MediaNode[]} media Media nodes to filter. * @returns {jibo.kb.media.MediaNode[]} Media nodes where `isDeleted` is * `false`. * @private */