microsoft/teams.net
Publicmirrored from https://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Api/Clients/MeetingClient.cs
92lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. All rights reserved. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using System.Text.Json.Serialization; |
| 5 | |
| 6 | using Microsoft.Teams.Api.Meetings; |
| 7 | using Microsoft.Teams.Common.Http; |
| 8 | |
| 9 | namespace Microsoft.Teams.Api.Clients; |
| 10 | |
| 11 | public class MeetingClient : Client |
| 12 | { |
| 13 | public readonly string ServiceUrl; |
| 14 | |
| 15 | public MeetingClient(string serviceUrl, CancellationToken cancellationToken = default) : base(cancellationToken) |
| 16 | { |
| 17 | ServiceUrl = serviceUrl; |
| 18 | } |
| 19 | |
| 20 | public MeetingClient(string serviceUrl, IHttpClient client, CancellationToken cancellationToken = default) : base(client, cancellationToken) |
| 21 | { |
| 22 | ServiceUrl = serviceUrl; |
| 23 | } |
| 24 | |
| 25 | public MeetingClient(string serviceUrl, IHttpClientOptions options, CancellationToken cancellationToken = default) : base(options, cancellationToken) |
| 26 | { |
| 27 | ServiceUrl = serviceUrl; |
| 28 | } |
| 29 | |
| 30 | public MeetingClient(string serviceUrl, IHttpClientFactory factory, CancellationToken cancellationToken = default) : base(factory, cancellationToken) |
| 31 | { |
| 32 | ServiceUrl = serviceUrl; |
| 33 | } |
| 34 | |
| 35 | public async Task<Meeting> GetByIdAsync(string id, CancellationToken cancellationToken = default) |
| 36 | { |
| 37 | var token = cancellationToken != default ? cancellationToken : _cancellationToken; |
| 38 | var request = HttpRequest.Get($"{ServiceUrl}v1/meetings/{id}"); |
| 39 | var response = await _http.SendAsync<Meeting>(request, token); |
| 40 | return response.Body; |
| 41 | } |
| 42 | |
| 43 | public async Task<MeetingParticipant> GetParticipantAsync(string meetingId, string id, string tenantId, CancellationToken cancellationToken = default) |
| 44 | { |
| 45 | var token = cancellationToken != default ? cancellationToken : _cancellationToken; |
| 46 | var request = HttpRequest.Get($"{ServiceUrl}v1/meetings/{Uri.EscapeDataString(meetingId)}/participants/{Uri.EscapeDataString(id)}?tenantId={Uri.EscapeDataString(tenantId)}"); |
| 47 | var response = await _http.SendAsync<MeetingParticipant>(request, token); |
| 48 | return response.Body; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | /// <summary> |
| 53 | /// Meeting participant information |
| 54 | /// </summary> |
| 55 | public class MeetingParticipant |
| 56 | { |
| 57 | /// <summary> |
| 58 | /// The participant's user information |
| 59 | /// </summary> |
| 60 | [JsonPropertyName("user")] |
| 61 | public Account? User { get; set; } |
| 62 | |
| 63 | /// <summary> |
| 64 | /// Gets or sets information about the associated meeting. |
| 65 | /// </summary> |
| 66 | [JsonPropertyName("meeting")] |
| 67 | public MeetingInfo? Meeting { get; set; } |
| 68 | |
| 69 | /// <summary> |
| 70 | /// Gets or sets the conversation associated with this object. |
| 71 | /// </summary> |
| 72 | [JsonPropertyName("conversation")] |
| 73 | public Conversation? Conversation { get; set; } |
| 74 | } |
| 75 | |
| 76 | /// <summary> |
| 77 | /// Represents information about a participant's role and meeting status within a meeting context. |
| 78 | /// </summary> |
| 79 | public class MeetingInfo |
| 80 | { |
| 81 | /// <summary> |
| 82 | /// Gets or sets the role associated with the entity. |
| 83 | /// </summary> |
| 84 | [JsonPropertyName("role")] |
| 85 | public string? Role { get; set; } |
| 86 | |
| 87 | /// <summary> |
| 88 | /// Gets or sets a value indicating whether the user is currently in a meeting. |
| 89 | /// </summary> |
| 90 | [JsonPropertyName("inMeeting")] |
| 91 | public bool? InMeeting { get; set; } |
| 92 | } |