2023-08-09 17:20:03 +00:00
|
|
|
import { RatingsInfo } from '../../commands/ratings';
|
|
|
|
|
import { Region } from '../../constants/regions';
|
2023-10-29 13:40:32 -05:00
|
|
|
import { context } from '../blitzkrieg/context';
|
2023-10-31 11:41:04 -05:00
|
|
|
import { withCORSProxy } from '../blitzkrieg/withCORSProxy';
|
2023-08-09 17:20:03 +00:00
|
|
|
import regionToRegionSubdomain from './regionToRegionSubdomain';
|
|
|
|
|
|
|
|
|
|
export default async function getRatingsInfo(region: Region) {
|
|
|
|
|
const response = await fetch(
|
2023-10-31 11:41:04 -05:00
|
|
|
withCORSProxy(
|
|
|
|
|
context === 'bot'
|
|
|
|
|
? `https://${regionToRegionSubdomain(
|
|
|
|
|
region,
|
|
|
|
|
)}.wotblitz.com/en/api/rating-leaderboards/season/`
|
|
|
|
|
: `/api/ratings/info/${region}`,
|
|
|
|
|
),
|
2023-08-09 17:20:03 +00:00
|
|
|
);
|
2023-09-03 18:15:10 +00:00
|
|
|
|
2023-08-09 17:20:03 +00:00
|
|
|
return (await response.json()) as Promise<RatingsInfo>;
|
|
|
|
|
}
|