/**
 * -------------------------------------------------------------------------------------------
 * Copyright (c) Microsoft Corporation.  All Rights Reserved.  Licensed under the MIT License.
 * See License in the project root for license information.
 * -------------------------------------------------------------------------------------------
 */ import { GraphPageIterator , IGraph , prepScopes } from '@microsoft/mgt-element' ; import * as MicrosoftGraph from '@microsoft/microsoft-graph-types' ; param { Date } startDateTime param { Date } endDateTime param { string } groupId param { string } preferredTimezone returns { ( Promise < Event [ ] > ) } memberof export function getEventsPageIterator ( graph , startDateTime , endDateTime , groupId ? , preferredTimezone ? ) { const scopes = 'calendars.read' ; const sdt = `startdatetime=${ startDateTime . toISOString ( ) }` ; const edt = `enddatetime=${ endDateTime . toISOString ( ) }` ; let uri ; if ( groupId ) { uri = `groups/${ groupId }/calendar` ; } else { uri = 'me' ; } uri += `/calendarview?${ sdt }&${ edt }` ; let request = graph . api ( uri ) . middlewareOptions ( prepScopes ( scopes ) ) . orderby ( 'start/dateTime' ) ; if ( preferredTimezone ) { request = request . header ( 'Prefer' , `outlook.timezone="${ preferredTimezone }"` ) ; } return GraphPageIterator . create < MicrosoftGraph . Event > ( graph , request ) ; }