Adding
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
using LCU.API.Collections.CollectionsApiLib.Models;
|
||||
using LCU.API.Collections.RepoApi.Exceptions;
|
||||
using Serilog;
|
||||
|
||||
namespace LCU.API.Collections.RepoApi.Services
|
||||
{
|
||||
public class StatusService
|
||||
{
|
||||
/**
|
||||
* Convert a Stage from a case to a RepoAccount status.
|
||||
*/
|
||||
public static string ConvertStatus(RepoStatus oldStage)
|
||||
{
|
||||
switch (oldStage)
|
||||
{
|
||||
case RepoStatus.PSKP: return "PSKP";
|
||||
case RepoStatus.REHO: return "REHO";
|
||||
case RepoStatus.RECA: return "RECA";
|
||||
case RepoStatus.O4R: return "O4R";
|
||||
case RepoStatus.REPO: return "REPO";
|
||||
case RepoStatus.REDEEMED: return "REDEEMED";
|
||||
case RepoStatus.SOLD: return "SOLD";
|
||||
case RepoStatus.NOTACTIVE: return "SOLD";
|
||||
case RepoStatus.INELIGIBLE: throw new IneligibleAccountException("CaseStage", "Not a Repo Case Stage.");
|
||||
// case RepoStatus.UNKNOWN is meant to fall through to below.
|
||||
}
|
||||
|
||||
Log.Fatal($"Attempt to convert status {oldStage}, but was not known.");
|
||||
// The account is not necessarily ineligible, but is missing a requirement, the stage.
|
||||
// This covers the problem of Temenos not providing a Case Stage Change event, and only
|
||||
// a Case Creation event. The stage won't be available yet, so throw a MissingRequirement
|
||||
// causing it to be retried on the hour - it should then run fine.
|
||||
throw new MissingRequirementException("Case Stage", $"A valid case stage is required, {oldStage} is not valid.");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user