UNPKG

zhonya

Version:

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

30 lines 1.14 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PuuidService = void 0; const axios_1 = require("axios"); const ZhonyaError_1 = require("../../errors/ZhonyaError"); class PuuidService { constructor(config) { this.config = config; const client = axios_1.default.create({ baseURL: `https://${config.regionalRouting}.api.riotgames.com/riot`, headers: { "X-Riot-Token": config.riotApiKey, }, }); this.httpClient = client; } async getByName(summonerName, tagLine = "BR1") { try { const encodedSummonerName = encodeURIComponent(summonerName); const encodedTagLine = encodeURIComponent(tagLine); const response = await this.httpClient.get(`account/v1/accounts/by-riot-id/${encodedSummonerName}/${encodedTagLine}`); return response.data.puuid; } catch (error) { throw new ZhonyaError_1.ZhonyaError("Error while fetching PUUID", error); } } } exports.PuuidService = PuuidService; //# sourceMappingURL=puuid.service.js.map