From 7f952cf5604cdea9b0f029c4d5011fa42c4e9d82 Mon Sep 17 00:00:00 2001 From: BlossomiShymae <87099578+BlossomiShymae@users.noreply.github.com> Date: Thu, 12 Sep 2024 21:13:27 -0500 Subject: [PATCH] Add models and apis to client --- core/client.ts | 47 +++++++++++++++++- core/models.ts | 132 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+), 1 deletion(-) diff --git a/core/client.ts b/core/client.ts index ed682b6..5faa628 100644 --- a/core/client.ts +++ b/core/client.ts @@ -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> { + 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> { + 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> { + 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> { + 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> { + let res = await axios.get(`${this.getClientPath(args)}/v1/tftdamageskins.json`); + return res.data.map((x: any) => new TftDamageSkin(x)); + } } \ No newline at end of file diff --git a/core/models.ts b/core/models.ts index 2e4d72e..2e14dda 100644 --- a/core/models.ts +++ b/core/models.ts @@ -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; + + 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}); + } } \ No newline at end of file