// Copyright Epic Games, Inc. All Rights Reserved. using System; using System.Collections.Generic; using System.Text.Json; using System.Text.Json.Serialization; namespace EpicGames.Slack { /// /// Abstract base class for all BlockKit blocks to derive from. /// [JsonConverter(typeof(BlockConverter))] public abstract class Block { /// /// The block type /// [JsonPropertyName("type"), JsonPropertyOrder(0)] public string Type { get; } /// /// A string acting as a unique identifier for a block. If not specified, one will be generated. Maximum length for this field is 255 characters. /// block_id should be unique for each message and each iteration of a message. If a message is updated, use a new block_id. /// [JsonPropertyName("block_id"), JsonPropertyOrder(30)] public string? BlockId { get; set; } /// /// Constructor /// /// Type of the block protected Block(string type) { Type = type; } } /// /// Interface for a container of items /// public interface ISlackBlockContainer { /// /// List of blocks /// List Blocks { get; } } /// /// Polymorphic serializer for Block objects. /// class BlockConverter : JsonConverter { public override Block? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options) { throw new NotImplementedException(); } public override void Write(Utf8JsonWriter writer, Block value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, (object)value, value.GetType(), options); } } }