/// <summary> /// Retrieve current connected user's data. /// <para>Permission Scopes: /// User.Read (Sign in and read user profile)</para> /// </summary> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <param name="selectFields">array of fields Microsoft Graph has to include in the response.</param> /// <returns>Strongly type User info from the service</returns> public async Task <Graph.User> GetProfileAsync(CancellationToken cancellationToken, MicrosoftGraphUserFields[] selectFields = null) { if (selectFields == null) { _currentConnectedUser = await _graphProvider.Me.Request().GetAsync(cancellationToken); } else { string selectedProperties = MicrosoftGraphHelper.BuildString <MicrosoftGraphUserFields>(selectFields); _currentConnectedUser = await _graphProvider.Me.Request().Select(selectedProperties).GetAsync(cancellationToken); } return(_currentConnectedUser); }
/// <summary> /// Retrieve current connected user's emails. /// <para>(default=10)</para> /// <para>Permission Scope : Mail.Read (Read user mail)</para> /// </summary> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <param name="top">The number of items to return in a result set.</param> /// <param name="selectFields">array of fields Microsoft Graph has to include in the response.</param> /// <returns>a Collection of Pages containing the messages</returns> public async Task <IUserMessagesCollectionPage> GetEmailsAsync(CancellationToken cancellationToken, int top = 10, MicrosoftGraphMessageFields[] selectFields = null) { IUserMessagesCollectionPage messages = null; if (selectFields == null) { messages = await _graphProvider.Me.Messages.Request().Top(top).OrderBy(OrderBy).GetAsync(cancellationToken); } else { string selectedProperties = MicrosoftGraphHelper.BuildString <MicrosoftGraphMessageFields>(selectFields); messages = await _graphProvider.Me.Messages.Request().Top(top).OrderBy(OrderBy).Select(selectedProperties).GetAsync(cancellationToken); } _nextPageRequest = messages.NextPageRequest; return(messages); }
/// <summary> /// Retrieve current connected user's events. /// <para>(default=10)</para> /// <para>Permission Scope : Event.Read (Read user calendar)</para> /// </summary> /// <param name="cancellationToken">The <see cref="CancellationToken"/> for the request.</param> /// <param name="top">The number of items to return in a result set.</param> /// <param name="selectFields">array of fields Microsoft Graph has to include in the response.</param> /// <returns>a Collection of Pages containing the events</returns> public async Task <IUserEventsCollectionPage> GetEventsAsync(CancellationToken cancellationToken, int top = 10, MicrosoftGraphEventFields[] selectFields = null) { IUserEventsCollectionPage events = null; if (selectFields == null) { events = await _graphProvider.Me.Events.Request().OrderBy(OrderBy).Top(top).GetAsync(cancellationToken); } else { string selectedProperties = MicrosoftGraphHelper.BuildString(selectFields); events = await _graphProvider.Me.Events.Request().OrderBy(OrderBy).Top(top).Select(selectedProperties).GetAsync(cancellationToken); } _nextPageRequest = events.NextPageRequest; return(events); }