UNPKG

zhonya

Version:

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

37 lines 1.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SummonerAPI = void 0; const ZhonyaError_1 = require("../errors/ZhonyaError"); const puuid_service_1 = require("../internal/Puuid/puuid.service"); const summoner_service_1 = require("../resources/summoner/summoner.service"); /** * Class for accessing summoner-related functionalities */ class SummonerAPI { constructor(context) { this.context = context; this.puuidService = new puuid_service_1.PuuidService(context.config); this.summonerService = new summoner_service_1.SummonerService(context.config); } /** * Find a summoner by name * @param summonerName - Summoner name * @returns Summoner data * @throws {ZhonyaError} - If the client is not initialized or if the API key is missing * @remarks **This method requires a valid API key to work** */ async getByName(summonerName) { this.context.checkInitialized(); this.context.checkApiKey(); try { const puuid = await this.puuidService.getByName(summonerName); return await this.summonerService.getByPuuid(puuid); } catch (error) { const zhonyaError = error; throw new ZhonyaError_1.ZhonyaError(`Error while fetching summoner by name`, zhonyaError.riotError); } } } exports.SummonerAPI = SummonerAPI; //# sourceMappingURL=summoner.js.map