Add models and apis to client

This commit is contained in:
BlossomiShymae
2024-09-12 21:13:27 -05:00
parent 41d937ae6f
commit 7f952cf560
2 changed files with 178 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
import { Champion, ChampionSummary, Item, LocaleVersionArgs, Perk, SummonerEmote, SummonerIcon, WardSkin, Companion, Loot } from './models';
import { Champion, ChampionSummary, Item, LocaleVersionArgs, Perk, SummonerEmote, SummonerIcon, WardSkin, Companion, Loot, CherryAugment, Universe, TftItem, TftMapSkin, TftDamageSkin } from './models';
import axios from "axios";
export abstract class ApiObject {
@@ -19,6 +19,11 @@ export class Client {
public wardSkins: WardSkinApi;
public companions: CompanionsApi;
public loots: LootApi;
public cherryAugments: CherryAugmentApi;
public universes: UniverseApi;
public tftItems: TftItemApi;
public tftMapSkins: TftMapSkinApi;
public tftDamageSkins: TftDamageSkinApi;
constructor() {
this.items = new ItemApi();
@@ -30,6 +35,11 @@ export class Client {
this.wardSkins = new WardSkinApi();
this.companions = new CompanionsApi();
this.loots = new LootApi();
this.cherryAugments = new CherryAugmentApi();
this.universes = new UniverseApi();
this.tftItems = new TftItemApi();
this.tftMapSkins = new TftMapSkinApi();
this.tftDamageSkins = new TftDamageSkinApi();
}
}
@@ -94,4 +104,39 @@ export class LootApi extends ApiObject {
let res = await axios.get(`${this.getClientPath(args)}/v1/loot.json`);
return res.data['LootItems'].map((x: any) => new Loot(x));
}
}
export class CherryAugmentApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<CherryAugment>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/cherry-augments.json`);
return res.data.map((x: any) => new CherryAugment(x));
}
}
export class UniverseApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<Universe>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/universes.json`);
return res.data.map((x: any) => new Universe(x));
}
}
export class TftItemApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<TftItem>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/tftitems.json`);
return res.data.map((x: any) => new TftItem(x));
}
}
export class TftMapSkinApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<TftMapSkin>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/tftmapskins.json`);
return res.data.map((x: any) => new TftMapSkin(x));
}
}
export class TftDamageSkinApi extends ApiObject {
async listAsync(args: LocaleVersionArgs): Promise<Array<TftDamageSkin>> {
let res = await axios.get(`${this.getClientPath(args)}/v1/tftdamageskins.json`);
return res.data.map((x: any) => new TftDamageSkin(x));
}
}

View File

@@ -347,4 +347,136 @@ export class Loot extends CommunityDragonObject {
getImage(version: string): string {
return this.resolveClientPath({path: this.image, args: {locale: "default", version: version}});
}
}
export class CherryAugment extends CommunityDragonObject {
id: number;
nameTRA: string;
augmentSmallIconPath: string;
rarity: string;
constructor(json: any) {
super();
this.id = json.id;
this.nameTRA = json.nameTRA;
this.augmentSmallIconPath = json.augmentSmallIconPath;
this.rarity = json.rarity;
}
getAugmentSmallIcon(version: string): string {
return this.resolveGamePath({path: this.augmentSmallIconPath, version: version});
}
}
export class Universe extends CommunityDragonObject {
id: number;
name: string;
description: string;
skinSets: Array<number>;
constructor(json: any) {
super();
this.id = json.id;
this.name = json.name;
this.description = json.description;
this.skinSets = json.skinSets;
}
}
export class TftItem extends CommunityDragonObject {
guid: string;
name: string;
nameId: string;
id: number;
color: Color;
squareIconPath: string;
constructor(json: any) {
super();
this.guid = json.guid;
this.name = json.name;
this.nameId = json.nameId;
this.id = json.id;
this.color = new Color(json.color);
this.squareIconPath = json.squareIconPath;
}
getSquareIcon(version: string): string {
return this.resolveGamePath({path: this.squareIconPath, version: version});
}
}
export class Color extends CommunityDragonObject {
R: number;
B: number;
G: number;
A: number;
constructor(json: any) {
super();
this.R = json.R;
this.B = json.B;
this.G = json.G;
this.A = json.A;
}
}
export class TftMapSkin extends CommunityDragonObject {
contentId: string;
itemId: number;
name: string;
loadoutsIcon: string;
groupId: number;
groupName: string;
rarity: string;
rarityValue: number;
constructor(json: any) {
super();
this.contentId = json.contentId;
this.itemId = json.itemId;
this.name = json.name;
this.loadoutsIcon = json.loadoutsIcon;
this.groupId = json.groupId;
this.groupName = json.groupName;
this.rarity = json.rarity;
this.rarityValue = json.rarityValue;
}
getLoadoutsIcon(version: string): string {
return this.resolveGamePath({path: this.loadoutsIcon, version: version});
}
}
export class TftDamageSkin extends CommunityDragonObject {
contentId: string;
itemId: number;
name: string;
loadoutsIcon: string;
groupId: number;
rarity: string;
rarityValue: number;
level: number;
constructor(json: any) {
super();
this.contentId = json.contentId;
this.itemId = json.itemId;
this.name = json.name;
this.loadoutsIcon = json.loadoutsIcon;
this.groupId = json.groupId;
this.rarity = json.rarity;
this.rarityValue = json.rarityValue;
this.level = json.level;
}
getLoadoutsIcon(version: string): string {
return this.resolveGamePath({path: this.loadoutsIcon, version: version});
}
}