"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.failSafeUpdate = failSafeUpdate;
const serializeModel_1 = require("../models/serializeModel");
const fail_safe_1 = require("../utils/fail-safe");
const wrappers_1 = require("../rest/portal/wrappers");
/**
 * Update a model's item, wrapped in a failSafe so this will not blow up if
 * the user lacks rights somehow. This should be used in places where there is
 * a high-probability that the current user CAN update the item.
 * @param {Object} model Model object to be updated
 * @param {IRequestOptions} requestOptions
 */
function failSafeUpdate(model, requestOptions) {
    const failSafedUpdate = (0, fail_safe_1.failSafe)(wrappers_1.updateItem, {
        id: model.item.id,
        success: true,
    });
    const opts = Object.assign({ item: (0, serializeModel_1.serializeModel)(model) }, requestOptions);
    return failSafedUpdate(opts);
}
//# sourceMappingURL=fail-safe-update.js.map