namespace Kbx.Shared.Integrations;

public static class KbxIntegrationFailureClassifier
{
    public static KbxIntegrationFailureKind Classify(Exception error) => error switch
    {
        OperationCanceledException => KbxIntegrationFailureKind.Transient,
        HttpRequestException => KbxIntegrationFailureKind.Transient,
        _ => KbxIntegrationFailureKind.Permanent,
    };

    public static KbxIntegrationFailureKind ClassifyHttp(int statusCode) => statusCode switch
    {
        408 or 429 => KbxIntegrationFailureKind.Transient,
        >= 500 and <= 599 => KbxIntegrationFailureKind.Transient,
        _ => KbxIntegrationFailureKind.Permanent,
    };
}
