microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
Libraries/Microsoft.Teams.Api/Clients/MeetingClient.cs
89lines · 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) |
| 36 | { |
| 37 | var request = HttpRequest.Get($"{ServiceUrl}v1/meetings/{id}"); |
| 38 | var response = await _http.SendAsync<Meeting>(request, _cancellationToken); |
| 39 | return response.Body; |
| 40 | } |
| 41 | |
| 42 | public async Task<MeetingParticipant> GetParticipantAsync(string meetingId, string id) |
| 43 | { |
| 44 | var request = HttpRequest.Get($"{ServiceUrl}v1/meetings/{meetingId}/participants/{id}"); |
| 45 | var response = await _http.SendAsync<MeetingParticipant>(request, _cancellationToken); |
| 46 | return response.Body; |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /// <summary> |
| 51 | /// Meeting participant information |
| 52 | /// </summary> |
| 53 | public class MeetingParticipant |
| 54 | { |
| 55 | /// <summary> |
| 56 | /// Unique identifier for the participant |
| 57 | /// </summary> |
| 58 | [JsonPropertyName("id")] |
| 59 | [JsonPropertyOrder(0)] |
| 60 | public required string Id { get; set; } |
| 61 | |
| 62 | /// <summary> |
| 63 | /// The participant's user information |
| 64 | /// </summary> |
| 65 | [JsonPropertyName("user")] |
| 66 | [JsonPropertyOrder(1)] |
| 67 | public Account? User { get; set; } |
| 68 | |
| 69 | /// <summary> |
| 70 | /// The participant's role in the meeting |
| 71 | /// </summary> |
| 72 | [JsonPropertyName("role")] |
| 73 | [JsonPropertyOrder(2)] |
| 74 | public string? Role { get; set; } |
| 75 | |
| 76 | /// <summary> |
| 77 | /// Whether the participant is an organizer |
| 78 | /// </summary> |
| 79 | [JsonPropertyName("isOrganizer")] |
| 80 | [JsonPropertyOrder(3)] |
| 81 | public bool IsOrganizer { get; set; } |
| 82 | |
| 83 | /// <summary> |
| 84 | /// The time when the participant joined the meeting |
| 85 | /// </summary> |
| 86 | [JsonPropertyName("joinTime")] |
| 87 | [JsonPropertyOrder(4)] |
| 88 | public DateTime? JoinTime { get; set; } |
| 89 | } |