package de.effigenix.infrastructure.usermanagement.web.exception;

import de.effigenix.domain.usermanagement.UserError;

public final class UserErrorHttpStatusMapper {

    private UserErrorHttpStatusMapper() {}

    public static int toHttpStatus(UserError error) {
        return switch (error) {
            case UserError.UsernameAlreadyExists e -> 409;
            case UserError.EmailAlreadyExists e -> 409;
            case UserError.UserNotFound e -> 404;
            case UserError.InvalidCredentials e -> 401;
            case UserError.UserLocked e -> 401;
            case UserError.UserInactive e -> 401;
            case UserError.RoleNotFound e -> 404;
            case UserError.InvalidPassword e -> 400;
            case UserError.Unauthorized e -> 403;
            case UserError.InvalidEmail e -> 400;
            case UserError.InvalidUsername e -> 400;
            case UserError.NullPasswordHash e -> 400;
            case UserError.NullRole e -> 400;
            case UserError.NullPermission e -> 400;
            case UserError.InvalidStatusTransition e -> 409;
            case UserError.InvalidInput e -> 400;
            case UserError.RepositoryFailure e -> 500;
        };
    }
}
