"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.removeResource = removeResource;
const arcgis_rest_portal_1 = require("@esri/arcgis-rest-portal");
const HubError_1 = require("../HubError");
/**
 * Removes a resource associated with an item
 *
 * @export
 * @param {string} id item id
 * @param {string} name resource name
 * @param {string} owner item owner
 * @param {IUserRequestOptions} ro request options
 * @return {*}  {Promise<{
 *   success: boolean;
 * }>}
 */
async function removeResource(id, name, owner, ro) {
    try {
        // Remove item resource
        const response = await (0, arcgis_rest_portal_1.removeItemResource)(Object.assign({ id, resource: name, owner }, ro));
        // if err throw
        if (!response.success) {
            throw new HubError_1.default("Remove Item Resource", "Unknown error removing resource.");
        }
        return response;
    }
    catch (err) {
        if (err instanceof Error) {
            throw new HubError_1.default("Remove Item Resource", err.message, err);
        }
        else {
            throw new HubError_1.default("Remove Item Resource", "Unknown error removing resource.");
        }
    }
}
//# sourceMappingURL=removeResource.js.map