microsoft/teams.net

Public

mirrored fromhttps://github.com/microsoft/teams.netAvailable

CodeCommitsIssuesPull requestsActionsInsightsSecurity
dev

Branches

Tags

  • No tags available.
0Branches0Tags
Go to file
Add file
Code

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Api/Clients/TeamClient.cs

45lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using Microsoft.Teams.Common.Http;
5
6namespace Microsoft.Teams.Api.Clients;
7
8public class TeamClient : Client
9{
10 public readonly string ServiceUrl;
11
12 public TeamClient(string serviceUrl, CancellationToken cancellationToken = default) : base(cancellationToken)
13 {
14 ServiceUrl = serviceUrl;
15 }
16
17 public TeamClient(string serviceUrl, IHttpClient client, CancellationToken cancellationToken = default) : base(client, cancellationToken)
18 {
19 ServiceUrl = serviceUrl;
20 }
21
22 public TeamClient(string serviceUrl, IHttpClientOptions options, CancellationToken cancellationToken = default) : base(options, cancellationToken)
23 {
24 ServiceUrl = serviceUrl;
25 }
26
27 public TeamClient(string serviceUrl, IHttpClientFactory factory, CancellationToken cancellationToken = default) : base(factory, cancellationToken)
28 {
29 ServiceUrl = serviceUrl;
30 }
31
32 public async Task<Team> GetByIdAsync(string id)
33 {
34 var request = HttpRequest.Get($"{ServiceUrl}v3/teams/{id}");
35 var response = await _http.SendAsync<Team>(request, _cancellationToken);
36 return response.Body;
37 }
38
39 public async Task<List<Channel>> GetConversationsAsync(string id)
40 {
41 var request = HttpRequest.Get($"{ServiceUrl}v3/teams/{id}/conversations");
42 var response = await _http.SendAsync<List<Channel>>(request, _cancellationToken);
43 return response.Body;
44 }
45}