microsoft/teams.net
Publicmirrored fromhttps://github.com/microsoft/teams.netAvailable
core/src/Microsoft.Teams.Bot.Apps/Api/ConversationsApi.cs
69lines · modecode
| 1 | // Copyright (c) Microsoft Corporation. |
| 2 | // Licensed under the MIT License. |
| 3 | |
| 4 | using Microsoft.Teams.Bot.Core; |
| 5 | using Microsoft.Teams.Bot.Core.Schema; |
| 6 | |
| 7 | namespace Microsoft.Teams.Bot.Apps.Api; |
| 8 | |
| 9 | using CustomHeaders = Dictionary<string, string>; |
| 10 | |
| 11 | /// <summary> |
| 12 | /// Provides conversation-related operations. |
| 13 | /// </summary> |
| 14 | /// <remarks> |
| 15 | /// This class serves as a container for conversation-specific sub-APIs: |
| 16 | /// <list type="bullet"> |
| 17 | /// <item><see cref="Activities"/> - Activity operations (send, update, delete, history)</item> |
| 18 | /// <item><see cref="Members"/> - Member operations (get, delete)</item> |
| 19 | /// <item><see cref="Reactions"/> - Reaction operations (add, delete)</item> |
| 20 | /// </list> |
| 21 | /// </remarks> |
| 22 | public class ConversationsApi |
| 23 | { |
| 24 | private readonly ConversationClient _client; |
| 25 | |
| 26 | /// <summary> |
| 27 | /// Initializes a new instance of the <see cref="ConversationsApi"/> class. |
| 28 | /// </summary> |
| 29 | /// <param name="conversationClient">The conversation client for conversation operations.</param> |
| 30 | internal ConversationsApi(ConversationClient conversationClient) |
| 31 | { |
| 32 | _client = conversationClient; |
| 33 | Activities = new ActivitiesApi(conversationClient); |
| 34 | Members = new MembersApi(conversationClient); |
| 35 | Reactions = new ReactionsApi(conversationClient); |
| 36 | } |
| 37 | |
| 38 | /// <summary> |
| 39 | /// Gets the activities API for sending, updating, and deleting activities. |
| 40 | /// </summary> |
| 41 | public ActivitiesApi Activities { get; } |
| 42 | |
| 43 | /// <summary> |
| 44 | /// Gets the members API for managing conversation members. |
| 45 | /// </summary> |
| 46 | public MembersApi Members { get; } |
| 47 | |
| 48 | /// <summary> |
| 49 | /// Gets the reactions API for adding and removing reactions on activities. |
| 50 | /// </summary> |
| 51 | public ReactionsApi Reactions { get; } |
| 52 | |
| 53 | /// <summary> |
| 54 | /// Creates a new conversation. |
| 55 | /// </summary> |
| 56 | /// <param name="parameters">The parameters for creating the conversation. Cannot be null.</param> |
| 57 | /// <param name="serviceUrl">The service URL for the bot. Cannot be null.</param> |
| 58 | /// <param name="agenticIdentity">Optional agentic identity for authentication.</param> |
| 59 | /// <param name="customHeaders">Optional custom headers to include in the request.</param> |
| 60 | /// <param name="cancellationToken">A cancellation token that can be used to cancel the operation.</param> |
| 61 | /// <returns>A task that represents the asynchronous operation. The task result contains the conversation resource response with the conversation ID.</returns> |
| 62 | public Task<CreateConversationResponse> CreateAsync( |
| 63 | ConversationParameters parameters, |
| 64 | Uri serviceUrl, |
| 65 | AgenticIdentity? agenticIdentity = null, |
| 66 | CustomHeaders? customHeaders = null, |
| 67 | CancellationToken cancellationToken = default) |
| 68 | => _client.CreateConversationAsync(parameters, serviceUrl, agenticIdentity, customHeaders, cancellationToken); |
| 69 | } |
| 70 | |