using ChatTwo.Code;
using Newtonsoft.Json;
namespace ChatTwo.Http.MessageProtocol;
#region Outgoing SSE
///
/// Contains a valid tab with its assigned index
///
public struct ChatTab(string name, int index)
{
[JsonProperty("name")] public string Name = name;
[JsonProperty("index")] public int Index = index;
}
///
/// Contains a number of tabs that are valid for the user to pick from
///
public struct ChatTabList(ChatTab[] tabs)
{
[JsonProperty("tabs")] public ChatTab[] Tabs = tabs;
}
///
/// Contains the current channel name
///
public struct SwitchChannel((MessageTemplate[] ChannelName, bool Locked) channel)
{
[JsonProperty("channelName")] public MessageTemplate[] ChannelName = channel.ChannelName;
[JsonProperty("channelLocked")] public bool Locked = channel.Locked;
}
///
/// Contains a number of channels that are valid for the user to pick from
///
public struct ChannelList(Dictionary channels)
{
[JsonProperty("channels")] public Dictionary Channels = channels;
}
///
/// Contains one or multiple messages
///
public struct Messages(MessageResponse[] set)
{
[JsonProperty("messages")] public MessageResponse[] Set = set;
}
///
/// Contains a single message with all its templates and a timestamp
///
public struct MessageResponse()
{
[JsonProperty("timestamp")] public string Timestamp = "";
[JsonProperty("templates")] public MessageTemplate[] Templates;
}
///
/// Template that is used for the channel name or any message posted to the chatlog
///
public struct MessageTemplate()
{
///
/// Template type
///
/// icon = a game icon
/// emote = BetterTTV emote
/// url = Simple url that should be clickable
/// text = Simple text content of the message
///
/// Note:
/// Empty is used for invalid payloads
///
[JsonProperty("payload")] public required string Payload;
///
/// Used for text and emote.
///
[JsonProperty("content")] public string Content = "";
///
/// Used for an icon.
///
[JsonProperty("id")] public uint Id;
///
/// Used for text and url
///
/// Note:
/// 0 is used for invalid colors
///
[JsonProperty("color")] public uint Color;
public static MessageTemplate Empty => new() {Payload = "empty"};
}
#endregion
#region Outgoing POST
public struct OkResponse(string message)
{
[JsonProperty("message")] public string Message = message;
}
public struct ErrorResponse(string reason)
{
[JsonProperty("reason")] public string Reason = reason;
}
#endregion
#region Incoming POST
///
/// Message must fulfill the posting requirement
/// Greater than or equal 2 characters
/// Less than or equal 500 characters
///
public struct IncomingMessage()
{
[JsonProperty("message")] public string Message = string.Empty;
}
///
/// The channel type must be a valid
///
public struct IncomingChannel()
{
[JsonProperty("channel")] public InputChannel Channel = InputChannel.Invalid;
}
///
/// The tabs index must be a valid int
///
public struct IncomingTab()
{
[JsonProperty("index")] public int Index = -1;
}
#endregion