UNPKG

@pnp/cli-microsoft365

Version:

Manage Microsoft 365 and SharePoint Framework projects on any platform

22 lines 1.1 kB
import { odata } from './odata.js'; import { formatting } from './formatting.js'; import { cli } from '../cli/cli.js'; export const calendarGroup = { async getUserCalendarGroupByName(userId, displayName, properties) { let url = `https://graph.microsoft.com/v1.0/users('${userId}')/calendarGroups?$filter=name eq '${formatting.encodeQueryParameter(displayName)}'`; if (properties) { url += `&$select=${properties}`; } const calendarGroups = await odata.getAllItems(url); if (calendarGroups.length === 0) { throw new Error(`The specified calendar group '${displayName}' does not exist.`); } if (calendarGroups.length > 1) { const resultAsKeyValuePair = formatting.convertArrayToHashTable('id', calendarGroups); const selectedCalendarGroup = await cli.handleMultipleResultsFound(`Multiple calendar groups with name '${displayName}' found.`, resultAsKeyValuePair); return selectedCalendarGroup; } return calendarGroups[0]; } }; //# sourceMappingURL=calendarGroup.js.map