Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// Hint for how to deal with multiple attachments in a messaging extension result.
/// Possible values include: 'list', 'grid'.
/// </summary>
[JsonConverter(typeof(StringEnum.JsonConverter<AttachmentLayout>))]
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);
}
2 changes: 1 addition & 1 deletion Libraries/Microsoft.Teams.Api/MessageExtensions/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public class Result
/// </summary>
[JsonPropertyName("attachmentLayout")]
[JsonPropertyOrder(0)]
public Api.Attachment.Layout? AttachmentLayout { get; set; }
public AttachmentLayout? AttachmentLayout { get; set; }

/// <summary>
/// The type of the result. Possible values include:
Expand Down
12 changes: 6 additions & 6 deletions Samples/Samples.MessageExtensions/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Microsoft.Teams.Api.MessageExtensions.Attachment>()
}
});
Expand Down Expand Up @@ -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
}
};
Expand Down Expand Up @@ -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<Microsoft.Teams.Api.MessageExtensions.Attachment> { attachment }
}
};
Expand Down Expand Up @@ -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<Microsoft.Teams.Api.MessageExtensions.Attachment> { attachment }
}
};
Expand Down Expand Up @@ -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<Microsoft.Teams.Api.MessageExtensions.Attachment> { attachment }
}
};
Expand Down Expand Up @@ -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<Microsoft.Teams.Api.MessageExtensions.Attachment> { attachment }
}
};
Expand Down