2023-11-07 18:58:19 -06:00
|
|
|
import { LeagueTop } from '../../commands/ratings';
|
|
|
|
|
import { Region } from '../../constants/regions';
|
2023-11-11 21:37:59 -06:00
|
|
|
import { context } from '../blitzkrieg/context';
|
2023-11-07 18:58:19 -06:00
|
|
|
import { patientFetch } from '../blitzkrieg/patientFetch';
|
|
|
|
|
import regionToRegionSubdomain from './regionToRegionSubdomain';
|
|
|
|
|
|
|
|
|
|
export async function getRatingsLeague(
|
|
|
|
|
region: Region,
|
|
|
|
|
league: number,
|
|
|
|
|
usePatientFetcher = false,
|
|
|
|
|
) {
|
|
|
|
|
const fetcher = usePatientFetcher ? patientFetch : fetch;
|
|
|
|
|
const response = await fetcher(
|
2023-11-11 21:37:59 -06:00
|
|
|
context === 'website'
|
|
|
|
|
? `/api/${region}/ratings/current/league/${league}`
|
|
|
|
|
: `https://${regionToRegionSubdomain(
|
|
|
|
|
region,
|
|
|
|
|
)}.wotblitz.com/en/api/rating-leaderboards/league/${league}/top/`,
|
2023-11-07 18:58:19 -06:00
|
|
|
);
|
|
|
|
|
const json = (await response.json()) as LeagueTop;
|
|
|
|
|
|
|
|
|
|
return json;
|
|
|
|
|
}
|