Add models for loot

This commit is contained in:
BlossomiShymae
2024-06-12 17:25:29 -05:00
parent be8d898947
commit c55aa7cf6c
2 changed files with 36 additions and 1 deletions

View File

@@ -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();
}
}
@@ -86,3 +88,10 @@ export class CompanionsApi extends ApiObject {
return res.data.map((x: any) => new Companion(x));
}
}
export class LootApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<Loot>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/loot.json`);
return res.data['LootItems'].map((x: any) => new Loot(x));
}
}

View File

@@ -322,3 +322,29 @@ export class Companion extends CommunityDragonObject {
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}});
}
}