using Workflow.Domain.Enums;
using Workflow.Domain.Exceptions;

namespace Workflow.Domain.StateMachine;

public class TokenTransitionContext
{
}

public class TokenStateMachine
{
    public TokenStatus Transition(TokenStatus currentState, TokenOperation operation, TokenTransitionContext context)
    {
        return (currentState, operation) switch
        {
            (TokenStatus.Active, TokenOperation.NodeComplete) => TokenStatus.Consumed,
            (TokenStatus.Active, TokenOperation.InstanceTerminate) => TokenStatus.Terminated,
            _ => throw new InvalidStateTransitionException(
                $"Invalid token state transition: cannot perform '{operation}' on token in '{currentState}' state.")
        };
    }
}
