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