UNPKG

zhonya

Version:

A simple and typed League of Legends API wrapper for Node.js

69 lines (68 loc) 2.1 kB
import { ChampionAPI, FreeWeekAPI, SummonerAPI } from "./api"; import { ZhonyaParams } from "./config"; /** * Contexto interno compartilhado entre o cliente e as APIs * @internal */ export interface IZhonyaContext { config: ZhonyaParams; checkInitialized(): void; checkApiKey(): void; } /** * Main client for the Zhonya */ export declare class ZhonyaClient { /** * API for accessing champion-related functionalities */ champion: ChampionAPI; /** * API for accessing summoner-related functionalities */ summoner: SummonerAPI; /** * API for accessing free rotation functionalities */ freeWeek: FreeWeekAPI; /** * Contexto interno compartilhado * @private */ private context; /** * Initializes the Zhonya client and returns it ready to use * * @param riotApiKey - Riot Games API key (optional for some methods) * @param regionalRouting - Regional routing (default: americas) * @param platformRouting - Platform routing (default: br1) * @param language - Language for data returned (default: en_US) * @returns Zhonya client instance ready to use * * @example * ```typescript * import { ZhonyaClient } from "zhonya"; * * // Client with API key (full access to all methods) * const clientWithKey = ZhonyaClient.init({ * riotApiKey: process.env.RIOT_API_KEY, * regionalRouting: "americas", * platformRouting: "br1", * }); * * // Client without API key (limited access) * const clientWithoutKey = ZhonyaClient.init(); * // This will work * const champions = await clientWithoutKey.champion.getAll(); * // This will throw an error * const summoner = await clientWithoutKey.summoner.getByName("playerName"); * ``` * */ static init({ riotApiKey, regionalRouting, platformRouting, language, }?: ZhonyaParams): ZhonyaClient; /** * Private constructor to prevent direct instantiation * Use Zhonya.init() instead */ private constructor(); }