"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setItemThumbnail = setItemThumbnail;
const wrappers_1 = require("../rest/portal/wrappers");
const HubError_1 = require("../HubError");
/**
 * Upload a file to be used as the thumbnail for an item
 * @param id
 * @param file
 * @param filename
 * @param requestOptions
 */
async function setItemThumbnail(id, file, filename, requestOptions, owner) {
    const opts = Object.assign({ item: {
            id,
        }, owner, params: {
            thumbnail: file,
            fileName: filename,
        }, filename }, requestOptions);
    try {
        const response = await (0, wrappers_1.updateItem)(opts);
        if (!response.success) {
            throw new HubError_1.default("Set Project Thumbnail", "Unknown error setting thumbnail.");
        }
    }
    catch (err) {
        if (err instanceof Error) {
            throw new HubError_1.default("Set Project Thumbnail", err.message, err);
        }
        else {
            throw new HubError_1.default("Set Project Thumbnail", "Unknown error setting thumbnail.");
        }
    }
}
//# sourceMappingURL=setItemThumbnail.js.map