@@ -10,8 +10,8 @@ import qs from 'qs';
10
10
import { decodeToken } from 'tc-accounts' ;
11
11
import logger from '../utils/logger' ;
12
12
import { setErrorIcon , ERROR_ICON_TYPES } from '../utils/errors' ;
13
- import { COMPETITION_TRACKS , getApiResponsePayloadV3 } from '../utils/tc' ;
14
- import { getApiV2 , getApiV3 , getApiV4 } from './api' ;
13
+ import { COMPETITION_TRACKS , getApiResponsePayload } from '../utils/tc' ;
14
+ import { getApiV2 , getApiV4 } from './api' ;
15
15
16
16
export const ORDER_BY = {
17
17
SUBMISSION_END_DATE : 'submissionEndDate' ,
@@ -86,7 +86,7 @@ export function normalizeChallengeDetails(v4, v4Filtered, v4User, username) {
86
86
registrants : v4 . registrants || [ ] ,
87
87
} ;
88
88
89
- // v4 Winners have different field names, needs to be normalized to match v4 filtered and v3
89
+ // v4 Winners have different field names, needs to be normalized to match v4 filtered and v4
90
90
challenge . winners = _ . map (
91
91
v4 . winners ,
92
92
( winner , index ) => ( {
@@ -117,22 +117,22 @@ export function normalizeChallengeDetails(v4, v4Filtered, v4User, username) {
117
117
componentId : v4Filtered . componentId ,
118
118
contestId : v4Filtered . contestId ,
119
119
120
- submissionEndDate : v4Filtered . submissionEndDate , // Dates are not correct in v3
121
- submissionEndTimestamp : v4Filtered . submissionEndDate , // Dates are not correct in v3
120
+ submissionEndDate : v4Filtered . submissionEndDate , // Dates are not correct in v4
121
+ submissionEndTimestamp : v4Filtered . submissionEndDate , // Dates are not correct in v4
122
122
123
- /* Taking phases from v3_filtered , because dates are not correct in v3 */
123
+ /* Taking phases from v4_filtered , because dates are not correct in v4 */
124
124
allPhases : v4Filtered . allPhases || [ ] ,
125
125
126
- /* Taking phases from v3_filtered , because dates are not correct in v3 */
126
+ /* Taking phases from v4_filtered , because dates are not correct in v4 */
127
127
currentPhases : v4Filtered . currentPhases || [ ] ,
128
128
129
- /* v3 returns incorrect value for numberOfSubmissions for some reason */
129
+ /* v4 returns incorrect value for numberOfSubmissions for some reason */
130
130
numSubmissions : v4Filtered . numSubmissions ,
131
131
groups,
132
132
} ) ;
133
133
}
134
134
135
- // Fill missing data from v3_user
135
+ // Fill missing data from v4_user
136
136
if ( v4User ) {
137
137
_ . defaults ( challenge , {
138
138
userDetails : v4User . userDetails ,
@@ -168,7 +168,7 @@ export function normalizeChallengeDetails(v4, v4Filtered, v4User, username) {
168
168
* Normalizes a regular challenge object received from the backend.
169
169
* NOTE: This function is copied from the existing code in the challenge listing
170
170
* component. It is possible, that this normalization is not necessary after we
171
- * have moved to Topcoder API v3 , but it is kept for now to minimize a risk of
171
+ * have moved to Topcoder API v4 , but it is kept for now to minimize a risk of
172
172
* breaking anything.
173
173
* @todo Should be used only internally!
174
174
* @param {Object } challenge Challenge object received from the backend.
@@ -251,7 +251,7 @@ class ChallengesService {
251
251
...params ,
252
252
} ;
253
253
const url = `${ endpoint } ?${ qs . stringify ( query ) } ` ;
254
- const res = await this . private . apiV4 . get ( url ) . then ( checkError ) ;
254
+ const res = await this . private . api . get ( url ) . then ( checkError ) ;
255
255
return {
256
256
challenges : res . content || [ ] ,
257
257
totalCount : res . metadata . totalCount ,
@@ -261,7 +261,6 @@ class ChallengesService {
261
261
this . private = {
262
262
api : getApiV4 ( tokenV3 ) ,
263
263
apiV2 : getApiV2 ( tokenV2 ) ,
264
- apiV4 : getApiV4 ( tokenV3 ) ,
265
264
getChallenges,
266
265
tokenV2,
267
266
tokenV3,
@@ -359,14 +358,14 @@ class ChallengesService {
359
358
360
359
/**
361
360
* Gets challenge details from Topcoder API v4.
362
- * NOTE: This function also uses API v2 and other v3 endpoints for now, due
361
+ * NOTE: This function also uses API v2 and other v4 endpoints for now, due
363
362
* to some information is missing or
364
- * incorrect in the main v3 endpoint. This may change in the future.
363
+ * incorrect in the main v4 endpoint. This may change in the future.
365
364
* @param {Number|String } challengeId
366
365
* @return {Promise } Resolves to the challenge object.
367
366
*/
368
367
async getChallengeDetails ( challengeId ) {
369
- const challengeV4 = await this . private . apiV4 . get ( `/challenges/${ challengeId } ` )
368
+ const challengeV4 = await this . private . api . get ( `/challenges/${ challengeId } ` )
370
369
. then ( checkError ) . then ( res => res . content ) ;
371
370
372
371
const challengeV4Filtered = await this . private . getChallenges ( '/challenges/' , { id : challengeId } )
@@ -437,7 +436,7 @@ class ChallengesService {
437
436
*/
438
437
async getSrms ( params ) {
439
438
const res = await this . private . api . get ( `/srms/?${ qs . stringify ( params ) } ` ) ;
440
- return getApiResponsePayloadV3 ( res ) ;
439
+ return getApiResponsePayload ( res ) ;
441
440
}
442
441
443
442
/**
@@ -466,7 +465,7 @@ class ChallengesService {
466
465
async getUserSrms ( handle , params ) {
467
466
const url = `/members/${ handle } /srms/?${ qs . stringify ( params ) } ` ;
468
467
const res = await this . private . api . get ( url ) ;
469
- return getApiResponsePayloadV3 ( res ) ;
468
+ return getApiResponsePayload ( res ) ;
470
469
}
471
470
472
471
/**
@@ -476,7 +475,7 @@ class ChallengesService {
476
475
*/
477
476
async register ( challengeId ) {
478
477
const endpoint = `/challenges/${ challengeId } /register` ;
479
- const res = await this . private . apiV4 . postJson ( endpoint ) ;
478
+ const res = await this . private . api . postJson ( endpoint ) ;
480
479
if ( ! res . ok ) throw new Error ( res . statusText ) ;
481
480
return res . json ( ) ;
482
481
}
@@ -488,7 +487,7 @@ class ChallengesService {
488
487
*/
489
488
async unregister ( challengeId ) {
490
489
const endpoint = `/challenges/${ challengeId } /unregister` ;
491
- const res = await this . private . apiV4 . post ( endpoint ) ;
490
+ const res = await this . private . api . post ( endpoint ) ;
492
491
if ( ! res . ok ) throw new Error ( res . statusText ) ;
493
492
return res . json ( ) ;
494
493
}
0 commit comments