using System.Text;

namespace QCRPG.TSL.ZigBee.Packets;

public static class ProtocolIdInfo
{
	public static ProtocolIdEnum ValueToProtocolId(uint value)
	{
		return value switch
		{
			1u => ProtocolIdEnum.REQUEST, 
			2u => ProtocolIdEnum.INDICATION, 
			3u => ProtocolIdEnum.RESPONSE, 
			4u => ProtocolIdEnum.CONFIRMATION, 
			_ => ProtocolIdEnum.InvalidProtocolIdValue, 
		};
	}

	public static uint ProtocolIdToValue(ProtocolIdEnum enumItem)
	{
		return enumItem switch
		{
			ProtocolIdEnum.REQUEST => 1u, 
			ProtocolIdEnum.INDICATION => 2u, 
			ProtocolIdEnum.RESPONSE => 3u, 
			ProtocolIdEnum.CONFIRMATION => 4u, 
			_ => uint.MaxValue, 
		};
	}

	public static string ProtocolIdToString(ProtocolIdEnum enumItem)
	{
		return enumItem switch
		{
			ProtocolIdEnum.REQUEST => "REQUEST", 
			ProtocolIdEnum.INDICATION => "INDICATION", 
			ProtocolIdEnum.RESPONSE => "RESPONSE", 
			ProtocolIdEnum.CONFIRMATION => "CONFIRMATION", 
			_ => "Invalid ProtocolId Value", 
		};
	}

	public static string ProtocolIdToDescription()
	{
		StringBuilder stringBuilder = new StringBuilder();
		stringBuilder.AppendLine("0x1 = REQUEST");
		stringBuilder.AppendLine("0x2 = INDICATION");
		stringBuilder.AppendLine("0x3 = RESPONSE");
		stringBuilder.AppendLine("0x4 = CONFIRMATION");
		return stringBuilder.ToString();
	}
}
