@@ -35,6 +35,12 @@ export const ORDER_BY = {
35
35
* @return {Object } Normalized challenge object.
36
36
*/
37
37
export function normalizeChallengeDetails ( challenge , filtered , user , username ) {
38
+ // FIXME: This has not been updated to use V5
39
+ // We should not be modifying the challenge data to get it in shape.
40
+ // Instead, we should be modifying the frontend to be able to
41
+ // consume the data as it comes from the API.
42
+ // So, Ideally, this method should be removed
43
+ // ------------------------------------
38
44
// Normalize exising data to make it consistent with the rest of the code
39
45
const finalChallenge = {
40
46
...challenge ,
@@ -173,6 +179,11 @@ export function normalizeChallengeDetails(challenge, filtered, user, username) {
173
179
* @param {String } username Optional.
174
180
*/
175
181
export function normalizeChallenge ( challenge , username ) {
182
+ // FIXME: This has not been updated to use V5
183
+ // We should not be modifying the challenge data to get it in shape.
184
+ // Instead, we should be modifying the frontend to be able to
185
+ // consume the data as it comes from the API.
186
+ // So, Ideally, this method should be removed
176
187
const registrationOpen = ( challenge . allPhases || challenge . phases || [ ] ) . filter ( d => ( d . name === 'Registration' || ! d . name ) ) [ 0 ] . isOpen ? 'Yes' : 'No' ;
177
188
const groups = { } ;
178
189
if ( challenge . groupIds ) {
@@ -304,6 +315,9 @@ class ChallengesService {
304
315
...params ,
305
316
} ;
306
317
const url = `${ endpoint } ?${ qs . stringify ( query ) } ` ;
318
+ // FIXME: This has not been updated to use the V5 API
319
+ // Ref: http://api.topcoder-dev.com/v5/challenges/docs/#/Challenges/get_challenges
320
+ // Use the `memberId` query parameter to filter challenges for a specific member
307
321
const res = await this . private . api . get ( url ) . then ( checkError ) ;
308
322
return {
309
323
challenges : res . content || [ ] ,
@@ -353,7 +367,7 @@ class ChallengesService {
353
367
const params = {
354
368
status : 'Completed' ,
355
369
} ;
356
- let res = await this . private . apiV5 . patch ( `/challenges/${ challengeId } /close ` , params ) ;
370
+ let res = await this . private . apiV5 . patch ( `/challenges/${ challengeId } ` , params ) ;
357
371
if ( ! res . ok ) throw new Error ( res . statusText ) ;
358
372
res = ( await res . json ( ) ) . result ;
359
373
if ( res . status !== 200 ) throw new Error ( res . content ) ;
@@ -387,6 +401,7 @@ class ChallengesService {
387
401
tags ,
388
402
) {
389
403
const payload = {
404
+ // FIXME: This has not been updated to use the v5 API
390
405
param : {
391
406
assignees : [ assignee ] ,
392
407
billingAccountId : accountId ,
@@ -457,6 +472,10 @@ class ChallengesService {
457
472
* @return {Promise } Resolves to the challenge registrants array.
458
473
*/
459
474
async getChallengeRegistrants ( challengeId ) {
475
+ // FIXME: The implementation here is wrong.
476
+ // The correct implementation would be to call the Resources API to fetch the
477
+ // resources for the given challenge and filter based on the registrant resource role ID
478
+ // Ref: http://api.topcoder-dev.com/v5/resources/docs/#/Resources/get_resources
460
479
const challenge = await this . private . apiV5 . get ( `/challenges/${ challengeId } ` )
461
480
. then ( checkError ) . then ( res => res ) ;
462
481
return challenge . registrants || [ ] ;
@@ -532,6 +551,7 @@ class ChallengesService {
532
551
* @return {Promise } Resolves to the api response.
533
552
*/
534
553
getUserChallenges ( username , filters , params ) {
554
+ // FIXME: This has not been updated to use the V5 API
535
555
const userFilters = _ . cloneDeep ( filters ) ;
536
556
ChallengesService . updateFiltersParamsForGettingMemberChallenges ( userFilters , params ) ;
537
557
const endpoint = `/members/${ username . toLowerCase ( ) } /challenges/` ;
@@ -550,6 +570,7 @@ class ChallengesService {
550
570
* @return {Promise } Resolves to the api response.
551
571
*/
552
572
getUserMarathonMatches ( username , filters , params ) {
573
+ // FIXME: This has not been updated to use the V5 API
553
574
ChallengesService . updateFiltersParamsForGettingMemberChallenges ( filters , params ) ;
554
575
const endpoint = `/members/${ username . toLowerCase ( ) } /mms/` ;
555
576
return this . private . getMemberChallenges ( endpoint , filters , params ) ;
@@ -562,6 +583,7 @@ class ChallengesService {
562
583
* @return {Promise }
563
584
*/
564
585
async getUserSrms ( handle , params ) {
586
+ // FIXME: This has not been updated to use the V5 API
565
587
const url = `/members/${ handle } /srms/?${ qs . stringify ( params ) } ` ;
566
588
const res = await this . private . api . get ( url ) ;
567
589
return getApiResponsePayload ( res ) ;
@@ -594,7 +616,7 @@ class ChallengesService {
594
616
const params = {
595
617
challengeId, memberHandle, roleId,
596
618
} ;
597
- const res = await this . private . apiV5 . post ( '/resources' , params ) ;
619
+ const res = await this . private . apiV5 . delete ( '/resources' , params ) ;
598
620
if ( ! res . ok ) throw new Error ( res . statusText ) ;
599
621
return res . json ( ) ;
600
622
}
0 commit comments