import { Archon } from "../Archon.js";
import { User, UserId } from "../types/user.js";

/**
 * Given a user id, return the user's information from the Archon authentication layer.
 * @param id The user id to get information for.
 * @returns The user's information.
 */
export default async function getUserInfo(id: UserId): Promise<User> {
    const response = await Archon.request(`/users/user/${id}`, "GET");

    if (response.status !== 200) {
        throw new Error(`Failed to retrieve user information for user ${id}.`);
    }

    return response.data;
}