microsoft/teams.net

Public

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

CodeCommitsIssuesPull requestsActionsInsightsSecurity
next/core-activitybuilder

Branches

Tags

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

Clone

HTTPS

Download ZIP

Libraries/Microsoft.Teams.Api/Cards/Action.cs

100lines · modecode

1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT License.
3
4using System.Text.Json.Serialization;
5
6using Microsoft.Teams.Common;
7
8namespace Microsoft.Teams.Api.Cards;
9
10[JsonConverter(typeof(JsonConverter<ActionType>))]
11public class ActionType(string value) : StringEnum(value)
12{
13 public static readonly ActionType OpenUrl = new("openUrl");
14 public bool IsOpenUrl => OpenUrl.Equals(Value);
15
16 public static readonly ActionType IMBack = new("imBack");
17 public bool IsIMBack => IMBack.Equals(Value);
18
19 public static readonly ActionType PostBack = new("postBack");
20 public bool IsPostBack => PostBack.Equals(Value);
21
22 public static readonly ActionType PlayAudio = new("playAudio");
23 public bool IsPlayAudio => PlayAudio.Equals(Value);
24
25 public static readonly ActionType PlayVideo = new("playVideo");
26 public bool IsPlayVideo => PlayVideo.Equals(Value);
27
28 public static readonly ActionType ShowImage = new("showImage");
29 public bool IsShowImage => ShowImage.Equals(Value);
30
31 public static readonly ActionType DownloadFile = new("downloadFile");
32 public bool IsDownloadFile => DownloadFile.Equals(Value);
33
34 public static readonly ActionType SignIn = new("signin");
35 public bool IsSignIn => SignIn.Equals(Value);
36
37 public static readonly ActionType Call = new("call");
38 public bool IsCall => Call.Equals(Value);
39}
40
41public class Action(ActionType type)
42{
43 /// <summary>
44 /// The type of action implemented by this button. Possible values include: 'openUrl', 'imBack',
45 /// 'postBack', 'playAudio', 'playVideo', 'showImage', 'downloadFile', 'signin', 'call',
46 /// 'messageBack'
47 /// </summary>
48 [JsonPropertyName("type")]
49 [JsonPropertyOrder(0)]
50 public ActionType Type { get; set; } = type;
51
52 /// <summary>
53 /// Text description which appears on the button
54 /// </summary>
55 [JsonPropertyName("title")]
56 [JsonPropertyOrder(1)]
57 public required string Title { get; set; }
58
59 /// <summary>
60 /// Image URL which will appear on the button, next to text label
61 /// </summary>
62 [JsonPropertyName("image")]
63 [JsonPropertyOrder(2)]
64 public string? Image { get; set; }
65
66 /// <summary>
67 /// Text for this action
68 /// </summary>
69 [JsonPropertyName("text")]
70 [JsonPropertyOrder(3)]
71 public string? Text { get; set; }
72
73 /// <summary>
74 /// (Optional) text to display in the chat feed if the button is clicked
75 /// </summary>
76 [JsonPropertyName("displayText")]
77 [JsonPropertyOrder(4)]
78 public string? DisplayText { get; set; }
79
80 /// <summary>
81 /// Supplementary parameter for action. Content of this property depends on the ActionType
82 /// </summary>
83 [JsonPropertyName("value")]
84 [JsonPropertyOrder(5)]
85 public object? Value { get; set; }
86
87 /// <summary>
88 /// Channel-specific data associated with this action
89 /// </summary>
90 [JsonPropertyName("channelData")]
91 [JsonPropertyOrder(6)]
92 public object? ChannelData { get; set; }
93
94 /// <summary>
95 /// Alternate image text to be used in place of the `image` field
96 /// </summary>
97 [JsonPropertyName("imageAltText")]
98 [JsonPropertyOrder(7)]
99 public string? ImageAltText { get; set; }
100}