From 1f3c8c2ea60db6a896c7c159c1f3b63312fc36f0 Mon Sep 17 00:00:00 2001 From: GardZock Date: Sun, 20 Feb 2022 19:38:51 -0300 Subject: [PATCH 1/8] World of Warships ADD --- .../world-of-warships/src/functions/ship.ts | 21 +++++ .../world-of-warships/src/functions/user.ts | 43 +++++++++ .../src/interfaces/ships/data.ts | 69 ++++++++++++++ .../src/interfaces/user/result.ts | 93 +++++++++++++++++++ 4 files changed, 226 insertions(+) create mode 100644 packages/wargaming/world-of-warships/src/functions/ship.ts create mode 100644 packages/wargaming/world-of-warships/src/functions/user.ts create mode 100644 packages/wargaming/world-of-warships/src/interfaces/ships/data.ts create mode 100644 packages/wargaming/world-of-warships/src/interfaces/user/result.ts diff --git a/packages/wargaming/world-of-warships/src/functions/ship.ts b/packages/wargaming/world-of-warships/src/functions/ship.ts new file mode 100644 index 0000000..d928c33 --- /dev/null +++ b/packages/wargaming/world-of-warships/src/functions/ship.ts @@ -0,0 +1,21 @@ +import { BaseClass } from "../../../../../builds/class/base"; +import axios from "axios"; +import { WOWSShipResolve } from '../interfaces/ships/data' + +class WOWSShip extends BaseClass { + + app: { id: string } + constructor(app_id: string) { + super(app_id) + this.app = { id: app_id } + } + + public async get(tankID: string | number): Promise { + var data = await (await axios.get(`https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data + if (data.status == "error") return null + + return data.data[tankID] + } +} + +export { WOWSShip } \ No newline at end of file diff --git a/packages/wargaming/world-of-warships/src/functions/user.ts b/packages/wargaming/world-of-warships/src/functions/user.ts new file mode 100644 index 0000000..d6a2d43 --- /dev/null +++ b/packages/wargaming/world-of-warships/src/functions/user.ts @@ -0,0 +1,43 @@ +import axios from 'axios' + +import { UserSearchResolve } from '../../../build/interfaces/search-resolve' +import { BaseClass } from '../../../../../builds/class/base' + +import { WOWSUserResolve } from '../interfaces/user/result' + +class WorldOfWarShipsUser extends BaseClass { + + app: { id: string } + constructor(app_id: string) { + super(app_id) + this.app = { id: app_id } + } + + /** + * Search users with respective name. + * @param userName Name of user. + * @returns {Object[]} Object Array with users data. + */ + + public async search(userName: string): Promise { + const searchUser = await ((await axios.get(`https://api.worldofwarships.com/wows/account/list/?application_id=${this.app?.id}&search=${userName}`)).data).data + if (!searchUser || searchUser.length <= 0) return null + return searchUser + } + + /** + * Get an user by ID. + * @param userID ID of user. + * @returns {Object} Object of user data. + */ + + public async get(userID: number | string): Promise { + let data = await (await axios.get(`https://api.worldofwarships.com/wows/account/info/?application_id=${this.app?.id}&account_id=${userID}`)).data + if (data.status == "error") return null + data = data.data[userID] + + return data; + } +} + +export { WorldOfWarShipsUser } \ No newline at end of file diff --git a/packages/wargaming/world-of-warships/src/interfaces/ships/data.ts b/packages/wargaming/world-of-warships/src/interfaces/ships/data.ts new file mode 100644 index 0000000..1d9d8bb --- /dev/null +++ b/packages/wargaming/world-of-warships/src/interfaces/ships/data.ts @@ -0,0 +1,69 @@ +interface WOWSShipResolve { + pvp: { + max_xp: number | null, + damage_to_buildings: number | null, + main_battery: { + max_frags_battle: number | null, + frags: number | null, + hits: number | null, + shots: number | null + }, + suppressions_count: number | null, + max_damage_scouting: number | null, + art_agro: number | null, + ships_spotted: number | null, + second_battery: { + max_frags_battle: number | null, + frags: number | null, + hits: number | null, + shots: number | null + }, + xp: number | null, + survived_battles: number | null, + dropped_capture_points: number | null, + max_damage_dealt_to_buildings: number | null, + torpedo_agro: number | null, + draws: number | null, + battles_since_510: number | null, + planes_killed: number | null, + battles: number | null, + max_ships_spotted: number | null, + team_capture_points: number | null, + frags: number | null, + damage_scouting: number | null, + max_total_agro: number | null, + max_frags_battle: number | null, + capture_points: number | null, + ramming: { + max_frags_battle: number | null, + frags: number | null + }, + torpedoes: { + max_frags_battle: number | null, + frags: number | null, + hits: number | null, + shots: number | null + }, + aircraft: { + max_frags_battle: number | null, + frags: number | null + }, + survived_wins: number | null, + max_damage_dealt: number | null, + wins: number | null, + losses: number | null, + damage_dealt: number | null, + max_planes_killed: number | null, + max_suppressions_count: number | null, + team_dropped_capture_points: number | null, + battles_since_512: number | null + }, + last_battle_time: number | null, + account_id: number | null, + distance: number | null, + updated_at: number | null, + battles: number | null, + ship_id: number | null +} + +export { WOWSShipResolve } \ No newline at end of file diff --git a/packages/wargaming/world-of-warships/src/interfaces/user/result.ts b/packages/wargaming/world-of-warships/src/interfaces/user/result.ts new file mode 100644 index 0000000..00607b7 --- /dev/null +++ b/packages/wargaming/world-of-warships/src/interfaces/user/result.ts @@ -0,0 +1,93 @@ +interface WOWSUserResolve { + last_battle_time: number | null, + account_id: number | null, + leveling_tier: number | null, + created_at: number | null, + leveling_points: number | null, + updated_at: number | null, + hidden_profile: boolean | null, + logout_at: number | null, + statistics: { + distance: number | null, + battles: number | null, + pvp: { + max_xp: number | null, + damage_to_buildings: number | null, + main_battery: { + max_frags_battle: number | null, + frags: number | null, + hits: number | null, + max_frags_ship_id: number | null, + shots: number | null + }, + max_ships_spotted_ship_id: number | null, + max_damage_scouting: number | null, + art_agro: number | null, + max_xp_ship_id: number | null, + ships_spotted: number | null, + second_battery: { + max_frags_battle: number | null, + frags: number | null, + hits: number | null, + max_frags_ship_id: number | null, + shots: number | null + }, + max_frags_ship_id: number | null, + xp: number | null, + survived_battles: number | null, + dropped_capture_points: number | null, + max_damage_dealt_to_buildings: number | null, + torpedo_agro: number | null, + draws: number | null, + control_captured_points: number | null, + battles_since_510: number | null, + max_total_agro_ship_id: number | null, + planes_killed: number | null, + battles: number | null, + max_ships_spotted: number | null, + max_suppressions_ship_id: number | null, + survived_wins: number | null, + frags: number | null, + damage_scouting: number | null, + max_total_agro: number | null, + max_frags_battle: number | null, + capture_points: number | null, + ramming: { + max_frags_battle: number | null, + frags: number | null, + max_frags_ship_id: number | null + }, + suppressions_count: number | null, + max_suppressions_count: number | null, + torpedoes: { + max_frags_battle: number | null, + frags: number | null, + hits: number | null, + max_frags_ship_id: number | null, + shots: number | null + }, + max_planes_killed_ship_id: number | null, + aircraft: { + max_frags_battle: number | null, + frags: number | null, + max_frags_ship_id: number | null + }, + team_capture_points: number | null, + control_dropped_points: number | null, + max_damage_dealt: number | null, + max_damage_dealt_to_buildings_ship_id: number | null, + max_damage_dealt_ship_id: number | null, + wins: number | null, + losses: number | null, + damage_dealt: number | null, + max_planes_killed: number | null, + max_scouting_damage_ship_id: number | null, + team_dropped_capture_points: number | null, + battles_since_512: number | null + } + }, + nickname: string | null, + stats_updated_at: number | null +} + +export { WOWSUserResolve } \ No newline at end of file From 781d974cff2c067bd5a237788fd792bdfbfeb7fe Mon Sep 17 00:00:00 2001 From: GardZock Date: Sun, 20 Feb 2022 19:43:54 -0300 Subject: [PATCH 2/8] Package.json updates --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index a14233d..5b17734 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { "name": "warcord", - "version": "0.2.8", - "description": "A Simple lib for discord with wargaming API", - "author": "Flaming-Eyes", - "license": "SEE LICENSE IN LICENSE", + "version": "0.3.8", + "description": "A Simple lib with wargaming API", + "author": "GardZock", + "license": "Apache 2.0", "main": "dist/warcord/index.js", "types": "dist/warcord/index.d.ts", "scripts": { @@ -12,12 +12,12 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/Flaming-Eyes-Store/WarCord.git" + "url": "git+https://github.com/Warcord/WarCord-Lib.git" }, "bugs": { - "url": "https://github.com/Flaming-Eyes-Store/WarCord/issues" + "url": "https://github.com/Warcord/WarCord-Lib/issues" }, - "homepage": "https://github.com/Flaming-Eyes-Store/WarCord#readme", + "homepage": "https://github.com/Warcord/WarCord-Lib#readme", "devDependencies": { "@types/ms": "^0.7.31", "@types/node": "^17.0.18", From 5ff6b1c35fc27abf96e474475cf1c809dccd1796 Mon Sep 17 00:00:00 2001 From: GardZock Date: Tue, 22 Feb 2022 23:11:02 -0300 Subject: [PATCH 3/8] Addition and Fixes for Ships --- dist/builds/class/base.d.ts | 4 ++++ packages/wargaming/build/class/base.ts | 16 ++++++++++++++-- .../world-of-warships/src/functions/ship.ts | 8 ++++---- .../world-of-warships/src/functions/user.ts | 4 ++-- 4 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 dist/builds/class/base.d.ts diff --git a/dist/builds/class/base.d.ts b/dist/builds/class/base.d.ts new file mode 100644 index 0000000..6f8b4c9 --- /dev/null +++ b/dist/builds/class/base.d.ts @@ -0,0 +1,4 @@ +declare class BaseClass { + constructor(app_id: string); +} +export { BaseClass }; diff --git a/packages/wargaming/build/class/base.ts b/packages/wargaming/build/class/base.ts index 422b53b..189feba 100644 --- a/packages/wargaming/build/class/base.ts +++ b/packages/wargaming/build/class/base.ts @@ -1,12 +1,16 @@ -import { WorldOfTanksUser } from '../../world-of-tanks/src/functions/user' +import { BaseClass } from '../../../../builds/class/base' import { WargamingApp } from '../interfaces/app' + +import { WorldOfTanksUser } from '../../world-of-tanks/src/functions/user' import { WorldOfTanksTank } from '../../world-of-tanks/src/functions/tank' import { WorldOfTanksClan } from '../../world-of-tanks/src/functions/clan' -import { BaseClass } from '../../../../builds/class/base' + import { WOTBUser } from '../../world-of-tanks-blitz/src/functions/user' import { WOTBTank } from '../../world-of-tanks-blitz/src/functions/tank' import { WOTBClan } from '../../world-of-tanks-blitz/src/functions/clan' +import { WOWSUser } from '../../world-of-warships/src/functions/user' +import { WOWSShip } from '../../world-of-warships/src/functions/ship' class WargamingBase extends BaseClass implements WargamingApp { app: { id: string } @@ -20,6 +24,10 @@ class WargamingBase extends BaseClass implements WargamingApp { tank: WOTBTank, clan: WOTBClan } + wows: { + user: WOWSUser, + ship: WOWSShip + } constructor(app_id: string) { super(app_id) @@ -34,6 +42,10 @@ class WargamingBase extends BaseClass implements WargamingApp { tank: new WOTBTank(app_id), clan: new WOTBClan(app_id) } + this.wows = { + user: new WOWSUser(app_id), + ship: new WOWSShip(app_id) + } } } diff --git a/packages/wargaming/world-of-warships/src/functions/ship.ts b/packages/wargaming/world-of-warships/src/functions/ship.ts index d928c33..9f1e8e5 100644 --- a/packages/wargaming/world-of-warships/src/functions/ship.ts +++ b/packages/wargaming/world-of-warships/src/functions/ship.ts @@ -10,11 +10,11 @@ class WOWSShip extends BaseClass { this.app = { id: app_id } } - public async get(tankID: string | number): Promise { - var data = await (await axios.get(`https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data - if (data.status == "error") return null + public async get(userID: string | number): Promise { + var data = await (await axios.get(`https://api.worldofwarships.com/wows/ships/stats/?application_id=${this.app.id}&account_id=${userID}`)).data + if (data.status == "error") return null; - return data.data[tankID] + return data.data[userID] } } diff --git a/packages/wargaming/world-of-warships/src/functions/user.ts b/packages/wargaming/world-of-warships/src/functions/user.ts index d6a2d43..dddcb20 100644 --- a/packages/wargaming/world-of-warships/src/functions/user.ts +++ b/packages/wargaming/world-of-warships/src/functions/user.ts @@ -5,7 +5,7 @@ import { BaseClass } from '../../../../../builds/class/base' import { WOWSUserResolve } from '../interfaces/user/result' -class WorldOfWarShipsUser extends BaseClass { +class WOWSUser extends BaseClass { app: { id: string } constructor(app_id: string) { @@ -40,4 +40,4 @@ class WorldOfWarShipsUser extends BaseClass { } } -export { WorldOfWarShipsUser } \ No newline at end of file +export { WOWSUser } \ No newline at end of file From 51db8310449f83d063722f3e4fdeefdc5edf7cda Mon Sep 17 00:00:00 2001 From: GardZock Date: Tue, 22 Feb 2022 23:26:05 -0300 Subject: [PATCH 4/8] NEW DOCS --- README.md | 38 +++++++++++++++++++++++++++++++++++--- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 107ba03..57e5348 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ const warcord = new Warcord('your-app-id') ``` # Useful Links -- Discord Server (In creation) +- Discord Server (canceled) # Credits @@ -43,6 +43,14 @@ const warcord = new Warcord('your-app-id') - [Tank](#tank-wotb) - [Getting a tank by ID](#getting-a-tank-by-id-wotb) +> World of WarShips +- [User](#user-wows) + - [Getting user by ID](#searching-a-user-by-id-wows) + - [Searching user by name](#searching-a-user-by-name-wows) +- [Ships](#ship-wows) + - [Getting ships by User ID](#getting-ships-status-by-id-wows) + + # World Of Tanks Functions ## User Wot @@ -116,8 +124,7 @@ const tank = await warcord.wargaming.blitz.tank.get('ID of Tank') //this returns an Object with tank data. ``` - - +# World of Tanks Blitz Functions ## User Wotb @@ -178,4 +185,29 @@ const clan = await warcord.wargaming.blitz.clan.get(searchingClan[0].clan_id) ... const tank = await warcord.wargaming.blitz.tank.get('ID of Tank') //this returns an Object with tank data. +``` + +# World of WarShips Functions + +## User + +### Getting user by ID WOWS +```js +... +const user = await warcord.wargaming.wows.user.get('ID of User') +//this returns user data. +``` + +### Searching user by name WOWS +```js +... +const user = await warcord.wargaming.wows.user.search('Name of User') +//this returns user ID and Name. +``` + +### Getting ships status by User ID +```js +... +const ships = await warcord.wargaming.wows.ship.get('ID of User') +//this returns an Array with Ships Status. ``` \ No newline at end of file From bb023e0ad68384b79a8d70628c7a3ce1528fda3c Mon Sep 17 00:00:00 2001 From: GardZock Date: Wed, 23 Feb 2022 00:21:09 -0300 Subject: [PATCH 5/8] Addition of clan on Warships and LANG CHANGE --- index.ts | 26 +++++++-- packages/wargaming/build/class/base.ts | 9 ++-- .../src/functions/clan.ts | 26 +++++++++ .../src/functions/tank.ts | 21 ++++++++ .../src/functions/user.ts | 47 ++++++++++++++++ .../src/interfaces/clan/clan-resolve.ts | 31 +++++++++++ .../src/interfaces/tank/tank-resolve.ts | 21 ++++++++ .../src/interfaces/tank/tank-top.ts | 33 ++++++++++++ .../src/interfaces/user/user-return.ts | 53 +++++++++++++++++++ .../world-of-tanks/src/functions/clan.ts | 12 ++--- .../world-of-tanks/src/functions/tank.ts | 8 +-- .../world-of-tanks/src/functions/user.ts | 12 ++--- .../world-of-warships/src/functions/clan.ts | 41 ++++++++++++++ .../world-of-warships/src/functions/ship.ts | 8 +-- .../world-of-warships/src/functions/user.ts | 10 ++-- .../src/interfaces/clan/clan-resolve.ts | 20 +++++++ .../src/interfaces/clan/search-resolve.ts | 9 ++++ 17 files changed, 354 insertions(+), 33 deletions(-) create mode 100644 packages/wargaming/world-of-tanks-blitz/src/functions/clan.ts create mode 100644 packages/wargaming/world-of-tanks-blitz/src/functions/tank.ts create mode 100644 packages/wargaming/world-of-tanks-blitz/src/functions/user.ts create mode 100644 packages/wargaming/world-of-tanks-blitz/src/interfaces/clan/clan-resolve.ts create mode 100644 packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-resolve.ts create mode 100644 packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-top.ts create mode 100644 packages/wargaming/world-of-tanks-blitz/src/interfaces/user/user-return.ts create mode 100644 packages/wargaming/world-of-warships/src/functions/clan.ts create mode 100644 packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.ts create mode 100644 packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.ts diff --git a/index.ts b/index.ts index 7ea5d23..4869b52 100644 --- a/index.ts +++ b/index.ts @@ -10,17 +10,18 @@ import { BaseClass } from './builds/class/base' class WarCord extends BaseClass { app: { - id: string + id: string, + lang?: string } wargaming: WargamingBase - constructor(app_id: string) { + constructor(app_id: string, lang?: string) { super(app_id) - this.app = { id: this.checker(app_id) } - this.wargaming = new WargamingBase(app_id) + this.app = { id: this.idChecker(app_id), lang: this.langChecker(lang) } + this.wargaming = new WargamingBase(app_id, lang) } - private checker(id: string): string { + private idChecker(id: string): string { if (!id || id.length <= 0) { console.log('[WarCord] Your API ID is empty. (using Wargaming API)') return '' @@ -28,6 +29,21 @@ class WarCord extends BaseClass { return id } } + + private langChecker(lang: string | undefined): string { + if (!lang) return 'com' + const langs = [ + 'na', + 'eu', + 'ru', + 'asia' + ] + + if (!langs.includes(lang)) { console.log('[WarCord] Your API Lang is not valid. (using Wargaming API)'); return 'com' } + if (lang = 'na') lang = 'com' + + return lang + } } //Main class export diff --git a/packages/wargaming/build/class/base.ts b/packages/wargaming/build/class/base.ts index 189feba..1370ba5 100644 --- a/packages/wargaming/build/class/base.ts +++ b/packages/wargaming/build/class/base.ts @@ -13,7 +13,10 @@ import { WOWSUser } from '../../world-of-warships/src/functions/user' import { WOWSShip } from '../../world-of-warships/src/functions/ship' class WargamingBase extends BaseClass implements WargamingApp { - app: { id: string } + app: { + id: string, + lang?: string + } wot: { user: WorldOfTanksUser, tank: WorldOfTanksTank, @@ -29,9 +32,9 @@ class WargamingBase extends BaseClass implements WargamingApp { ship: WOWSShip } - constructor(app_id: string) { + constructor(app_id: string, lang?: string) { super(app_id) - this.app = { id: app_id } + this.app = { id: app_id, lang: lang } this.wot = { user: new WorldOfTanksUser(app_id), tank: new WorldOfTanksTank(app_id), diff --git a/packages/wargaming/world-of-tanks-blitz/src/functions/clan.ts b/packages/wargaming/world-of-tanks-blitz/src/functions/clan.ts new file mode 100644 index 0000000..2cbbc16 --- /dev/null +++ b/packages/wargaming/world-of-tanks-blitz/src/functions/clan.ts @@ -0,0 +1,26 @@ +import { BaseClass } from "../../../../../builds/class/base"; +import axios from "axios"; +import { WOTBClanResolve } from '../interfaces/clan/clan-resolve' + +class WOTBClan extends BaseClass { + + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { + super(app_id) + this.app = { id: app_id, lang: lang } + } + + public async get(clanID: string | number): Promise { + let data = await (await axios.get(`https://api.wotblitz.${this.app.lang}/wotb/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data + if (data.status == "error") return null + return data.data[clanID] + } + + public async search(clanNameOrTag: string): Promise { + let data = await (await axios.get(`https://api.wotblitz.${this.app.lang}/wotb/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data + if (data.status == "error" || data.data.length <= 0) return null + return data.data + } +} + +export { WOTBClan } \ No newline at end of file diff --git a/packages/wargaming/world-of-tanks-blitz/src/functions/tank.ts b/packages/wargaming/world-of-tanks-blitz/src/functions/tank.ts new file mode 100644 index 0000000..d6aabb7 --- /dev/null +++ b/packages/wargaming/world-of-tanks-blitz/src/functions/tank.ts @@ -0,0 +1,21 @@ +import { BaseClass } from "../../../../../builds/class/base"; +import axios from "axios"; +import { WOTBTankResolve } from '../interfaces/tank/tank-resolve' + +class WOTBTank extends BaseClass { + + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { + super(app_id) + this.app = { id: app_id, lang: lang } + } + + public async get(tankID: string | number): Promise { + var data = await (await axios.get(`https://api.wotblitz.${this.app.lang}/wotb/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data + if (data.status == "error") return null + + return data.data[tankID] + } +} + +export { WOTBTank } \ No newline at end of file diff --git a/packages/wargaming/world-of-tanks-blitz/src/functions/user.ts b/packages/wargaming/world-of-tanks-blitz/src/functions/user.ts new file mode 100644 index 0000000..18df30d --- /dev/null +++ b/packages/wargaming/world-of-tanks-blitz/src/functions/user.ts @@ -0,0 +1,47 @@ +import { BaseClass } from "../../../../../builds/class/base"; +import axios from "axios"; +import { WOTBUserResolve } from '../interfaces/user/user-return'; +import { UserSearchResolve } from '../../../build/interfaces/search-resolve'; +import { WOTBTankTop } from '../interfaces/tank/tank-top' + +class WOTBUser extends BaseClass { + + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { + super(app_id) + this.app = { id: app_id, lang: lang } + } + + + public async get(userID: string | number): Promise { + let data = await (await axios.get(`https://api.wotblitz.${this.app.lang}/wotb/account/info/?application_id=${this.app.id}&account_id=${userID}`)).data + if (data.status == "error") return null + data = data.data[userID] + return { + statistics: { + clan: data.statistics.clan, + all: data.statistics.all + }, + account_id: data.account_id, + created_at: data.created_at, + last_battle_time: data.last_battle_time, + nickname: data.nickname + } + } + + public async search(userName: string): Promise { + let data = await (await axios.get(`https://api.wotblitz.${this.app.lang}/wotb/account/list/?application_id=${this.app.id}&search=${userName}`)).data + if (data.status == "error" || data.data.length <= 0) return null + return data.data + } + + public async topTanks(userID: string | number): Promise { + let data = await (await axios.get(`https://api.wotblitz.${this.app.lang}/wotb/tanks/stats/?application_id=${this.app.id}&account_id=${userID}`)).data + if (data.status == "error" || data.data.length <= 0) return null + data = data.data[userID] + data.length = 5 + return data + } +} + +export { WOTBUser } \ No newline at end of file diff --git a/packages/wargaming/world-of-tanks-blitz/src/interfaces/clan/clan-resolve.ts b/packages/wargaming/world-of-tanks-blitz/src/interfaces/clan/clan-resolve.ts new file mode 100644 index 0000000..621693f --- /dev/null +++ b/packages/wargaming/world-of-tanks-blitz/src/interfaces/clan/clan-resolve.ts @@ -0,0 +1,31 @@ +interface WOTBClanResolve { + + recruiting_options: { + vehicles_level: number | null, + wins_ratio: number | null, + average_battles_per_day: number | null, + battles: number | null, + average_damage: number | null + }, + members_count: number | null, + name: string | null, + creator_name: string | null, + clan_id: number | null, + created_at: number | null, + updated_at: number | null, + leader_name: string | null, + members_ids: number[], + recruiting_policy: string | null, + tag: string | null, + is_clan_disbanded: boolean, + old_name: string | null, + emblem_set_id: number | null, + creator_id: number | null, + motto: string | null, + renamed_at: number | null, + old_tag: string | null, + leader_id: number | null, + description: string | null +} + +export { WOTBClanResolve } \ No newline at end of file diff --git a/packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-resolve.ts b/packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-resolve.ts new file mode 100644 index 0000000..c67ec38 --- /dev/null +++ b/packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-resolve.ts @@ -0,0 +1,21 @@ +interface WOTBTankResolve { + suspensions: number[] | null, + description: string | null, + engines: number[] | null, + prices_xp: number | null, + next_tanks: any | null, + modules_tree: any, + nation: string | null, + is_premium: boolean, + images: any | null, + cost: number | null, + default_profile: any | null, + tier: number | null, + tank_id: number | null, + type: string | null, + guns: number[], + turrets: number[], + name: string | null +} + +export { WOTBTankResolve } \ No newline at end of file diff --git a/packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-top.ts b/packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-top.ts new file mode 100644 index 0000000..12cba35 --- /dev/null +++ b/packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-top.ts @@ -0,0 +1,33 @@ +interface WOTBTankTop { + + all: { + spotted: number | null, + hits: number | null, + frags: number | null, + max_xp: number | null, + wins: number | null, + losses: number | null, + capture_points: number | null, + battles: number | null, + damage_dealt: number | null, + damage_received: number | null, + max_frags: number | null, + shots: number | null, + frags8p: number | null, + xp: number | null, + win_and_survived: number | null, + survived_battles: number | null, + dropped_capture_points: number | null + }, + last_battle_time: number | null, + account_id: number | null, + max_xp: number | null, + in_garage_updated: number | null, + max_frags: number | null, + mark_of_mastery: number | null, + battle_life_time: number | null, + in_garage: number | null, + tank_id: number | null +} + +export { WOTBTankTop } \ No newline at end of file diff --git a/packages/wargaming/world-of-tanks-blitz/src/interfaces/user/user-return.ts b/packages/wargaming/world-of-tanks-blitz/src/interfaces/user/user-return.ts new file mode 100644 index 0000000..75a1b66 --- /dev/null +++ b/packages/wargaming/world-of-tanks-blitz/src/interfaces/user/user-return.ts @@ -0,0 +1,53 @@ +interface WOTBUserResolve { + + last_battle_time: number | null, + account_id: number | null, + created_at: number | null, + statistics: { + clan: { + spotted: number | null, + max_frags_tank_id: number | null, + hits: number | null, + frags: number | null, + max_xp: number | null, + max_xp_tank_id: number | null, + wins: number | null, + losses: number | null, + capture_points: number | null, + battles: number | null, + damage_dealt: number | null, + damage_received: number | null, + max_frags: number | null, + shots: number | null, + frags8p: number | null, + xp: number | null, + win_and_survived: number | null, + survived_battles: number | null, + dropped_capture_points: number | null + }, + all: { + spotted: number | null, + max_frags_tank_id: number | null, + hits: number | null, + frags: number | null, + max_xp: number | null, + max_xp_tank_id: number | null, + wins: number | null, + losses: number | null, + capture_points: number | null, + battles: number | null, + damage_dealt: number | null, + damage_received: number | null, + max_frags: number | null, + shots: number | null, + frags8p: number | null, + xp: number | null, + win_and_survived: number | null, + survived_battles: number | null, + dropped_capture_points: number | null + } + }, + nickname: string | null +} + +export { WOTBUserResolve } \ No newline at end of file diff --git a/packages/wargaming/world-of-tanks/src/functions/clan.ts b/packages/wargaming/world-of-tanks/src/functions/clan.ts index af692f9..2eb4c4d 100644 --- a/packages/wargaming/world-of-tanks/src/functions/clan.ts +++ b/packages/wargaming/world-of-tanks/src/functions/clan.ts @@ -5,10 +5,10 @@ import { BaseClass } from '../../../../../builds/class/base' class WorldOfTanksClan extends BaseClass { - app: { id: string } - constructor(app_id: string) { + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { super(app_id) - this.app = { id: app_id } + this.app = { id: app_id, lang: lang } } /** @@ -18,7 +18,7 @@ class WorldOfTanksClan extends BaseClass { */ public async get(clanID: number | string): Promise { - let data = await (await axios.get(`https://api.worldoftanks.com/wot/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data + let data = await (await axios.get(`https://api.worldoftanks.${this.app.lang}/wot/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data if (data.status == "error") return null data = data.data[clanID] return { @@ -52,7 +52,7 @@ class WorldOfTanksClan extends BaseClass { * @returns {ClanSearchResolve} Array with clan data. */ public async search(clanNameOrTag: string): Promise { - let data = await (await axios.get(`https://api.worldoftanks.com/wot/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data + let data = await (await axios.get(`https://api.worldoftanks.${this.app.lang}/wot/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data if (data.status == "error") return null data = data.data if (!data || data.length <= 0) return null @@ -65,7 +65,7 @@ class WorldOfTanksClan extends BaseClass { * @returns {Object} Clan rating. */ public async rating(clanID: string | number): Promise { - let data = await (await axios.get(`https://api.worldoftanks.com/wot/clanratings/clans/?application_id=${this.app.id}&clan_id=${clanID}`)).data + let data = await (await axios.get(`https://api.worldoftanks.${this.app.lang}/wot/clanratings/clans/?application_id=${this.app.id}&clan_id=${clanID}`)).data if (data.status == "error") return null data = data.data[clanID] return data diff --git a/packages/wargaming/world-of-tanks/src/functions/tank.ts b/packages/wargaming/world-of-tanks/src/functions/tank.ts index 7e0480f..cf0bbcf 100644 --- a/packages/wargaming/world-of-tanks/src/functions/tank.ts +++ b/packages/wargaming/world-of-tanks/src/functions/tank.ts @@ -4,10 +4,10 @@ import { BaseClass } from '../../../../../builds/class/base' class WorldOfTanksTank extends BaseClass { - app: { id: string } - constructor(app_id: string) { + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { super(app_id) - this.app = { id: app_id } + this.app = { id: app_id, lang: lang } } /** @@ -17,7 +17,7 @@ class WorldOfTanksTank extends BaseClass { */ public async get(tankID: number | string): Promise { - let data = await (await axios.get(`https://api.worldoftanks.com/wot/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data + let data = await (await axios.get(`https://api.worldoftanks.${this.app.lang}/wot/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data if (data.status == "error") return null data = data.data[tankID] diff --git a/packages/wargaming/world-of-tanks/src/functions/user.ts b/packages/wargaming/world-of-tanks/src/functions/user.ts index 05d1874..2cf41bb 100644 --- a/packages/wargaming/world-of-tanks/src/functions/user.ts +++ b/packages/wargaming/world-of-tanks/src/functions/user.ts @@ -6,10 +6,10 @@ import { BaseClass } from '../../../../../builds/class/base' class WorldOfTanksUser extends BaseClass { - app: { id: string } - constructor(app_id: string) { + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { super(app_id) - this.app = { id: app_id } + this.app = { id: app_id, lang: lang } } /** @@ -19,7 +19,7 @@ class WorldOfTanksUser extends BaseClass { */ public async search(userName: string): Promise { - const searchUser = await ((await axios.get(`https://api.worldoftanks.com/wot/account/list/?application_id=${this.app?.id}&search=${userName}`)).data).data + const searchUser = await ((await axios.get(`https://api.worldoftanks.${this.app.lang}/wot/account/list/?application_id=${this.app?.id}&search=${userName}`)).data).data if (!searchUser || searchUser.length <= 0) return null return searchUser } @@ -31,7 +31,7 @@ class WorldOfTanksUser extends BaseClass { */ public async get(userID: number | string): Promise { - let data = await (await axios.get(`https://api.worldoftanks.com/wot/account/info/?application_id=${this.app?.id}&account_id=${userID}`)).data + let data = await (await axios.get(`https://api.worldoftanks.${this.app.lang}/wot/account/info/?application_id=${this.app?.id}&account_id=${userID}`)).data if (data.status == "error") return null data = data.data[userID] @@ -56,7 +56,7 @@ class WorldOfTanksUser extends BaseClass { * @returns {Object[]} Object Array with tanks data. */ public async topTanks(userID: number | string): Promise { - let data = await (await axios.get(`https://api.worldoftanks.com/wot/account/tanks/?application_id=${this.app.id}&account_id=${userID}`)).data + let data = await (await axios.get(`https://api.worldoftanks.${this.app.lang}/wot/account/tanks/?application_id=${this.app.id}&account_id=${userID}`)).data if (data.status == "error") return null data = data.data[userID] data.length = 5 diff --git a/packages/wargaming/world-of-warships/src/functions/clan.ts b/packages/wargaming/world-of-warships/src/functions/clan.ts new file mode 100644 index 0000000..6d2c1d1 --- /dev/null +++ b/packages/wargaming/world-of-warships/src/functions/clan.ts @@ -0,0 +1,41 @@ +import axios from 'axios' +import { WOWSClansResolve } from '../interfaces/clan/clan-resolve' +import { WOWSClansSearchResolve } from '../interfaces/clan/search-resolve' +import { BaseClass } from '../../../../../builds/class/base' + +class WOWSClans extends BaseClass { + + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { + super(app_id) + this.app = { id: app_id, lang: lang } + } + + /** + * Get a clan in World of WarShips. + * @param clanID ID of clan. + * @returns {WOWSClansResolve} Clan data. + */ + + public async get(clanID: number | string): Promise { + let data = await (await axios.get(`https://api.worldofwarships.${this.app.lang}/wows/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data + if (data.status == "error") return null + data = data.data[clanID] + return data + } + + /** + * Get a array with clans data of respective name. + * @param clanNameOrTag Name or Tag of clan. + * @returns {ClanSearchResolve} Array with clan data. + */ + public async search(clanNameOrTag: string): Promise { + let data = await (await axios.get(`https://api.worldofwarships.${this.app.lang}/wows/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data + if (data.status == "error") return null + data = data.data + if (!data || data.length <= 0) return null + return data + } +} + +export { WOWSClans } \ No newline at end of file diff --git a/packages/wargaming/world-of-warships/src/functions/ship.ts b/packages/wargaming/world-of-warships/src/functions/ship.ts index 9f1e8e5..c2cb92c 100644 --- a/packages/wargaming/world-of-warships/src/functions/ship.ts +++ b/packages/wargaming/world-of-warships/src/functions/ship.ts @@ -4,14 +4,14 @@ import { WOWSShipResolve } from '../interfaces/ships/data' class WOWSShip extends BaseClass { - app: { id: string } - constructor(app_id: string) { + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { super(app_id) - this.app = { id: app_id } + this.app = { id: app_id, lang: lang } } public async get(userID: string | number): Promise { - var data = await (await axios.get(`https://api.worldofwarships.com/wows/ships/stats/?application_id=${this.app.id}&account_id=${userID}`)).data + var data = await (await axios.get(`https://api.worldofwarships.${this.app.lang}/wows/ships/stats/?application_id=${this.app.id}&account_id=${userID}`)).data if (data.status == "error") return null; return data.data[userID] diff --git a/packages/wargaming/world-of-warships/src/functions/user.ts b/packages/wargaming/world-of-warships/src/functions/user.ts index dddcb20..8bb8d37 100644 --- a/packages/wargaming/world-of-warships/src/functions/user.ts +++ b/packages/wargaming/world-of-warships/src/functions/user.ts @@ -7,10 +7,10 @@ import { WOWSUserResolve } from '../interfaces/user/result' class WOWSUser extends BaseClass { - app: { id: string } - constructor(app_id: string) { + app: { id: string, lang?: string } + constructor(app_id: string, lang?: string) { super(app_id) - this.app = { id: app_id } + this.app = { id: app_id, lang: lang } } /** @@ -20,7 +20,7 @@ class WOWSUser extends BaseClass { */ public async search(userName: string): Promise { - const searchUser = await ((await axios.get(`https://api.worldofwarships.com/wows/account/list/?application_id=${this.app?.id}&search=${userName}`)).data).data + const searchUser = await ((await axios.get(`https://api.worldofwarships.${this.app.lang}/wows/account/list/?application_id=${this.app?.id}&search=${userName}`)).data).data if (!searchUser || searchUser.length <= 0) return null return searchUser } @@ -32,7 +32,7 @@ class WOWSUser extends BaseClass { */ public async get(userID: number | string): Promise { - let data = await (await axios.get(`https://api.worldofwarships.com/wows/account/info/?application_id=${this.app?.id}&account_id=${userID}`)).data + let data = await (await axios.get(`https://api.worldofwarships.${this.app.lang}/wows/account/info/?application_id=${this.app?.id}&account_id=${userID}`)).data if (data.status == "error") return null data = data.data[userID] diff --git a/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.ts b/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.ts new file mode 100644 index 0000000..0be2eaa --- /dev/null +++ b/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.ts @@ -0,0 +1,20 @@ +interface WOWSClansResolve { + members_count: number | null, + name: string | null, + creator_name: string | null, + clan_id: number | null, + created_at: number | null, + updated_at: number | null, + leader_name: string | null, + members_ids: Array, + creator_id: number | null, + tag: string | null, + old_name: string | null, + is_clan_disbanded: boolean, + renamed_at: number | null, + old_tag: string | null, + leader_id: number | null, + description: string | null +} + +export { WOWSClansResolve } \ No newline at end of file diff --git a/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.ts b/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.ts new file mode 100644 index 0000000..e598a2a --- /dev/null +++ b/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.ts @@ -0,0 +1,9 @@ +interface WOWSClansSearchResolve { + members_count: number | null, + created_at: number | null, + clan_id: number | null, + tag: string | null, + name: string | null +} + +export { WOWSClansSearchResolve } \ No newline at end of file From 0854ee06fe3a4ba8913f59c2a85d0db54416da79 Mon Sep 17 00:00:00 2001 From: GardZock Date: Wed, 23 Feb 2022 00:31:24 -0300 Subject: [PATCH 6/8] Package.JSON and DIST FOLDER fixes and updates --- dist/index.d.ts | 6 ++- dist/index.js | 25 +++++++-- dist/package.json | 33 ++++++++++++ dist/packages/wargaming/build/class/base.d.ts | 13 +++-- dist/packages/wargaming/build/class/base.js | 12 +++-- .../src/functions/clan.d.ts | 3 +- .../src/functions/clan.js | 8 +-- .../src/functions/tank.d.ts | 3 +- .../src/functions/tank.js | 6 +-- .../src/functions/user.d.ts | 3 +- .../src/functions/user.js | 10 ++-- .../world-of-tanks/src/functions/clan.d.ts | 3 +- .../world-of-tanks/src/functions/clan.js | 10 ++-- .../world-of-tanks/src/functions/tank.d.ts | 3 +- .../world-of-tanks/src/functions/tank.js | 6 +-- .../world-of-tanks/src/functions/user.d.ts | 3 +- .../world-of-tanks/src/functions/user.js | 10 ++-- .../world-of-warships/src/functions/clan.d.ts | 23 ++++++++ .../world-of-warships/src/functions/clan.js | 54 +++++++++++++++++++ .../world-of-warships/src/functions/ship.d.ts | 5 +- .../world-of-warships/src/functions/ship.js | 10 ++-- .../world-of-warships/src/functions/user.d.ts | 7 +-- .../world-of-warships/src/functions/user.js | 14 ++--- .../src/interfaces/clan/clan-resolve.d.ts | 19 +++++++ .../src/interfaces/clan/clan-resolve.js | 2 + .../src/interfaces/clan/search-resolve.d.ts | 8 +++ .../src/interfaces/clan/search-resolve.js | 2 + package.json | 2 +- 28 files changed, 242 insertions(+), 61 deletions(-) create mode 100644 dist/package.json create mode 100644 dist/packages/wargaming/world-of-warships/src/functions/clan.d.ts create mode 100644 dist/packages/wargaming/world-of-warships/src/functions/clan.js create mode 100644 dist/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.d.ts create mode 100644 dist/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.js create mode 100644 dist/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.d.ts create mode 100644 dist/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.js diff --git a/dist/index.d.ts b/dist/index.d.ts index 2c4e7ee..9c6c3af 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -9,10 +9,12 @@ import { BaseClass } from './builds/class/base'; declare class WarCord extends BaseClass { app: { id: string; + lang?: string; }; wargaming: WargamingBase; - constructor(app_id: string); - private checker; + constructor(app_id: string, lang?: string); + private idChecker; + private langChecker; } export { WarCord }; export { WOTClanResolve, WOTClanSearchResolve, WOTTanksResolve, WOTTopTanksResolve, WOTUserResolve, UserSearchResolve }; diff --git a/dist/index.js b/dist/index.js index 7530661..8d0deb8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -4,12 +4,12 @@ exports.WarCord = void 0; const base_1 = require("./packages/wargaming/build/class/base"); const base_2 = require("./builds/class/base"); class WarCord extends base_2.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: this.checker(app_id) }; - this.wargaming = new base_1.WargamingBase(app_id); + this.app = { id: this.idChecker(app_id), lang: this.langChecker(lang) }; + this.wargaming = new base_1.WargamingBase(app_id, lang); } - checker(id) { + idChecker(id) { if (!id || id.length <= 0) { console.log('[WarCord] Your API ID is empty. (using Wargaming API)'); return ''; @@ -18,5 +18,22 @@ class WarCord extends base_2.BaseClass { return id; } } + langChecker(lang) { + if (!lang) + return 'com'; + const langs = [ + 'na', + 'eu', + 'ru', + 'asia' + ]; + if (!langs.includes(lang)) { + console.log('[WarCord] Your API Lang is not valid. (using Wargaming API)'); + return 'com'; + } + if (lang = 'na') + lang = 'com'; + return lang; + } } exports.WarCord = WarCord; diff --git a/dist/package.json b/dist/package.json new file mode 100644 index 0000000..4dff0fc --- /dev/null +++ b/dist/package.json @@ -0,0 +1,33 @@ +{ + "name": "warcord", + "version": "0.3.8", + "description": "A Simple lib with wargaming API", + "author": "GardZock", + "license": "Apache-2.0", + "main": "index.js", + "types": "index.d.ts", + "scripts": { + "dev": "tsnd --respawn --transpile-only tests/tests.ts", + "tscd": "tsc --declaration" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Warcord/WarCord-Lib.git" + }, + "bugs": { + "url": "https://github.com/Warcord/WarCord-Lib/issues" + }, + "homepage": "https://github.com/Warcord/WarCord-Lib#readme", + "devDependencies": { + "@types/ms": "^0.7.31", + "@types/node": "^17.0.18", + "@typescript-eslint/eslint-plugin": "^5.9.1", + "@typescript-eslint/parser": "^5.9.1", + "eslint": "^8.6.0", + "ts-node-dev": "^1.1.8", + "typescript": "^4.5.4" + }, + "dependencies": { + "axios": "^0.24.0" + } +} diff --git a/dist/packages/wargaming/build/class/base.d.ts b/dist/packages/wargaming/build/class/base.d.ts index de8f8af..125d191 100644 --- a/dist/packages/wargaming/build/class/base.d.ts +++ b/dist/packages/wargaming/build/class/base.d.ts @@ -1,14 +1,17 @@ -import { WorldOfTanksUser } from '../../world-of-tanks/src/functions/user'; +import { BaseClass } from '../../../../builds/class/base'; import { WargamingApp } from '../interfaces/app'; +import { WorldOfTanksUser } from '../../world-of-tanks/src/functions/user'; import { WorldOfTanksTank } from '../../world-of-tanks/src/functions/tank'; import { WorldOfTanksClan } from '../../world-of-tanks/src/functions/clan'; -import { BaseClass } from '../../../../builds/class/base'; import { WOTBUser } from '../../world-of-tanks-blitz/src/functions/user'; import { WOTBTank } from '../../world-of-tanks-blitz/src/functions/tank'; import { WOTBClan } from '../../world-of-tanks-blitz/src/functions/clan'; +import { WOWSUser } from '../../world-of-warships/src/functions/user'; +import { WOWSShip } from '../../world-of-warships/src/functions/ship'; declare class WargamingBase extends BaseClass implements WargamingApp { app: { id: string; + lang?: string; }; wot: { user: WorldOfTanksUser; @@ -20,6 +23,10 @@ declare class WargamingBase extends BaseClass implements WargamingApp { tank: WOTBTank; clan: WOTBClan; }; - constructor(app_id: string); + wows: { + user: WOWSUser; + ship: WOWSShip; + }; + constructor(app_id: string, lang?: string); } export { WargamingBase }; diff --git a/dist/packages/wargaming/build/class/base.js b/dist/packages/wargaming/build/class/base.js index 32c81b1..bb595ba 100644 --- a/dist/packages/wargaming/build/class/base.js +++ b/dist/packages/wargaming/build/class/base.js @@ -1,17 +1,19 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WargamingBase = void 0; +const base_1 = require("../../../../builds/class/base"); const user_1 = require("../../world-of-tanks/src/functions/user"); const tank_1 = require("../../world-of-tanks/src/functions/tank"); const clan_1 = require("../../world-of-tanks/src/functions/clan"); -const base_1 = require("../../../../builds/class/base"); const user_2 = require("../../world-of-tanks-blitz/src/functions/user"); const tank_2 = require("../../world-of-tanks-blitz/src/functions/tank"); const clan_2 = require("../../world-of-tanks-blitz/src/functions/clan"); +const user_3 = require("../../world-of-warships/src/functions/user"); +const ship_1 = require("../../world-of-warships/src/functions/ship"); class WargamingBase extends base_1.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; this.wot = { user: new user_1.WorldOfTanksUser(app_id), tank: new tank_1.WorldOfTanksTank(app_id), @@ -22,6 +24,10 @@ class WargamingBase extends base_1.BaseClass { tank: new tank_2.WOTBTank(app_id), clan: new clan_2.WOTBClan(app_id) }; + this.wows = { + user: new user_3.WOWSUser(app_id), + ship: new ship_1.WOWSShip(app_id) + }; } } exports.WargamingBase = WargamingBase; diff --git a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/clan.d.ts b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/clan.d.ts index 5ff9d8d..0d90caf 100644 --- a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/clan.d.ts +++ b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/clan.d.ts @@ -3,8 +3,9 @@ import { WOTBClanResolve } from '../interfaces/clan/clan-resolve'; declare class WOTBClan extends BaseClass { app: { id: string; + lang?: string; }; - constructor(app_id: string); + constructor(app_id: string, lang?: string); get(clanID: string | number): Promise; search(clanNameOrTag: string): Promise; } diff --git a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/clan.js b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/clan.js index 5c3d430..55da898 100644 --- a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/clan.js +++ b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/clan.js @@ -16,13 +16,13 @@ exports.WOTBClan = void 0; const base_1 = require("../../../../../builds/class/base"); const axios_1 = __importDefault(require("axios")); class WOTBClan extends base_1.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; } get(clanID) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data; if (data.status == "error") return null; return data.data[clanID]; @@ -30,7 +30,7 @@ class WOTBClan extends base_1.BaseClass { } search(clanNameOrTag) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data; + let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data; if (data.status == "error" || data.data.length <= 0) return null; return data.data; diff --git a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/tank.d.ts b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/tank.d.ts index 46e8912..4e6dced 100644 --- a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/tank.d.ts +++ b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/tank.d.ts @@ -3,8 +3,9 @@ import { WOTBTankResolve } from '../interfaces/tank/tank-resolve'; declare class WOTBTank extends BaseClass { app: { id: string; + lang?: string; }; - constructor(app_id: string); + constructor(app_id: string, lang?: string); get(tankID: string | number): Promise; } export { WOTBTank }; diff --git a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/tank.js b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/tank.js index 71a8354..3fe172f 100644 --- a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/tank.js +++ b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/tank.js @@ -16,13 +16,13 @@ exports.WOTBTank = void 0; const base_1 = require("../../../../../builds/class/base"); const axios_1 = __importDefault(require("axios")); class WOTBTank extends base_1.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; } get(tankID) { return __awaiter(this, void 0, void 0, function* () { - var data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data; + var data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data; if (data.status == "error") return null; return data.data[tankID]; diff --git a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/user.d.ts b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/user.d.ts index 852def2..d386730 100644 --- a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/user.d.ts +++ b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/user.d.ts @@ -5,8 +5,9 @@ import { WOTBTankTop } from '../interfaces/tank/tank-top'; declare class WOTBUser extends BaseClass { app: { id: string; + lang?: string; }; - constructor(app_id: string); + constructor(app_id: string, lang?: string); get(userID: string | number): Promise; search(userName: string): Promise; topTanks(userID: string | number): Promise; diff --git a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/user.js b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/user.js index d3ce11f..8f15bde 100644 --- a/dist/packages/wargaming/world-of-tanks-blitz/src/functions/user.js +++ b/dist/packages/wargaming/world-of-tanks-blitz/src/functions/user.js @@ -16,13 +16,13 @@ exports.WOTBUser = void 0; const base_1 = require("../../../../../builds/class/base"); const axios_1 = __importDefault(require("axios")); class WOTBUser extends base_1.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; } get(userID) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/account/info/?application_id=${this.app.id}&account_id=${userID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/account/info/?application_id=${this.app.id}&account_id=${userID}`)).data; if (data.status == "error") return null; data = data.data[userID]; @@ -40,7 +40,7 @@ class WOTBUser extends base_1.BaseClass { } search(userName) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/account/list/?application_id=${this.app.id}&search=${userName}`)).data; + let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/account/list/?application_id=${this.app.id}&search=${userName}`)).data; if (data.status == "error" || data.data.length <= 0) return null; return data.data; @@ -48,7 +48,7 @@ class WOTBUser extends base_1.BaseClass { } topTanks(userID) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/tanks/stats/?application_id=${this.app.id}&account_id=${userID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.wotblitz.${this.app.lang}/wotb/tanks/stats/?application_id=${this.app.id}&account_id=${userID}`)).data; if (data.status == "error" || data.data.length <= 0) return null; data = data.data[userID]; diff --git a/dist/packages/wargaming/world-of-tanks/src/functions/clan.d.ts b/dist/packages/wargaming/world-of-tanks/src/functions/clan.d.ts index 1189dee..f6a472b 100644 --- a/dist/packages/wargaming/world-of-tanks/src/functions/clan.d.ts +++ b/dist/packages/wargaming/world-of-tanks/src/functions/clan.d.ts @@ -4,8 +4,9 @@ import { BaseClass } from '../../../../../builds/class/base'; declare class WorldOfTanksClan extends BaseClass { app: { id: string; + lang?: string; }; - constructor(app_id: string); + constructor(app_id: string, lang?: string); /** * Get a clan in World of Tanks. * @param clanID ID of clan. diff --git a/dist/packages/wargaming/world-of-tanks/src/functions/clan.js b/dist/packages/wargaming/world-of-tanks/src/functions/clan.js index 8bde458..229bc68 100644 --- a/dist/packages/wargaming/world-of-tanks/src/functions/clan.js +++ b/dist/packages/wargaming/world-of-tanks/src/functions/clan.js @@ -16,9 +16,9 @@ exports.WorldOfTanksClan = void 0; const axios_1 = __importDefault(require("axios")); const base_1 = require("../../../../../builds/class/base"); class WorldOfTanksClan extends base_1.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; } /** * Get a clan in World of Tanks. @@ -27,7 +27,7 @@ class WorldOfTanksClan extends base_1.BaseClass { */ get(clanID) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data; if (data.status == "error") return null; data = data.data[clanID]; @@ -63,7 +63,7 @@ class WorldOfTanksClan extends base_1.BaseClass { */ search(clanNameOrTag) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data; + let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data; if (data.status == "error") return null; data = data.data; @@ -79,7 +79,7 @@ class WorldOfTanksClan extends base_1.BaseClass { */ rating(clanID) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/clanratings/clans/?application_id=${this.app.id}&clan_id=${clanID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/clanratings/clans/?application_id=${this.app.id}&clan_id=${clanID}`)).data; if (data.status == "error") return null; data = data.data[clanID]; diff --git a/dist/packages/wargaming/world-of-tanks/src/functions/tank.d.ts b/dist/packages/wargaming/world-of-tanks/src/functions/tank.d.ts index 9777b69..209cf98 100644 --- a/dist/packages/wargaming/world-of-tanks/src/functions/tank.d.ts +++ b/dist/packages/wargaming/world-of-tanks/src/functions/tank.d.ts @@ -3,8 +3,9 @@ import { BaseClass } from '../../../../../builds/class/base'; declare class WorldOfTanksTank extends BaseClass { app: { id: string; + lang?: string; }; - constructor(app_id: string); + constructor(app_id: string, lang?: string); /** * Get a tank by ID. * @param tankID ID of Tank. diff --git a/dist/packages/wargaming/world-of-tanks/src/functions/tank.js b/dist/packages/wargaming/world-of-tanks/src/functions/tank.js index 3a4c0c0..bbabd05 100644 --- a/dist/packages/wargaming/world-of-tanks/src/functions/tank.js +++ b/dist/packages/wargaming/world-of-tanks/src/functions/tank.js @@ -16,9 +16,9 @@ exports.WorldOfTanksTank = void 0; const axios_1 = __importDefault(require("axios")); const base_1 = require("../../../../../builds/class/base"); class WorldOfTanksTank extends base_1.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; } /** * Get a tank by ID. @@ -27,7 +27,7 @@ class WorldOfTanksTank extends base_1.BaseClass { */ get(tankID) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data; if (data.status == "error") return null; data = data.data[tankID]; diff --git a/dist/packages/wargaming/world-of-tanks/src/functions/user.d.ts b/dist/packages/wargaming/world-of-tanks/src/functions/user.d.ts index e5940cf..9d57e02 100644 --- a/dist/packages/wargaming/world-of-tanks/src/functions/user.d.ts +++ b/dist/packages/wargaming/world-of-tanks/src/functions/user.d.ts @@ -5,8 +5,9 @@ import { BaseClass } from '../../../../../builds/class/base'; declare class WorldOfTanksUser extends BaseClass { app: { id: string; + lang?: string; }; - constructor(app_id: string); + constructor(app_id: string, lang?: string); /** * Search users with respective name. * @param userName Name of user. diff --git a/dist/packages/wargaming/world-of-tanks/src/functions/user.js b/dist/packages/wargaming/world-of-tanks/src/functions/user.js index 45bcd2f..ef96dc1 100644 --- a/dist/packages/wargaming/world-of-tanks/src/functions/user.js +++ b/dist/packages/wargaming/world-of-tanks/src/functions/user.js @@ -16,9 +16,9 @@ exports.WorldOfTanksUser = void 0; const axios_1 = __importDefault(require("axios")); const base_1 = require("../../../../../builds/class/base"); class WorldOfTanksUser extends base_1.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; } /** * Search users with respective name. @@ -28,7 +28,7 @@ class WorldOfTanksUser extends base_1.BaseClass { search(userName) { var _a; return __awaiter(this, void 0, void 0, function* () { - const searchUser = yield ((yield axios_1.default.get(`https://api.worldoftanks.com/wot/account/list/?application_id=${(_a = this.app) === null || _a === void 0 ? void 0 : _a.id}&search=${userName}`)).data).data; + const searchUser = yield ((yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/account/list/?application_id=${(_a = this.app) === null || _a === void 0 ? void 0 : _a.id}&search=${userName}`)).data).data; if (!searchUser || searchUser.length <= 0) return null; return searchUser; @@ -42,7 +42,7 @@ class WorldOfTanksUser extends base_1.BaseClass { get(userID) { var _a; return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/account/info/?application_id=${(_a = this.app) === null || _a === void 0 ? void 0 : _a.id}&account_id=${userID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/account/info/?application_id=${(_a = this.app) === null || _a === void 0 ? void 0 : _a.id}&account_id=${userID}`)).data; if (data.status == "error") return null; data = data.data[userID]; @@ -68,7 +68,7 @@ class WorldOfTanksUser extends base_1.BaseClass { */ topTanks(userID) { return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.worldoftanks.com/wot/account/tanks/?application_id=${this.app.id}&account_id=${userID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.worldoftanks.${this.app.lang}/wot/account/tanks/?application_id=${this.app.id}&account_id=${userID}`)).data; if (data.status == "error") return null; data = data.data[userID]; diff --git a/dist/packages/wargaming/world-of-warships/src/functions/clan.d.ts b/dist/packages/wargaming/world-of-warships/src/functions/clan.d.ts new file mode 100644 index 0000000..fd690b2 --- /dev/null +++ b/dist/packages/wargaming/world-of-warships/src/functions/clan.d.ts @@ -0,0 +1,23 @@ +import { WOWSClansResolve } from '../interfaces/clan/clan-resolve'; +import { WOWSClansSearchResolve } from '../interfaces/clan/search-resolve'; +import { BaseClass } from '../../../../../builds/class/base'; +declare class WOWSClans extends BaseClass { + app: { + id: string; + lang?: string; + }; + constructor(app_id: string, lang?: string); + /** + * Get a clan in World of WarShips. + * @param clanID ID of clan. + * @returns {WOWSClansResolve} Clan data. + */ + get(clanID: number | string): Promise; + /** + * Get a array with clans data of respective name. + * @param clanNameOrTag Name or Tag of clan. + * @returns {ClanSearchResolve} Array with clan data. + */ + search(clanNameOrTag: string): Promise; +} +export { WOWSClans }; diff --git a/dist/packages/wargaming/world-of-warships/src/functions/clan.js b/dist/packages/wargaming/world-of-warships/src/functions/clan.js new file mode 100644 index 0000000..eb69b1d --- /dev/null +++ b/dist/packages/wargaming/world-of-warships/src/functions/clan.js @@ -0,0 +1,54 @@ +"use strict"; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.WOWSClans = void 0; +const axios_1 = __importDefault(require("axios")); +const base_1 = require("../../../../../builds/class/base"); +class WOWSClans extends base_1.BaseClass { + constructor(app_id, lang) { + super(app_id); + this.app = { id: app_id, lang: lang }; + } + /** + * Get a clan in World of WarShips. + * @param clanID ID of clan. + * @returns {WOWSClansResolve} Clan data. + */ + get(clanID) { + return __awaiter(this, void 0, void 0, function* () { + let data = yield (yield axios_1.default.get(`https://api.worldofwarships.${this.app.lang}/wows/clans/info/?application_id=${this.app.id}&clan_id=${clanID}`)).data; + if (data.status == "error") + return null; + data = data.data[clanID]; + return data; + }); + } + /** + * Get a array with clans data of respective name. + * @param clanNameOrTag Name or Tag of clan. + * @returns {ClanSearchResolve} Array with clan data. + */ + search(clanNameOrTag) { + return __awaiter(this, void 0, void 0, function* () { + let data = yield (yield axios_1.default.get(`https://api.worldofwarships.${this.app.lang}/wows/clans/list/?application_id=${this.app.id}&search=${clanNameOrTag}`)).data; + if (data.status == "error") + return null; + data = data.data; + if (!data || data.length <= 0) + return null; + return data; + }); + } +} +exports.WOWSClans = WOWSClans; diff --git a/dist/packages/wargaming/world-of-warships/src/functions/ship.d.ts b/dist/packages/wargaming/world-of-warships/src/functions/ship.d.ts index 39737b1..a9ad506 100644 --- a/dist/packages/wargaming/world-of-warships/src/functions/ship.d.ts +++ b/dist/packages/wargaming/world-of-warships/src/functions/ship.d.ts @@ -3,8 +3,9 @@ import { WOWSShipResolve } from '../interfaces/ships/data'; declare class WOWSShip extends BaseClass { app: { id: string; + lang?: string; }; - constructor(app_id: string); - get(tankID: string | number): Promise; + constructor(app_id: string, lang?: string); + get(userID: string | number): Promise; } export { WOWSShip }; diff --git a/dist/packages/wargaming/world-of-warships/src/functions/ship.js b/dist/packages/wargaming/world-of-warships/src/functions/ship.js index 19b91bb..ae01567 100644 --- a/dist/packages/wargaming/world-of-warships/src/functions/ship.js +++ b/dist/packages/wargaming/world-of-warships/src/functions/ship.js @@ -16,16 +16,16 @@ exports.WOWSShip = void 0; const base_1 = require("../../../../../builds/class/base"); const axios_1 = __importDefault(require("axios")); class WOWSShip extends base_1.BaseClass { - constructor(app_id) { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; } - get(tankID) { + get(userID) { return __awaiter(this, void 0, void 0, function* () { - var data = yield (yield axios_1.default.get(`https://api.wotblitz.com/wotb/encyclopedia/vehicles/?application_id=${this.app.id}&tank_id=${tankID}`)).data; + var data = yield (yield axios_1.default.get(`https://api.worldofwarships.${this.app.lang}/wows/ships/stats/?application_id=${this.app.id}&account_id=${userID}`)).data; if (data.status == "error") return null; - return data.data[tankID]; + return data.data[userID]; }); } } diff --git a/dist/packages/wargaming/world-of-warships/src/functions/user.d.ts b/dist/packages/wargaming/world-of-warships/src/functions/user.d.ts index 7ba4e4e..1a97ae4 100644 --- a/dist/packages/wargaming/world-of-warships/src/functions/user.d.ts +++ b/dist/packages/wargaming/world-of-warships/src/functions/user.d.ts @@ -1,11 +1,12 @@ import { UserSearchResolve } from '../../../build/interfaces/search-resolve'; import { BaseClass } from '../../../../../builds/class/base'; import { WOWSUserResolve } from '../interfaces/user/result'; -declare class WorldOfWarShipsUser extends BaseClass { +declare class WOWSUser extends BaseClass { app: { id: string; + lang?: string; }; - constructor(app_id: string); + constructor(app_id: string, lang?: string); /** * Search users with respective name. * @param userName Name of user. @@ -19,4 +20,4 @@ declare class WorldOfWarShipsUser extends BaseClass { */ get(userID: number | string): Promise; } -export { WorldOfWarShipsUser }; +export { WOWSUser }; diff --git a/dist/packages/wargaming/world-of-warships/src/functions/user.js b/dist/packages/wargaming/world-of-warships/src/functions/user.js index e2f336d..457b8b8 100644 --- a/dist/packages/wargaming/world-of-warships/src/functions/user.js +++ b/dist/packages/wargaming/world-of-warships/src/functions/user.js @@ -12,13 +12,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); -exports.WorldOfWarShipsUser = void 0; +exports.WOWSUser = void 0; const axios_1 = __importDefault(require("axios")); const base_1 = require("../../../../../builds/class/base"); -class WorldOfWarShipsUser extends base_1.BaseClass { - constructor(app_id) { +class WOWSUser extends base_1.BaseClass { + constructor(app_id, lang) { super(app_id); - this.app = { id: app_id }; + this.app = { id: app_id, lang: lang }; } /** * Search users with respective name. @@ -28,7 +28,7 @@ class WorldOfWarShipsUser extends base_1.BaseClass { search(userName) { var _a; return __awaiter(this, void 0, void 0, function* () { - const searchUser = yield ((yield axios_1.default.get(`https://api.worldofwarships.com/wows/account/list/?application_id=${(_a = this.app) === null || _a === void 0 ? void 0 : _a.id}&search=${userName}`)).data).data; + const searchUser = yield ((yield axios_1.default.get(`https://api.worldofwarships.${this.app.lang}/wows/account/list/?application_id=${(_a = this.app) === null || _a === void 0 ? void 0 : _a.id}&search=${userName}`)).data).data; if (!searchUser || searchUser.length <= 0) return null; return searchUser; @@ -42,7 +42,7 @@ class WorldOfWarShipsUser extends base_1.BaseClass { get(userID) { var _a; return __awaiter(this, void 0, void 0, function* () { - let data = yield (yield axios_1.default.get(`https://api.worldofwarships.com/wows/account/info/?application_id=${(_a = this.app) === null || _a === void 0 ? void 0 : _a.id}&account_id=${userID}`)).data; + let data = yield (yield axios_1.default.get(`https://api.worldofwarships.${this.app.lang}/wows/account/info/?application_id=${(_a = this.app) === null || _a === void 0 ? void 0 : _a.id}&account_id=${userID}`)).data; if (data.status == "error") return null; data = data.data[userID]; @@ -50,4 +50,4 @@ class WorldOfWarShipsUser extends base_1.BaseClass { }); } } -exports.WorldOfWarShipsUser = WorldOfWarShipsUser; +exports.WOWSUser = WOWSUser; diff --git a/dist/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.d.ts b/dist/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.d.ts new file mode 100644 index 0000000..fa82835 --- /dev/null +++ b/dist/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.d.ts @@ -0,0 +1,19 @@ +interface WOWSClansResolve { + members_count: number | null; + name: string | null; + creator_name: string | null; + clan_id: number | null; + created_at: number | null; + updated_at: number | null; + leader_name: string | null; + members_ids: Array; + creator_id: number | null; + tag: string | null; + old_name: string | null; + is_clan_disbanded: boolean; + renamed_at: number | null; + old_tag: string | null; + leader_id: number | null; + description: string | null; +} +export { WOWSClansResolve }; diff --git a/dist/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.js b/dist/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/packages/wargaming/world-of-warships/src/interfaces/clan/clan-resolve.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/dist/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.d.ts b/dist/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.d.ts new file mode 100644 index 0000000..b2f5645 --- /dev/null +++ b/dist/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.d.ts @@ -0,0 +1,8 @@ +interface WOWSClansSearchResolve { + members_count: number | null; + created_at: number | null; + clan_id: number | null; + tag: string | null; + name: string | null; +} +export { WOWSClansSearchResolve }; diff --git a/dist/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.js b/dist/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/dist/packages/wargaming/world-of-warships/src/interfaces/clan/search-resolve.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/package.json b/package.json index 5b17734..3cd871d 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.3.8", "description": "A Simple lib with wargaming API", "author": "GardZock", - "license": "Apache 2.0", + "license": "Apache-2.0", "main": "dist/warcord/index.js", "types": "dist/warcord/index.d.ts", "scripts": { From 9ce34b4b74cb1e42f6bfe3e86de39dbbc571ea59 Mon Sep 17 00:00:00 2001 From: GardZock Date: Wed, 23 Feb 2022 00:34:26 -0300 Subject: [PATCH 7/8] Add of Clan in Base Wargaming Class --- dist/packages/wargaming/build/class/base.d.ts | 2 ++ dist/packages/wargaming/build/class/base.js | 18 +++++++++------- packages/wargaming/build/class/base.ts | 21 +++++++++++-------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/dist/packages/wargaming/build/class/base.d.ts b/dist/packages/wargaming/build/class/base.d.ts index 125d191..665f1b8 100644 --- a/dist/packages/wargaming/build/class/base.d.ts +++ b/dist/packages/wargaming/build/class/base.d.ts @@ -8,6 +8,7 @@ import { WOTBTank } from '../../world-of-tanks-blitz/src/functions/tank'; import { WOTBClan } from '../../world-of-tanks-blitz/src/functions/clan'; import { WOWSUser } from '../../world-of-warships/src/functions/user'; import { WOWSShip } from '../../world-of-warships/src/functions/ship'; +import { WOWSClans } from '../../world-of-warships/src/functions/clan'; declare class WargamingBase extends BaseClass implements WargamingApp { app: { id: string; @@ -26,6 +27,7 @@ declare class WargamingBase extends BaseClass implements WargamingApp { wows: { user: WOWSUser; ship: WOWSShip; + clan: WOWSClans; }; constructor(app_id: string, lang?: string); } diff --git a/dist/packages/wargaming/build/class/base.js b/dist/packages/wargaming/build/class/base.js index bb595ba..f2b61b5 100644 --- a/dist/packages/wargaming/build/class/base.js +++ b/dist/packages/wargaming/build/class/base.js @@ -10,23 +10,25 @@ const tank_2 = require("../../world-of-tanks-blitz/src/functions/tank"); const clan_2 = require("../../world-of-tanks-blitz/src/functions/clan"); const user_3 = require("../../world-of-warships/src/functions/user"); const ship_1 = require("../../world-of-warships/src/functions/ship"); +const clan_3 = require("../../world-of-warships/src/functions/clan"); class WargamingBase extends base_1.BaseClass { constructor(app_id, lang) { super(app_id); this.app = { id: app_id, lang: lang }; this.wot = { - user: new user_1.WorldOfTanksUser(app_id), - tank: new tank_1.WorldOfTanksTank(app_id), - clan: new clan_1.WorldOfTanksClan(app_id) + user: new user_1.WorldOfTanksUser(app_id, lang), + tank: new tank_1.WorldOfTanksTank(app_id, lang), + clan: new clan_1.WorldOfTanksClan(app_id, lang) }; this.blitz = { - user: new user_2.WOTBUser(app_id), - tank: new tank_2.WOTBTank(app_id), - clan: new clan_2.WOTBClan(app_id) + user: new user_2.WOTBUser(app_id, lang), + tank: new tank_2.WOTBTank(app_id, lang), + clan: new clan_2.WOTBClan(app_id, lang) }; this.wows = { - user: new user_3.WOWSUser(app_id), - ship: new ship_1.WOWSShip(app_id) + user: new user_3.WOWSUser(app_id, lang), + ship: new ship_1.WOWSShip(app_id, lang), + clan: new clan_3.WOWSClans(app_id, lang) }; } } diff --git a/packages/wargaming/build/class/base.ts b/packages/wargaming/build/class/base.ts index 1370ba5..326be4f 100644 --- a/packages/wargaming/build/class/base.ts +++ b/packages/wargaming/build/class/base.ts @@ -11,6 +11,7 @@ import { WOTBClan } from '../../world-of-tanks-blitz/src/functions/clan' import { WOWSUser } from '../../world-of-warships/src/functions/user' import { WOWSShip } from '../../world-of-warships/src/functions/ship' +import { WOWSClans } from '../../world-of-warships/src/functions/clan' class WargamingBase extends BaseClass implements WargamingApp { app: { @@ -29,25 +30,27 @@ class WargamingBase extends BaseClass implements WargamingApp { } wows: { user: WOWSUser, - ship: WOWSShip + ship: WOWSShip, + clan: WOWSClans } constructor(app_id: string, lang?: string) { super(app_id) this.app = { id: app_id, lang: lang } this.wot = { - user: new WorldOfTanksUser(app_id), - tank: new WorldOfTanksTank(app_id), - clan: new WorldOfTanksClan(app_id) + user: new WorldOfTanksUser(app_id, lang), + tank: new WorldOfTanksTank(app_id, lang), + clan: new WorldOfTanksClan(app_id, lang) } this.blitz = { - user: new WOTBUser(app_id), - tank: new WOTBTank(app_id), - clan: new WOTBClan(app_id) + user: new WOTBUser(app_id, lang), + tank: new WOTBTank(app_id, lang), + clan: new WOTBClan(app_id, lang) } this.wows = { - user: new WOWSUser(app_id), - ship: new WOWSShip(app_id) + user: new WOWSUser(app_id, lang), + ship: new WOWSShip(app_id, lang), + clan: new WOWSClans(app_id, lang) } } } From 41c401be0cd42cf97e144c3bd0bcf30903a2f83e Mon Sep 17 00:00:00 2001 From: GardZock Date: Wed, 23 Feb 2022 00:38:21 -0300 Subject: [PATCH 8/8] The Last Change --- dist/package.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/package.json b/dist/package.json index 4dff0fc..e8ed364 100644 --- a/dist/package.json +++ b/dist/package.json @@ -1,6 +1,6 @@ { "name": "warcord", - "version": "0.3.8", + "version": "1.0.0", "description": "A Simple lib with wargaming API", "author": "GardZock", "license": "Apache-2.0", diff --git a/package.json b/package.json index 3cd871d..5032cc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "warcord", - "version": "0.3.8", + "version": "1.0.0", "description": "A Simple lib with wargaming API", "author": "GardZock", "license": "Apache-2.0",