@esri/arcgis-rest-portal
Version:
ArcGIS Online and Enterprise content and user helpers for @esri/arcgis-rest-request
31 lines • 1.37 kB
JavaScript
;
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc.
* Apache-2.0 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.setUserProperties = void 0;
const arcgis_rest_request_1 = require("@esri/arcgis-rest-request");
const get_portal_url_js_1 = require("../util/get-portal-url.js");
/**
* Updates the properties for a user
* @param username The user whose properties to update
* @param properties IUserProperties object with properties to update
* @param requestOptions An IAuthenticatedRequestOptions object
* @returns a promise that resolves to { success: boolean }
*/
async function setUserProperties(username, properties, requestOptions) {
const url = `${(0, get_portal_url_js_1.getPortalUrl)(requestOptions)}/community/users/${encodeURIComponent(username)}/setProperties`;
const options = Object.assign({ httpMethod: "POST", params: { properties } }, requestOptions);
try {
const response = await (0, arcgis_rest_request_1.request)(url, options);
if (!response.success) {
throw new Error("Success was false");
}
return response;
}
catch (e) {
const error = e;
throw new Error(`Failed to set user properties: ${error.message}`);
}
}
exports.setUserProperties = setUserProperties;
//# sourceMappingURL=set-user-properties.js.map