microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Api/Clients/MemberClient.cs
51lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.Common.Http; |
| 5 | |
| 6 | namespace Microsoft.Teams.Api.Clients; |
| 7 | |
| 8 | public class MemberClient : Client |
| 9 | { |
| 10 | public readonly string ServiceUrl; |
| 11 | |
| 12 | public MemberClient(string serviceUrl, CancellationToken cancellationToken = default) : base(cancellationToken) |
| 13 | { |
| 14 | ServiceUrl = serviceUrl; |
| 15 | } |
| 16 | |
| 17 | public MemberClient(string serviceUrl, IHttpClient client, CancellationToken cancellationToken = default) : base(client, cancellationToken) |
| 18 | { |
| 19 | ServiceUrl = serviceUrl; |
| 20 | } |
| 21 | |
| 22 | public MemberClient(string serviceUrl, IHttpClientOptions options, CancellationToken cancellationToken = default) : base(options, cancellationToken) |
| 23 | { |
| 24 | ServiceUrl = serviceUrl; |
| 25 | } |
| 26 | |
| 27 | public MemberClient(string serviceUrl, IHttpClientFactory factory, CancellationToken cancellationToken = default) : base(factory, cancellationToken) |
| 28 | { |
| 29 | ServiceUrl = serviceUrl; |
| 30 | } |
| 31 | |
| 32 | public async Task<List<Account>> GetAsync(string conversationId) |
| 33 | { |
| 34 | var request = HttpRequest.Get($"{ServiceUrl}v3/conversations/{conversationId}/members"); |
| 35 | var response = await _http.SendAsync<List<Account>>(request, _cancellationToken); |
| 36 | return response.Body; |
| 37 | } |
| 38 | |
| 39 | public async Task<Account> GetByIdAsync(string conversationId, string memberId) |
| 40 | { |
| 41 | var request = HttpRequest.Get($"{ServiceUrl}v3/conversations/{conversationId}/members/{memberId}"); |
| 42 | var response = await _http.SendAsync<Account>(request, _cancellationToken); |
| 43 | return response.Body; |
| 44 | } |
| 45 | |
| 46 | public async Task DeleteAsync(string conversationId, string memberId) |
| 47 | { |
| 48 | var request = HttpRequest.Delete($"{ServiceUrl}v3/conversations/{conversationId}/members/{memberId}"); |
| 49 | await _http.SendAsync(request, _cancellationToken); |
| 50 | } |
| 51 | } |