48 lines
1.6 KiB
C#
48 lines
1.6 KiB
C#
using System.Xml.Linq;
|
|
using Serilog;
|
|
using CRIF.ACTion.Common.Parsers;
|
|
using Landmark.OLA.Models.Decisioning.Enums;
|
|
|
|
namespace CRIF.ACTion.Decisioning
|
|
{
|
|
public class DecisioningStateResponseParser : IResponseParser<DecisioningState>
|
|
{
|
|
private const string SuccessMessage = "Success";
|
|
private const string MissingRequredInformation = "WorkFlowBC::SendToWorkflow::(Decisioning) Process Instances not in correct state Please correct the Process Errors.";
|
|
|
|
private string ExpectedLoanId;
|
|
|
|
public DecisioningStateResponseParser()
|
|
{
|
|
}
|
|
|
|
public void SetLoanId(string expectedLoanId)
|
|
{
|
|
ExpectedLoanId = expectedLoanId;
|
|
}
|
|
|
|
public DecisioningState Parse(XElement xElement)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(ExpectedLoanId))
|
|
{
|
|
throw new ArgumentException("Must set valid ExpectedLoanId with SetLoanId(expectedLoanId)");
|
|
}
|
|
|
|
if (xElement.Value.Equals(SuccessMessage + ExpectedLoanId))
|
|
{
|
|
return DecisioningState.Requested;
|
|
}
|
|
if (xElement.Value.Equals(MissingRequredInformation))
|
|
{
|
|
Log.Debug("Application {loanId} is likely missing information required for decisioning.", SuccessMessage, ExpectedLoanId);
|
|
return DecisioningState.MissingRequiredInformation;
|
|
}
|
|
else
|
|
{
|
|
Log.Debug("Did not receive {SuccessMessage} for a SendToDecisioning call for Application {loanId}.", SuccessMessage, ExpectedLoanId);
|
|
return DecisioningState.Unknown;
|
|
}
|
|
}
|
|
}
|
|
}
|