diff --git a/core/client.ts b/core/client.ts index 7c06767..ed682b6 100644 --- a/core/client.ts +++ b/core/client.ts @@ -1,4 +1,4 @@ -import { Champion, ChampionSummary, Item, LocaleVersionArgs, Perk, SummonerEmote, SummonerIcon, WardSkin, Companion } from './models'; +import { Champion, ChampionSummary, Item, LocaleVersionArgs, Perk, SummonerEmote, SummonerIcon, WardSkin, Companion, Loot } from './models'; import axios from "axios"; export abstract class ApiObject { @@ -18,6 +18,7 @@ export class Client { public summonerIcons: SummonerIconApi; public wardSkins: WardSkinApi; public companions: CompanionsApi; + public loots: LootApi; constructor() { this.items = new ItemApi(); @@ -28,6 +29,7 @@ export class Client { this.summonerIcons = new SummonerIconApi(); this.wardSkins = new WardSkinApi(); this.companions = new CompanionsApi(); + this.loots = new LootApi(); } } @@ -85,4 +87,11 @@ export class CompanionsApi extends ApiObject { let res = await axios.get(`${this.getClientPath(args)}/v1/companions.json`); return res.data.map((x: any) => new Companion(x)); } +} + +export class LootApi extends ApiObject { + async listAsync(args: LocaleVersionArgs): Promise> { + let res = await axios.get(`${this.getClientPath(args)}/v1/loot.json`); + return res.data['LootItems'].map((x: any) => new Loot(x)); + } } \ No newline at end of file diff --git a/core/models.ts b/core/models.ts index 285e30a..2e4d72e 100644 --- a/core/models.ts +++ b/core/models.ts @@ -321,4 +321,30 @@ export class Companion extends CommunityDragonObject { getLoadoutsIcon(version: string): string { return this.resolveClientPath({path: this.loadoutsIcon, args: {locale: "default", version: version}}); } +} + +export class Loot extends CommunityDragonObject { + id: string; + name: string; + description: string; + image: string; + mappedStoreId: number; + rarity: string; + type: string; + + constructor(json: any) { + super(); + + this.id = json.id; + this.name = json.name; + this.description = json.description; + this.image = json.image; + this.mappedStoreId = json.mappedStoreId; + this.rarity = json.rarity; + this.type = json.type; + } + + getImage(version: string): string { + return this.resolveClientPath({path: this.image, args: {locale: "default", version: version}}); + } } \ No newline at end of file