/// <summary> Gets read receipts for a thread asynchronously. </summary> /// <param name="skip"> Skips chat message read receipts up to a specified position in response. </param> /// <param name="cancellationToken"> The cancellation token to use. </param> /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception> public virtual AsyncPageable <ChatMessageReadReceipt> GetReadReceiptsAsync(int?skip = null, CancellationToken cancellationToken = default) { async Task <Page <ChatMessageReadReceipt> > FirstPageFunc(int?pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ChatThreadClient)}.{nameof(GetReadReceipts)}"); scope.Start(); try { Response <ChatMessageReadReceiptsCollection> response = await _chatThreadRestClient.ListChatReadReceiptsAsync(Id, pageSizeHint, skip, cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value.Select(x => new ChatMessageReadReceipt(x)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } async Task <Page <ChatMessageReadReceipt> > NextPageFunc(string nextLink, int?pageSizeHint) { using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(ChatThreadClient)}.{nameof(GetReadReceipts)}"); scope.Start(); try { Response <ChatMessageReadReceiptsCollection> response = await _chatThreadRestClient.ListChatReadReceiptsNextPageAsync(nextLink, Id, pageSizeHint, skip, cancellationToken).ConfigureAwait(false); return(Page.FromValues(response.Value.Value.Select(x => new ChatMessageReadReceipt(x)), response.Value.NextLink, response.GetRawResponse())); } catch (Exception e) { scope.Failed(e); throw; } } return(PageableHelpers.CreateAsyncEnumerable(FirstPageFunc, NextPageFunc)); }