diff --git a/src/enum/clan.enum.ts b/src/enum/clan.enum.ts new file mode 100644 index 0000000..6144b13 --- /dev/null +++ b/src/enum/clan.enum.ts @@ -0,0 +1,5 @@ +export enum ClanRole { + Master = 'MASTER', + Officer = 'OFFICER', + Regular = 'REGULAR', +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index f396e3e..b525413 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,9 @@ import axios from "axios"; import { Endpoint, Server } from "./enum/common.enum"; +import { Clan } from "./interfaces/clan.interface"; import { Achievement } from "./interfaces/common.interface"; +import { Player } from "./interfaces/player.interface"; +import { Top } from "./interfaces/top.interface"; import formatService from "./services/format.service"; export class WFApi { @@ -43,7 +46,7 @@ export class WFApi { }); } - async getTop100(server: Server) { + async getTop100(server: Server): Promise { return new Promise(async (resolve, reject) => { if(!server) { return reject('no_server_specified'); @@ -60,7 +63,7 @@ export class WFApi { }); } - async getPlayer(name: string, server: Server | null = null) { + async getPlayer(name: string, server: Server | null = null): Promise { return new Promise(async (resolve, reject) => { if(!name) { reject(new Error('nickname_not_specified')); @@ -102,7 +105,7 @@ export class WFApi { }); } - async getClan(name: string, server: Server | null = null) { + async getClan(name: string, server: Server | null = null): Promise { return new Promise(async (resolve, reject) => { if(!name) { reject('name_is_not_specified'); diff --git a/src/interfaces/clan.interface.ts b/src/interfaces/clan.interface.ts new file mode 100644 index 0000000..03243cf --- /dev/null +++ b/src/interfaces/clan.interface.ts @@ -0,0 +1,14 @@ +import { ClanRole } from "../enum/clan.enum"; + +export interface ClanMember { + nickname: string; + rank_id: string; + clan_points: string; + clan_role: ClanRole; +} + +export interface Clan { + id: string; + name: string; + members: ClanMember[]; +} diff --git a/src/interfaces/player.interface.ts b/src/interfaces/player.interface.ts new file mode 100644 index 0000000..d6e743d --- /dev/null +++ b/src/interfaces/player.interface.ts @@ -0,0 +1,34 @@ +import { Achievement } from "./common.interface"; + +export interface Player { + user_id?: string; + nickname?: string; + experience?: number; + rank_id?: number; + clan_id?: number; + clan_name?: string; + kill?: number; + friendly_kills?: number; + kills?: number; + death?: number; + pvp?: number; + pve_kill?: number; + pve_friendly_kills?: number; + pve_kills?: number; + pve_death?: number; + pve?: number; + playtime?: number; + playtime_h?: number; + playtime_m?: number; + favoritPVP?: string; + favoritPVE?: string; + pve_wins?: number; + pvp_wins?: number; + pvp_lost?: number; + pve_lost?: number; + pve_all?: number; + pvp_all?: number; + pvp_wl?: number; + full_player?: Record; + achievements?: Achievement[]; +} \ No newline at end of file diff --git a/src/interfaces/top.interface.ts b/src/interfaces/top.interface.ts new file mode 100644 index 0000000..5f26d3e --- /dev/null +++ b/src/interfaces/top.interface.ts @@ -0,0 +1,6 @@ +export interface Top { + nickname: string; + clan: string; + class: string; + shard: string; +} \ No newline at end of file diff --git a/src/services/format.service.ts b/src/services/format.service.ts index ee81b0f..874863c 100644 --- a/src/services/format.service.ts +++ b/src/services/format.service.ts @@ -1,11 +1,13 @@ import { Server } from "../enum/common.enum"; +import { Achievement } from "../interfaces/common.interface"; +import { Player } from "../interfaces/player.interface"; export class formatService { getMatch(el: any, regexp: any) { return el.match(regexp)[0].trim(); } - format(playerData: any, achievements: any, server: Server) { + format(playerData: Partial, achievements: Achievement[], server: Server) { let player = playerData; const full_player = parseFullResponse(player['full_response']); delete player['full_response']; @@ -14,7 +16,7 @@ export class formatService { server, player, full_player, - achievements + achievements, }; }