@@ -7,7 +7,8 @@ import { User, UserName } from '../interfaces/User';
77import { OpenContests } from './OpenContest' ;
88
99const BASE_URL = 'https://yukicoder.me' ;
10- const STATIC_API_BASE_URL = `${ BASE_URL } /api/v1` ;
10+ const STATIC_API_BASE_URL_V1 = `${ BASE_URL } /api/v1` ;
11+ const STATIC_API_BASE_URL_V2 = `${ BASE_URL } /api/v2` ;
1112
1213// eslint-disable-next-line @typescript-eslint/no-explicit-any
1314const assertResultIsValid = ( obj : any ) : void => {
@@ -26,30 +27,30 @@ const fetchJson = async <T>(url: string): Promise<T> => {
2627export type UserParam = 'id' | 'name' | 'twitter' ;
2728
2829const fetchContests = ( ) =>
29- fetchJson < Contest [ ] > ( `${ STATIC_API_BASE_URL } /contest/past` ) ;
30+ fetchJson < Contest [ ] > ( `${ STATIC_API_BASE_URL_V1 } /contest/past` ) ;
3031const fetchCurrentContests = ( ) =>
31- fetchJson < Contest [ ] > ( `${ STATIC_API_BASE_URL } /contest/current` ) ;
32+ fetchJson < Contest [ ] > ( `${ STATIC_API_BASE_URL_V1 } /contest/current` ) ;
3233const fetchProblems = ( ) =>
33- fetchJson < Problem [ ] > ( `${ STATIC_API_BASE_URL } /problems` ) ;
34+ fetchJson < Problem [ ] > ( `${ STATIC_API_BASE_URL_V1 } /problems` ) ;
3435const fetchLanguages = ( ) =>
35- fetchJson < Language [ ] > ( `${ STATIC_API_BASE_URL } /languages` ) ;
36+ fetchJson < Language [ ] > ( `${ STATIC_API_BASE_URL_V1 } /languages` ) ;
3637const fetchGolferRanking = ( ) =>
37- fetchJson < RankingProblem [ ] > ( `${ STATIC_API_BASE_URL } /ranking/golfer` ) ;
38+ fetchJson < RankingProblem [ ] > ( `${ STATIC_API_BASE_URL_V2 } /ranking/golfer` ) ;
3839const fetchGolferRankingPure = ( ) =>
39- fetchJson < RankingProblem [ ] > ( `${ STATIC_API_BASE_URL } /ranking/golfer/pure` ) ;
40+ fetchJson < RankingProblem [ ] > ( `${ STATIC_API_BASE_URL_V2 } /ranking/golfer/pure` ) ;
4041const fetchSpeederRanking = ( ) =>
41- fetchJson < RankingProblem [ ] > ( `${ STATIC_API_BASE_URL } /ranking/speeder` ) ;
42+ fetchJson < RankingProblem [ ] > ( `${ STATIC_API_BASE_URL_V2 } /ranking/speeder` ) ;
4243const fetchGolferRankingPureLangId = ( landId : LangId ) =>
4344 fetchJson < RankingProblem [ ] > (
44- `${ STATIC_API_BASE_URL } /ranking/golfer/pure/${ landId } `
45+ `${ STATIC_API_BASE_URL_V2 } /ranking/golfer/pure/${ landId } `
4546 ) ;
4647const fetchUserInfo = ( param : UserParam , user : UserName ) =>
4748 fetchJson < User > (
48- `${ STATIC_API_BASE_URL } /user/${ param } /${ encodeURIComponent ( user ) } `
49+ `${ STATIC_API_BASE_URL_V1 } /user/${ param } /${ encodeURIComponent ( user ) } `
4950 ) ;
5051const fetchSolvedProblems = ( param : UserParam , user : UserName ) =>
5152 fetchJson < SolvedProblem [ ] > (
52- `${ STATIC_API_BASE_URL } /solved/${ param } /${ encodeURIComponent ( user ) } `
53+ `${ STATIC_API_BASE_URL_V1 } /solved/${ param } /${ encodeURIComponent ( user ) } `
5354 ) . then ( ( solvedProblems ) =>
5455 solvedProblems . map ( ( solvedProblem ) => {
5556 solvedProblem . First = false ;
@@ -58,15 +59,17 @@ const fetchSolvedProblems = (param: UserParam, user: UserName) =>
5859 ) ;
5960const fetchFirstSolvedProblems = ( param : UserParam , user : UserName ) =>
6061 fetchJson < FirstSolvedProblem [ ] > (
61- `${ STATIC_API_BASE_URL } /solved/${ param } /${ encodeURIComponent ( user ) } /first`
62+ `${ STATIC_API_BASE_URL_V1 } /solved/${ param } /${ encodeURIComponent (
63+ user
64+ ) } /first`
6265 ) . then ( ( solvedProblems ) =>
6366 solvedProblems . map ( ( solvedProblem ) => {
6467 solvedProblem . First = true ;
6568 return solvedProblem ;
6669 } )
6770 ) ;
6871const fetchSingleProblem = ( problemId : ProblemId ) =>
69- fetchJson < Problem > ( `${ STATIC_API_BASE_URL } /problems/${ problemId } ` ) ;
72+ fetchJson < Problem > ( `${ STATIC_API_BASE_URL_V1 } /problems/${ problemId } ` ) ;
7073
7174// //////////////////
7275// Raw Data
0 commit comments