diff --git a/core/client.ts b/core/client.ts index f660da2..7c06767 100644 --- a/core/client.ts +++ b/core/client.ts @@ -1,4 +1,4 @@ -import { Champion, ChampionSummary, Item, LocaleVersionArgs, Perk, SummonerEmote, SummonerIcon, WardSkin } from "./models"; +import { Champion, ChampionSummary, Item, LocaleVersionArgs, Perk, SummonerEmote, SummonerIcon, WardSkin, Companion } from './models'; import axios from "axios"; export abstract class ApiObject { @@ -17,6 +17,7 @@ export class Client { public summonerEmotes: SummonerEmoteApi; public summonerIcons: SummonerIconApi; public wardSkins: WardSkinApi; + public companions: CompanionsApi; constructor() { this.items = new ItemApi(); @@ -26,6 +27,7 @@ export class Client { this.summonerEmotes = new SummonerEmoteApi(); this.summonerIcons = new SummonerIconApi(); this.wardSkins = new WardSkinApi(); + this.companions = new CompanionsApi(); } } @@ -76,4 +78,11 @@ export class WardSkinApi extends ApiObject { let res = await axios.get(`${this.getClientPath(args)}/v1/ward-skins.json`); return res.data.map((x: any) => new WardSkin(x)); } +} + +export class CompanionsApi extends ApiObject { + async listAsync(args: LocaleVersionArgs): Promise> { + let res = await axios.get(`${this.getClientPath(args)}/v1/companions.json`); + return res.data.map((x: any) => new Companion(x)); + } } \ No newline at end of file diff --git a/core/models.ts b/core/models.ts index 3b1a7c7..faaeb92 100644 --- a/core/models.ts +++ b/core/models.ts @@ -291,4 +291,34 @@ export class Rarity extends CommunityDragonObject { this.region = json.region; this.rarity = json.rarity; } +} + +export class Companion extends CommunityDragonObject { + contentId: string; + itemId: number; + name: string; + loadoutsIcon: string; + description: string; + level: number; + speciesName: string; + speciesId: string; + rarity: string; + + constructor(json: any) { + super(); + + this.contentId = json.contentId; + this.itemId = json.itemId; + this.name = json.name; + this.loadoutsIcon = json.loadoutsIcon; + this.description = json.description; + this.level = json.level; + this.speciesName = json.speciesName; + this.speciesId = json.speciesId; + this.rarity = json.rarity; + } + + getLoadoutsIcon(version: string): string { + return this.resolveGamePath({path: this.loadoutsIcon, version: version}); + } } \ No newline at end of file