@@ -39,7 +39,7 @@ async function createPayment (options) {
3939 const challengeId = await createChallenge ( options , token )
4040 await addResourceToChallenge ( challengeId , options . userHandle , token )
4141 await activateChallenge ( challengeId , token )
42- const completedChallenge = await closeChallenge ( challengeId , token )
42+ const completedChallenge = await closeChallenge ( challengeId , options . userHandle , token )
4343 return completedChallenge
4444}
4545
@@ -146,14 +146,21 @@ async function activateChallenge (id, token) {
146146/**
147147 * closes the topcoder challenge
148148 * @param {String } id the challenge id
149+ * @param {String } userHandle the user handle
149150 * @param {String } token m2m token
150151 * @returns {Object } the closed challenge
151152 */
152- async function closeChallenge ( id , token ) {
153+ async function closeChallenge ( id , userHandle , token ) {
153154 localLogger . info ( { context : 'closeChallenge' , message : `Closing challenge ${ id } ` } )
154155 try {
156+ const { userId } = await helper . getV3MemberDetailsByHandle ( userHandle )
155157 const body = {
156- status : constants . ChallengeStatus . COMPLETED
158+ status : constants . ChallengeStatus . COMPLETED ,
159+ winners : [ {
160+ userId,
161+ handle : userHandle ,
162+ placement : 1
163+ } ]
157164 }
158165 const response = await helper . updateChallenge ( id , body , token )
159166 localLogger . info ( { context : 'closeChallenge' , message : `Challenge ${ id } is closed successfully.` } )
0 commit comments