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";
|
||||
|
||||
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<Array<Loot>> {
|
||||
let res = await axios.get(`${this.getClientPath(args)}/v1/loot.json`);
|
||||
return res.data['LootItems'].map((x: any) => new Loot(x));
|
||||
}
|
||||
}
|
||||
@@ -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}});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user