mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-21 18:57:03 +02:00
feat: cc account tracking 2
This commit is contained in:
1 parent
d2b18360ed
commit
38fa15ab97
4 files changed
+48
-12
No files matched your search
@@ -60,10 +60,12 @@ async function manageQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
export type FetchBlitzParams = Record<string, string | number | undefined>;
|
||||
|
||||
export default function fetchBlitz<Data extends object>(
|
||||
region: Region,
|
||||
path: string,
|
||||
params: Record<string, string | number | undefined> = {},
|
||||
params: FetchBlitzParams = {},
|
||||
) {
|
||||
return new Promise<Data>((resolve) => {
|
||||
queue.push({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
import fetchBlitz from './fetchBlitz';
|
||||
import fetchBlitz, { FetchBlitzParams } from './fetchBlitz';
|
||||
import { normalizeIds } from './normalizeIds';
|
||||
|
||||
export interface AllStats {
|
||||
@@ -95,10 +95,16 @@ export async function getAccountInfo<
|
||||
ReturnType = Ids extends number
|
||||
? IndividualAccountInfo
|
||||
: IndividualAccountInfo[],
|
||||
>(region: Region, ids: Ids, extra: string[] = []) {
|
||||
>(
|
||||
region: Region,
|
||||
ids: Ids,
|
||||
extra: string[] = [],
|
||||
params: FetchBlitzParams = {},
|
||||
) {
|
||||
const object = await fetchBlitz<AccountInfo>(region, 'account/info', {
|
||||
account_id: normalizeIds(ids),
|
||||
extra: extra.length === 0 ? undefined : extra.join(','),
|
||||
...params,
|
||||
});
|
||||
|
||||
if (typeof ids === 'number') {
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
import { Region } from '../../constants/regions';
|
||||
import { TanksStats } from '../../types/tanksStats';
|
||||
import fetchBlitz from './fetchBlitz';
|
||||
import fetchBlitz, { FetchBlitzParams } from './fetchBlitz';
|
||||
|
||||
export default async function getTankStats(region: Region, id: number) {
|
||||
export default async function getTankStats(
|
||||
region: Region,
|
||||
id: number,
|
||||
|
||||
params?: FetchBlitzParams,
|
||||
) {
|
||||
const tankStats = await fetchBlitz<TanksStats>(region, 'tanks/stats', {
|
||||
account_id: id,
|
||||
...params,
|
||||
});
|
||||
|
||||
return tankStats[id];
|
||||
|
||||
Reference in new issue
Block a user