This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
232 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
packages/wargaming/world-of-tanks-blitz/src/functions/clan.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } | ||
constructor(app_id: string) { | ||
super(app_id) | ||
this.app = { id: app_id } | ||
} | ||
|
||
public async get(clanID: string | number): Promise<WOTBClanResolve | null> { | ||
let data = await (await axios.get(`https://api.wotblitz.com/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<any | null> { | ||
let data = await (await axios.get(`https://api.wotblitz.com/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 } |
21 changes: 21 additions & 0 deletions
21
packages/wargaming/world-of-tanks-blitz/src/functions/tank.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } | ||
constructor(app_id: string) { | ||
super(app_id) | ||
this.app = { id: app_id } | ||
} | ||
|
||
public async get(tankID: string | number): Promise<WOTBTankResolve | null> { | ||
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 { WOTBTank } |
47 changes: 47 additions & 0 deletions
47
packages/wargaming/world-of-tanks-blitz/src/functions/user.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } | ||
constructor(app_id: string) { | ||
super(app_id) | ||
this.app = { id: app_id } | ||
} | ||
|
||
|
||
public async get(userID: string | number): Promise<WOTBUserResolve | null> { | ||
let data = await (await axios.get(`https://api.wotblitz.com/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<UserSearchResolve | null> { | ||
let data = await (await axios.get(`https://api.wotblitz.com/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<WOTBTankTop | null> { | ||
let data = await (await axios.get(`https://api.wotblitz.com/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 } |
31 changes: 31 additions & 0 deletions
31
packages/wargaming/world-of-tanks-blitz/src/interfaces/clan/clan-resolve.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |
21 changes: 21 additions & 0 deletions
21
packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-resolve.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |
33 changes: 33 additions & 0 deletions
33
packages/wargaming/world-of-tanks-blitz/src/interfaces/tank/tank-top.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |
53 changes: 53 additions & 0 deletions
53
packages/wargaming/world-of-tanks-blitz/src/interfaces/user/user-return.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 } |