diff --git a/Libraries/Microsoft.Teams.Api/MessageExtensions/AttachmentLayout.cs b/Libraries/Microsoft.Teams.Api/MessageExtensions/AttachmentLayout.cs new file mode 100644 index 000000000..e09797dd2 --- /dev/null +++ b/Libraries/Microsoft.Teams.Api/MessageExtensions/AttachmentLayout.cs @@ -0,0 +1,24 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System.Text.Json.Serialization; + +using Microsoft.Teams.Common; + +namespace Microsoft.Teams.Api.MessageExtensions; + +/// +/// Hint for how to deal with multiple attachments in a messaging extension result. +/// Possible values include: 'list', 'grid'. +/// +[JsonConverter(typeof(StringEnum.JsonConverter))] +public class AttachmentLayout(string value) : StringEnum(value) +{ + public static readonly AttachmentLayout List = new("list"); + [JsonIgnore] + public bool IsList => List.Equals(Value); + + public static readonly AttachmentLayout Grid = new("grid"); + [JsonIgnore] + public bool IsGrid => Grid.Equals(Value); +} diff --git a/Libraries/Microsoft.Teams.Api/MessageExtensions/Result.cs b/Libraries/Microsoft.Teams.Api/MessageExtensions/Result.cs index f7dc401ac..5995c6b96 100644 --- a/Libraries/Microsoft.Teams.Api/MessageExtensions/Result.cs +++ b/Libraries/Microsoft.Teams.Api/MessageExtensions/Result.cs @@ -42,7 +42,7 @@ public class Result /// [JsonPropertyName("attachmentLayout")] [JsonPropertyOrder(0)] - public Api.Attachment.Layout? AttachmentLayout { get; set; } + public AttachmentLayout? AttachmentLayout { get; set; } /// /// The type of the result. Possible values include: diff --git a/Samples/Samples.MessageExtensions/Program.cs b/Samples/Samples.MessageExtensions/Program.cs index a82cd5592..38048b706 100644 --- a/Samples/Samples.MessageExtensions/Program.cs +++ b/Samples/Samples.MessageExtensions/Program.cs @@ -60,7 +60,7 @@ ComposeExtension = new Microsoft.Teams.Api.MessageExtensions.Result { Type = Microsoft.Teams.Api.MessageExtensions.ResultType.Result, - AttachmentLayout = Microsoft.Teams.Api.Attachment.Layout.List, + AttachmentLayout = Microsoft.Teams.Api.MessageExtensions.AttachmentLayout.List, Attachments = new List() } }); @@ -198,7 +198,7 @@ static Microsoft.Teams.Api.MessageExtensions.Response CreateSearchResults(string ComposeExtension = new Microsoft.Teams.Api.MessageExtensions.Result { Type = Microsoft.Teams.Api.MessageExtensions.ResultType.Result, - AttachmentLayout = Microsoft.Teams.Api.Attachment.Layout.List, + AttachmentLayout = Microsoft.Teams.Api.MessageExtensions.AttachmentLayout.List, Attachments = attachments } }; @@ -233,7 +233,7 @@ static Microsoft.Teams.Api.MessageExtensions.Response HandleCreateCard(JsonEleme ComposeExtension = new Microsoft.Teams.Api.MessageExtensions.Result { Type = Microsoft.Teams.Api.MessageExtensions.ResultType.Result, - AttachmentLayout = Microsoft.Teams.Api.Attachment.Layout.List, + AttachmentLayout = Microsoft.Teams.Api.MessageExtensions.AttachmentLayout.List, Attachments = new List { attachment } } }; @@ -268,7 +268,7 @@ static Microsoft.Teams.Api.MessageExtensions.Response HandleGetMessageDetails(Mi ComposeExtension = new Microsoft.Teams.Api.MessageExtensions.Result { Type = Microsoft.Teams.Api.MessageExtensions.ResultType.Result, - AttachmentLayout = Microsoft.Teams.Api.Attachment.Layout.List, + AttachmentLayout = Microsoft.Teams.Api.MessageExtensions.AttachmentLayout.List, Attachments = new List { attachment } } }; @@ -303,7 +303,7 @@ static Microsoft.Teams.Api.MessageExtensions.Response CreateLinkUnfurlResponse(s ComposeExtension = new Microsoft.Teams.Api.MessageExtensions.Result { Type = Microsoft.Teams.Api.MessageExtensions.ResultType.Result, - AttachmentLayout = Microsoft.Teams.Api.Attachment.Layout.List, + AttachmentLayout = Microsoft.Teams.Api.MessageExtensions.AttachmentLayout.List, Attachments = new List { attachment } } }; @@ -335,7 +335,7 @@ static Microsoft.Teams.Api.MessageExtensions.Response CreateItemSelectionRespons ComposeExtension = new Microsoft.Teams.Api.MessageExtensions.Result { Type = Microsoft.Teams.Api.MessageExtensions.ResultType.Result, - AttachmentLayout = Microsoft.Teams.Api.Attachment.Layout.List, + AttachmentLayout = Microsoft.Teams.Api.MessageExtensions.AttachmentLayout.List, Attachments = new List { attachment } } };