mirror of
https://github.com/BlossomiShymae/clean-cuts.git
synced 2025-12-06 10:10:47 +01:00
Add models for loot
This commit is contained in:
@@ -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";
|
import axios from "axios";
|
||||||
|
|
||||||
export abstract class ApiObject {
|
export abstract class ApiObject {
|
||||||
@@ -18,6 +18,7 @@ export class Client {
|
|||||||
public summonerIcons: SummonerIconApi;
|
public summonerIcons: SummonerIconApi;
|
||||||
public wardSkins: WardSkinApi;
|
public wardSkins: WardSkinApi;
|
||||||
public companions: CompanionsApi;
|
public companions: CompanionsApi;
|
||||||
|
public loots: LootApi;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.items = new ItemApi();
|
this.items = new ItemApi();
|
||||||
@@ -28,6 +29,7 @@ export class Client {
|
|||||||
this.summonerIcons = new SummonerIconApi();
|
this.summonerIcons = new SummonerIconApi();
|
||||||
this.wardSkins = new WardSkinApi();
|
this.wardSkins = new WardSkinApi();
|
||||||
this.companions = new CompanionsApi();
|
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));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -322,3 +322,29 @@ export class Companion extends CommunityDragonObject {
|
|||||||
return this.resolveClientPath({path: this.loadoutsIcon, args: {locale: "default", version: version}});
|
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}});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user