// Copyright Epic Games, Inc. All Rights Reserved. using System.Collections.Generic; using System.Text.Json.Serialization; namespace EpicGames.Slack { /// /// Abstract base class for all BlockKit blocks to derive from. /// public class SlackAttachment : ISlackBlockContainer { /// /// The color of the line down the left side of the attachment. /// [JsonPropertyName("color"), JsonPropertyOrder(1)] public string Color { get; set; } = "#ff0000"; /// /// Used for the "toast" notifications sent by Slack. If not set, and the Text property of the /// base message isn't set, the notification will have a message saying it has no preview. /// [JsonPropertyName("fallback"), JsonPropertyOrder(2)] public string? FallbackText { get; set; } /// /// A collection of BlockKit blocks the attachment is composed from. /// [JsonPropertyName("blocks"), JsonPropertyOrder(3)] public List Blocks { get; } = new List(); /// /// Implicit conversion to a message of its own /// /// public static implicit operator SlackMessage(SlackAttachment attachment) { SlackMessage message = new SlackMessage(); message.Attachments.Add(attachment); return message; } } }