@@ -60,7 +60,7 @@ const challengesApiInstance = new topcoderApiChallenges.DefaultApi();
60
60
* @returns {String } the access token issued by Topcoder
61
61
* @private
62
62
*/
63
- async function getAccessToken ( ) {
63
+ async function getAccessToken ( ) { // eslint-disable-line no-unused-vars
64
64
// Check the cached access token
65
65
if ( cachedAccessToken ) {
66
66
const decoded = jwtDecode ( cachedAccessToken ) ;
@@ -115,7 +115,7 @@ async function getM2Mtoken() {
115
115
* @returns {Number } the created project id
116
116
*/
117
117
async function createProject ( projectName ) {
118
- bearer . apiKey = await getAccessToken ( ) ;
118
+ bearer . apiKey = await getM2Mtoken ( ) ;
119
119
// eslint-disable-next-line new-cap
120
120
const projectBody = new topcoderApiProjects . ProjectRequestBody . constructFromObject ( {
121
121
projectName
@@ -147,7 +147,7 @@ async function createProject(projectName) {
147
147
* @returns {Number } the created challenge id
148
148
*/
149
149
async function createChallenge ( challenge ) {
150
- bearer . apiKey = await getAccessToken ( ) ;
150
+ bearer . apiKey = await getM2Mtoken ( ) ;
151
151
const start = new Date ( ) ;
152
152
const startTime = moment ( start ) . toISOString ( ) ;
153
153
const end = moment ( start ) . add ( config . NEW_CHALLENGE_DURATION_IN_DAYS , 'days' ) . toISOString ( ) ;
@@ -188,7 +188,7 @@ async function createChallenge(challenge) {
188
188
* @param {Object } challenge the challenge to update
189
189
*/
190
190
async function updateChallenge ( id , challenge ) {
191
- bearer . apiKey = await getAccessToken ( ) ;
191
+ bearer . apiKey = await getM2Mtoken ( ) ;
192
192
logger . debug ( `Updating challenge ${ id } with ${ circularJSON . stringify ( challenge ) } ` ) ;
193
193
// eslint-disable-next-line new-cap
194
194
const challengeBody = new topcoderApiChallenges . UpdateChallengeBodyParam . constructFromObject ( {
@@ -226,7 +226,7 @@ async function updateChallenge(id, challenge) {
226
226
* @param {Number } id the challenge id
227
227
*/
228
228
async function activateChallenge ( id ) {
229
- bearer . apiKey = await getAccessToken ( ) ;
229
+ bearer . apiKey = await getM2Mtoken ( ) ;
230
230
logger . debug ( `Activating challenge ${ id } ` ) ;
231
231
try {
232
232
const response = await new Promise ( ( resolve , reject ) => {
@@ -266,7 +266,7 @@ async function getChallengeById(id) {
266
266
if ( ! _ . isNumber ( id ) ) {
267
267
throw new Error ( 'The challenge id must valid number' ) ;
268
268
}
269
- const apiKey = await getAccessToken ( ) ;
269
+ const apiKey = await getM2Mtoken ( ) ;
270
270
logger . debug ( 'Getting topcoder challenge details' ) ;
271
271
try {
272
272
const response = await axios . get ( `${ challengesClient . basePath } /challenges/${ id } ` , {
@@ -297,7 +297,7 @@ async function getChallengeById(id) {
297
297
* @param {Number } winnerId the winner id
298
298
*/
299
299
async function closeChallenge ( id , winnerId ) {
300
- const apiKey = await getAccessToken ( ) ;
300
+ const apiKey = await getM2Mtoken ( ) ;
301
301
logger . debug ( `Closing challenge ${ id } ` ) ;
302
302
try {
303
303
const basePath = challengesClient . basePath ;
@@ -328,7 +328,7 @@ async function closeChallenge(id, winnerId) {
328
328
* @returns {Number } the billing account id
329
329
*/
330
330
async function getProjectBillingAccountId ( id ) {
331
- const apiKey = await getAccessToken ( ) ;
331
+ const apiKey = await getM2Mtoken ( ) ;
332
332
logger . debug ( `Getting project billing detail ${ id } ` ) ;
333
333
try {
334
334
const response = await axios . get ( `${ projectsClient . basePath } /direct/projects/${ id } ` , {
@@ -360,7 +360,7 @@ async function getProjectBillingAccountId(id) {
360
360
* @returns {Number } the user id
361
361
*/
362
362
async function getTopcoderMemberId ( handle ) {
363
- bearer . apiKey = await getAccessToken ( ) ;
363
+ bearer . apiKey = await getM2Mtoken ( ) ;
364
364
try {
365
365
const response = await axios . get ( `${ projectsClient . basePath } /members/${ handle } ` ) ;
366
366
const statusCode = response ? response . status : null ;
@@ -379,7 +379,7 @@ async function getTopcoderMemberId(handle) {
379
379
* @param {Object } resource the resource resource to add
380
380
*/
381
381
async function addResourceToChallenge ( id , resource ) {
382
- bearer . apiKey = await getAccessToken ( ) ;
382
+ bearer . apiKey = await getM2Mtoken ( ) ;
383
383
logger . debug ( `adding resource to challenge ${ id } ` ) ;
384
384
try {
385
385
const response = await new Promise ( ( resolve , reject ) => {
@@ -420,7 +420,7 @@ async function getResourcesFromChallenge(id) {
420
420
if ( ! _ . isNumber ( id ) ) {
421
421
throw new Error ( 'The challenge id must valid number' ) ;
422
422
}
423
- const apiKey = await getAccessToken ( ) ;
423
+ const apiKey = await getM2Mtoken ( ) ;
424
424
logger . debug ( `fetch resource from challenge ${ id } ` ) ;
425
425
try {
426
426
const response = await axios . get ( `${ challengesClient . basePath } /challenges/${ id } /resources` , {
@@ -465,7 +465,7 @@ async function roleAlreadySet(id, role) {
465
465
* @param {Object } resource the resource resource to remove
466
466
*/
467
467
async function unregisterUserFromChallenge ( id ) {
468
- bearer . apiKey = await getAccessToken ( ) ;
468
+ bearer . apiKey = await getM2Mtoken ( ) ;
469
469
logger . debug ( `removing resource from challenge ${ id } ` ) ;
470
470
try {
471
471
const response = await new Promise ( ( resolve , reject ) => {
@@ -502,7 +502,7 @@ async function unregisterUserFromChallenge(id) {
502
502
* @param {Number } id the challenge id
503
503
*/
504
504
async function cancelPrivateContent ( id ) {
505
- bearer . apiKey = await getAccessToken ( ) ;
505
+ bearer . apiKey = await getM2Mtoken ( ) ;
506
506
logger . debug ( `Cancelling challenge ${ id } ` ) ;
507
507
try {
508
508
const response = await new Promise ( ( resolve , reject ) => {
@@ -550,7 +550,7 @@ async function assignUserAsRegistrant(topcoderUserId, challengeId) {
550
550
* @param {Object } resource the resource resource to remove
551
551
*/
552
552
async function removeResourceToChallenge ( id , resource ) {
553
- bearer . apiKey = await getAccessToken ( ) ;
553
+ bearer . apiKey = await getM2Mtoken ( ) ;
554
554
logger . debug ( `removing resource from challenge ${ id } ` ) ;
555
555
try {
556
556
const response = await new Promise ( ( resolve , reject ) => {
@@ -580,7 +580,7 @@ async function removeResourceToChallenge(id, resource) {
580
580
* @returns {Array } the resources of challenge
581
581
*/
582
582
async function getChallengeResources ( id ) {
583
- const apiKey = await getAccessToken ( ) ;
583
+ const apiKey = await getM2Mtoken ( ) ;
584
584
logger . debug ( `getting resource from challenge ${ id } ` ) ;
585
585
try {
586
586
const response = await axios . get ( `${ challengesClient . basePath } /challenges/${ id } /resources` , {
0 commit comments