feat(decode): Methoden zur Konvertierung des dekodierten Arrays in eine Umschlag-Empfänger-ID und eine Nur-Lese-ID mit Ausnahmewirkung hinzugefügt.

This commit is contained in:
Developer 02 2024-10-01 16:44:46 +02:00
parent 6847b74095
commit 792aa0b922

View File

@ -1,5 +1,4 @@
using Microsoft.Extensions.Logging;
using System.Security.Cryptography;
using System.Text;
namespace EnvelopeGenerator.Application
@ -81,13 +80,23 @@ namespace EnvelopeGenerator.Application
return true;
}
public static EncodeType GetEncodeType(string[] decoded) => decoded.Length switch
public static EncodeType GetEncodeType(this string[] decoded) => decoded.Length switch
{
2 => EncodeType.EnvelopeReceiver,
3 => EncodeType.ReadOnly,
3 => long.TryParse(decoded[1], out var _) ? EncodeType.ReadOnly : EncodeType.Undefined,
_ => EncodeType.Undefined,
};
public static (string? EnvelopeUuid, string? ReceiverSignature) ToEnvelopeReceiverId(this string[] decoded)
=> decoded.GetEncodeType() == EncodeType.EnvelopeReceiver
? (EnvelopeUuid: decoded[0], ReceiverSignature: decoded[1])
: throw new InvalidOperationException("Attempted to convert a decoded other than type EnvelopeReceiver to EnvelopeReceiver. ");
public static long ToReadOnlyId(this string[] decoded)
=> decoded.GetEncodeType() == EncodeType.ReadOnly
? long.Parse(decoded[1])
: throw new InvalidOperationException("Attempted to convert a decoded other than type EnvelopeReceiver to EnvelopeReceiver. ");
/// <summary>
/// Decodes the envelope receiver ID and extracts the envelope UUID and receiver signature.
/// </summary>