mirror of
https://github.com/BlossomiShymae/clean-cuts.git
synced 2025-12-06 10:10:47 +01:00
Add models and apis to client
This commit is contained in:
@@ -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";
|
import axios from "axios";
|
||||||
|
|
||||||
export abstract class ApiObject {
|
export abstract class ApiObject {
|
||||||
@@ -19,6 +19,11 @@ export class Client {
|
|||||||
public wardSkins: WardSkinApi;
|
public wardSkins: WardSkinApi;
|
||||||
public companions: CompanionsApi;
|
public companions: CompanionsApi;
|
||||||
public loots: LootApi;
|
public loots: LootApi;
|
||||||
|
public cherryAugments: CherryAugmentApi;
|
||||||
|
public universes: UniverseApi;
|
||||||
|
public tftItems: TftItemApi;
|
||||||
|
public tftMapSkins: TftMapSkinApi;
|
||||||
|
public tftDamageSkins: TftDamageSkinApi;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.items = new ItemApi();
|
this.items = new ItemApi();
|
||||||
@@ -30,6 +35,11 @@ export class Client {
|
|||||||
this.wardSkins = new WardSkinApi();
|
this.wardSkins = new WardSkinApi();
|
||||||
this.companions = new CompanionsApi();
|
this.companions = new CompanionsApi();
|
||||||
this.loots = new LootApi();
|
this.loots = new LootApi();
|
||||||
|
this.cherryAugments = new CherryAugmentApi();
|
||||||
|
this.universes = new UniverseApi();
|
||||||
|
this.tftItems = new TftItemApi();
|
||||||
|
this.tftMapSkins = new TftMapSkinApi();
|
||||||
|
this.tftDamageSkins = new TftDamageSkinApi();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,3 +105,38 @@ export class LootApi extends ApiObject {
|
|||||||
return res.data['LootItems'].map((x: any) => new Loot(x));
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
132
core/models.ts
132
core/models.ts
@@ -348,3 +348,135 @@ export class Loot extends CommunityDragonObject {
|
|||||||
return this.resolveClientPath({path: this.image, args: {locale: "default", version: version}});
|
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});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user