UNPKG

@mencraft/lore-headless

Version:
60 lines (59 loc) 2.21 kB
import { ApiResponse } from './types'; /** * Authentication credentials */ export interface AuthCredentials { clientId: string; token: string; } /** * API client for making requests */ export declare class LoreClient { private chatUrl; private validationUrl; /** * Creates an instance of the LoreClient * @param mode The mode to use for the API client. One of 'production', 'staging', or 'development'. * @param customChatUrl Optional custom chat URL to use instead of the default based on the mode. * @param customValidationUrl Optional custom validation URL to use instead of the default based on the mode. * @throws Error if customChatUrl or customValidationUrl is provided but the other is not. */ constructor(mode?: 'production' | 'staging' | 'development', customChatUrl?: string, customValidationUrl?: string); /** * Make a POST request to the API * @param endpoint API endpoint * @param auth Authentication credentials * @param body Request body * @param options Request options * @returns API response */ post<T>(endpoint: string, auth: AuthCredentials, body?: any, options?: RequestInit & { headers?: Record<string, string>; useValidationUrl?: boolean; }): Promise<ApiResponse<T>>; /** * Make a chat POST request to the API * @param endpoint API endpoint * @param auth Authentication credentials * @param body Request body * @param options Request options * @returns API response */ chatPost<T>(endpoint: string, auth: AuthCredentials, body?: any, options?: RequestInit & { headers?: Record<string, string>; }): Promise<ApiResponse<T>>; /** * Make an admin POST request to the API * @param endpoint API endpoint * @param clientId Client ID * @param firebaseIdToken Firebase ID token * @param body Request body * @param options Request options * @returns API response */ adminPost<T>(endpoint: string, auth: AuthCredentials, body?: any, options?: RequestInit & { headers?: Record<string, string>; useValidationUrl?: boolean; }): Promise<ApiResponse<T>>; }