microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
core/src/Microsoft.Teams.Apps/Api/Clients/MemberClient.cs
48lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.Core.Schema; |
| 5 | |
| 6 | using CoreConversationClient = Microsoft.Teams.Core.ConversationClient; |
| 7 | |
| 8 | namespace Microsoft.Teams.Apps.Api.Clients; |
| 9 | |
| 10 | /// <summary> |
| 11 | /// Client for managing conversation members. |
| 12 | /// Delegates to the core <see cref="CoreConversationClient"/>. |
| 13 | /// </summary> |
| 14 | public class MemberClient |
| 15 | { |
| 16 | private readonly CoreConversationClient _client; |
| 17 | private readonly Uri _serviceUrl; |
| 18 | |
| 19 | internal MemberClient(Uri serviceUrl, CoreConversationClient client) |
| 20 | { |
| 21 | _serviceUrl = serviceUrl; |
| 22 | _client = client; |
| 23 | } |
| 24 | |
| 25 | /// <summary> |
| 26 | /// Get all members of a conversation. |
| 27 | /// </summary> |
| 28 | public Task<IList<ConversationAccount>> GetAsync(string conversationId, AgenticIdentity? agenticIdentity = null, CancellationToken cancellationToken = default) |
| 29 | { |
| 30 | return _client.GetConversationMembersAsync(conversationId, _serviceUrl, agenticIdentity: agenticIdentity, cancellationToken: cancellationToken); |
| 31 | } |
| 32 | |
| 33 | /// <summary> |
| 34 | /// Get a specific member of a conversation by ID. |
| 35 | /// </summary> |
| 36 | public Task<T> GetByIdAsync<T>(string conversationId, string memberId, AgenticIdentity? agenticIdentity = null, CancellationToken cancellationToken = default) where T : ConversationAccount |
| 37 | { |
| 38 | return _client.GetConversationMemberAsync<T>(conversationId, memberId, _serviceUrl, agenticIdentity: agenticIdentity, cancellationToken: cancellationToken); |
| 39 | } |
| 40 | |
| 41 | /// <summary> |
| 42 | /// Get a specific member of a conversation by ID. |
| 43 | /// </summary> |
| 44 | public Task<ConversationAccount> GetByIdAsync(string conversationId, string memberId, AgenticIdentity? agenticIdentity = null, CancellationToken cancellationToken = default) |
| 45 | { |
| 46 | return GetByIdAsync<ConversationAccount>(conversationId, memberId, agenticIdentity, cancellationToken); |
| 47 | } |
| 48 | } |