import {
  CharacterListResponse,
  CharacterListResponseSchema,
} from "@/data/schemas/character";

import { ApiPath } from "./api_path";
import { httpClient } from "./http_client";
import { ApiEnvelope, unwrap } from "./response_helper";

export class CharacterApi {
  async getChatCharacters(): Promise<CharacterListResponse> {
    const env = await httpClient<ApiEnvelope<unknown>>(ApiPath.characters, {
      query: { capability: "chat" },
    });
    return CharacterListResponseSchema.parse(unwrap(env));
  }
}

export const characterApi = new CharacterApi();
