46 lines
1.4 KiB
C#
46 lines
1.4 KiB
C#
using DigitalData.Modules.Logging;
|
|
using EnvelopeGenerator.Common;
|
|
|
|
namespace EnvelopeGenerator.Web.Services
|
|
{
|
|
public class ApiService
|
|
{
|
|
private LogConfig _logConfig;
|
|
private Logger _logger;
|
|
|
|
public ApiService(LoggingService Logging, IConfiguration Config)
|
|
{
|
|
_logConfig = Logging.LogConfig;
|
|
_logger = Logging.LogConfig.GetLogger();
|
|
|
|
_logger.Debug("Initializing ApiService");
|
|
}
|
|
|
|
public string EnsureValidEnvelopeKey(string envelopeKey)
|
|
{
|
|
_logger.Debug("Parsing EnvelopeKey..");
|
|
|
|
if (string.IsNullOrEmpty(envelopeKey))
|
|
throw new ArgumentNullException("EnvelopeKey");
|
|
|
|
Tuple<string, string> result = Helpers.DecodeEnvelopeReceiverId(envelopeKey);
|
|
_logger.Debug("EnvelopeUUID: [{0}]", result.Item1);
|
|
_logger.Debug("ReceiverSignature: [{0}]", result.Item2);
|
|
|
|
if (string.IsNullOrEmpty(result.Item1))
|
|
throw new ArgumentNullException("EnvelopeUUID");
|
|
|
|
if (string.IsNullOrEmpty(result.Item2))
|
|
throw new ArgumentNullException("ReceiverSignature");
|
|
|
|
return envelopeKey;
|
|
}
|
|
|
|
public string EnsureValidEnvelopeKey(HttpRequest request)
|
|
{
|
|
var envelopeKey = request.RouteValues["envelopeKey"] as string;
|
|
return EnsureValidEnvelopeKey(envelopeKey);
|
|
}
|
|
}
|
|
}
|