UNPKG

@esri/arcgis-rest-portal

Version:

ArcGIS Online and Enterprise content and user helpers for @esri/arcgis-rest-request

27 lines 1.14 kB
/* Copyright (c) 2023 Environmental Systems Research Institute, Inc. * Apache-2.0 */ import { request } from "@esri/arcgis-rest-request"; import { getPortalUrl } from "../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 } */ export async function setUserProperties(username, properties, requestOptions) { const url = `${getPortalUrl(requestOptions)}/community/users/${encodeURIComponent(username)}/setProperties`; const options = Object.assign({ httpMethod: "POST", params: { properties } }, requestOptions); try { const response = await 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}`); } } //# sourceMappingURL=set-user-properties.js.map