using System.Text.Json;
using DysonNetwork.Shared.Proto;
namespace DysonNetwork.Sphere.WebReader;
/// 
/// The embeddable can be used in the post or messages' meta's embeds fields
/// To render a richer type of content.
///
/// A simple example of using link preview embed:
/// 
/// {
///     // ... post content
///     "meta": {
///         "embeds": [
///             {
///                 "type": "link",
///                 "title: "...",
///                 /// ...
///             }
///         ]
///     }
/// }
/// 
/// 
public abstract class EmbeddableBase
{
    public abstract string Type { get; }
    public static Dictionary ToDictionary(dynamic input)
    {
        var jsonRaw = JsonSerializer.Serialize(
            input,
            GrpcTypeHelper.SerializerOptionsWithIgnore
        );
        return JsonSerializer.Deserialize>(
            jsonRaw,
            GrpcTypeHelper.SerializerOptionsWithIgnore
        );
    }
}