@@ -60,7 +60,7 @@ const challengesApiInstance = new topcoderApiChallenges.DefaultApi();
6060 * @returns {String } the access token issued by Topcoder
6161 * @private
6262 */
63- async function getAccessToken ( ) {
63+ async function getAccessToken ( ) { // eslint-disable-line no-unused-vars
6464 // Check the cached access token
6565 if ( cachedAccessToken ) {
6666 const decoded = jwtDecode ( cachedAccessToken ) ;
@@ -115,7 +115,7 @@ async function getM2Mtoken() {
115115 * @returns {Number } the created project id
116116 */
117117async function createProject ( projectName ) {
118- bearer . apiKey = await getAccessToken ( ) ;
118+ bearer . apiKey = await getM2Mtoken ( ) ;
119119 // eslint-disable-next-line new-cap
120120 const projectBody = new topcoderApiProjects . ProjectRequestBody . constructFromObject ( {
121121 projectName
@@ -147,7 +147,7 @@ async function createProject(projectName) {
147147 * @returns {Number } the created challenge id
148148 */
149149async function createChallenge ( challenge ) {
150- bearer . apiKey = await getAccessToken ( ) ;
150+ bearer . apiKey = await getM2Mtoken ( ) ;
151151 const start = new Date ( ) ;
152152 const startTime = moment ( start ) . toISOString ( ) ;
153153 const end = moment ( start ) . add ( config . NEW_CHALLENGE_DURATION_IN_DAYS , 'days' ) . toISOString ( ) ;
@@ -188,7 +188,7 @@ async function createChallenge(challenge) {
188188 * @param {Object } challenge the challenge to update
189189 */
190190async function updateChallenge ( id , challenge ) {
191- bearer . apiKey = await getAccessToken ( ) ;
191+ bearer . apiKey = await getM2Mtoken ( ) ;
192192 logger . debug ( `Updating challenge ${ id } with ${ circularJSON . stringify ( challenge ) } ` ) ;
193193 // eslint-disable-next-line new-cap
194194 const challengeBody = new topcoderApiChallenges . UpdateChallengeBodyParam . constructFromObject ( {
@@ -226,7 +226,7 @@ async function updateChallenge(id, challenge) {
226226 * @param {Number } id the challenge id
227227 */
228228async function activateChallenge ( id ) {
229- bearer . apiKey = await getAccessToken ( ) ;
229+ bearer . apiKey = await getM2Mtoken ( ) ;
230230 logger . debug ( `Activating challenge ${ id } ` ) ;
231231 try {
232232 const response = await new Promise ( ( resolve , reject ) => {
@@ -266,7 +266,7 @@ async function getChallengeById(id) {
266266 if ( ! _ . isNumber ( id ) ) {
267267 throw new Error ( 'The challenge id must valid number' ) ;
268268 }
269- const apiKey = await getAccessToken ( ) ;
269+ const apiKey = await getM2Mtoken ( ) ;
270270 logger . debug ( 'Getting topcoder challenge details' ) ;
271271 try {
272272 const response = await axios . get ( `${ challengesClient . basePath } /challenges/${ id } ` , {
@@ -297,7 +297,7 @@ async function getChallengeById(id) {
297297 * @param {Number } winnerId the winner id
298298 */
299299async function closeChallenge ( id , winnerId ) {
300- const apiKey = await getAccessToken ( ) ;
300+ const apiKey = await getM2Mtoken ( ) ;
301301 logger . debug ( `Closing challenge ${ id } ` ) ;
302302 try {
303303 const basePath = challengesClient . basePath ;
@@ -328,7 +328,7 @@ async function closeChallenge(id, winnerId) {
328328 * @returns {Number } the billing account id
329329 */
330330async function getProjectBillingAccountId ( id ) {
331- const apiKey = await getAccessToken ( ) ;
331+ const apiKey = await getM2Mtoken ( ) ;
332332 logger . debug ( `Getting project billing detail ${ id } ` ) ;
333333 try {
334334 const response = await axios . get ( `${ projectsClient . basePath } /direct/projects/${ id } ` , {
@@ -360,7 +360,7 @@ async function getProjectBillingAccountId(id) {
360360 * @returns {Number } the user id
361361 */
362362async function getTopcoderMemberId ( handle ) {
363- bearer . apiKey = await getAccessToken ( ) ;
363+ bearer . apiKey = await getM2Mtoken ( ) ;
364364 try {
365365 const response = await axios . get ( `${ projectsClient . basePath } /members/${ handle } ` ) ;
366366 const statusCode = response ? response . status : null ;
@@ -379,7 +379,7 @@ async function getTopcoderMemberId(handle) {
379379 * @param {Object } resource the resource resource to add
380380 */
381381async function addResourceToChallenge ( id , resource ) {
382- bearer . apiKey = await getAccessToken ( ) ;
382+ bearer . apiKey = await getM2Mtoken ( ) ;
383383 logger . debug ( `adding resource to challenge ${ id } ` ) ;
384384 try {
385385 const response = await new Promise ( ( resolve , reject ) => {
@@ -420,7 +420,7 @@ async function getResourcesFromChallenge(id) {
420420 if ( ! _ . isNumber ( id ) ) {
421421 throw new Error ( 'The challenge id must valid number' ) ;
422422 }
423- const apiKey = await getAccessToken ( ) ;
423+ const apiKey = await getM2Mtoken ( ) ;
424424 logger . debug ( `fetch resource from challenge ${ id } ` ) ;
425425 try {
426426 const response = await axios . get ( `${ challengesClient . basePath } /challenges/${ id } /resources` , {
@@ -465,7 +465,7 @@ async function roleAlreadySet(id, role) {
465465 * @param {Object } resource the resource resource to remove
466466 */
467467async function unregisterUserFromChallenge ( id ) {
468- bearer . apiKey = await getAccessToken ( ) ;
468+ bearer . apiKey = await getM2Mtoken ( ) ;
469469 logger . debug ( `removing resource from challenge ${ id } ` ) ;
470470 try {
471471 const response = await new Promise ( ( resolve , reject ) => {
@@ -502,7 +502,7 @@ async function unregisterUserFromChallenge(id) {
502502 * @param {Number } id the challenge id
503503 */
504504async function cancelPrivateContent ( id ) {
505- bearer . apiKey = await getAccessToken ( ) ;
505+ bearer . apiKey = await getM2Mtoken ( ) ;
506506 logger . debug ( `Cancelling challenge ${ id } ` ) ;
507507 try {
508508 const response = await new Promise ( ( resolve , reject ) => {
@@ -550,7 +550,7 @@ async function assignUserAsRegistrant(topcoderUserId, challengeId) {
550550 * @param {Object } resource the resource resource to remove
551551 */
552552async function removeResourceToChallenge ( id , resource ) {
553- bearer . apiKey = await getAccessToken ( ) ;
553+ bearer . apiKey = await getM2Mtoken ( ) ;
554554 logger . debug ( `removing resource from challenge ${ id } ` ) ;
555555 try {
556556 const response = await new Promise ( ( resolve , reject ) => {
@@ -580,7 +580,7 @@ async function removeResourceToChallenge(id, resource) {
580580 * @returns {Array } the resources of challenge
581581 */
582582async function getChallengeResources ( id ) {
583- const apiKey = await getAccessToken ( ) ;
583+ const apiKey = await getM2Mtoken ( ) ;
584584 logger . debug ( `getting resource from challenge ${ id } ` ) ;
585585 try {
586586 const response = await axios . get ( `${ challengesClient . basePath } /challenges/${ id } /resources` , {
0 commit comments