"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.fetchAndUploadThumbnail = fetchAndUploadThumbnail;
const wrappers_1 = require("../rest/portal/wrappers");
const fetch_image_as_blob_1 = require("./fetch-image-as-blob");
/**
 * Fetch image from a url, then upload to an item as it's thumbnail
 * @param {object} options
 */
function fetchAndUploadThumbnail(options) {
    // first fetch it as a blob...
    return (0, fetch_image_as_blob_1.fetchImageAsBlob)(options.url)
        .then((file) => {
        return (0, wrappers_1.updateItem)({
            item: {
                id: options.id,
                owner: options.owner,
            },
            params: {
                fileName: options.fileName,
                thumbnail: file,
            },
            authentication: options.authentication,
        }).catch((_) => {
            // resolve b/c this is not crtical
            return Promise.resolve();
        });
    })
        .catch((_) => {
        return Promise.resolve();
    });
}
//# sourceMappingURL=fetch-and-upload-thumbnail.js.map