diff --git a/README.md b/README.md index 13f5f4ea..13ce0505 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,6 @@ The following parameters can be set in config files or in env variables: - ES.ES_REFRESH: Elasticsearch refresh method. Default to string `true`(i.e. refresh immediately) - FILE_UPLOAD_SIZE_LIMIT: the file upload size limit in bytes - RESOURCES_API_URL: TC resources API base URL -- V3_PROJECTS_API_URL: TC direct projects API base URL - GROUPS_API_URL: TC groups API base URL - PROJECTS_API_URL: TC projects API base URL - TERMS_API_URL: TC Terms API Base URL diff --git a/config/default.js b/config/default.js index bd64f4eb..1fd2d89a 100644 --- a/config/default.js +++ b/config/default.js @@ -54,7 +54,6 @@ module.exports = { GROUPS_API_URL: process.env.GROUPS_API_URL || 'http://localhost:4000/v5/groups', PROJECTS_API_URL: process.env.PROJECTS_API_URL || 'http://localhost:4000/v5/projects', TERMS_API_URL: process.env.TERMS_API_URL || 'http://localhost:4000/v5/terms', - V3_PROJECTS_API_URL: process.env.V3_PROJECTS_API_URL || 'http://localhost:4000/v3/direct/projects', // copilot resource role ids allowed to upload attachment COPILOT_RESOURCE_ROLE_IDS: process.env.COPILOT_RESOURCE_ROLE_IDS ? process.env.COPILOT_RESOURCE_ROLE_IDS.split(',') : ['10ba038e-48da-487b-96e8-8d3b99b6d18b'], diff --git a/src/common/helper.js b/src/common/helper.js index 4802b102..513af441 100644 --- a/src/common/helper.js +++ b/src/common/helper.js @@ -759,10 +759,10 @@ async function getProjectDefaultTerms (projectId) { */ async function getProjectBillingAccount (projectId) { const token = await getM2MToken() - const projectUrl = `${config.V3_PROJECTS_API_URL}/${projectId}` + const projectUrl = `${config.PROJECTS_API_URL}/${projectId}` try { const res = await axios.get(projectUrl, { headers: { Authorization: `Bearer ${token}` } }) - return _.get(res, 'data.result.content.billingAccountIds[0]', null) + return _.get(res, 'data.billingAccountId', null) } catch (err) { if (_.get(err, 'response.status') === HttpStatus.NOT_FOUND) { throw new errors.BadRequestError(`Project with id: ${projectId} doesn't exist`) diff --git a/src/services/ChallengeService.js b/src/services/ChallengeService.js index 3805556b..757145c2 100644 --- a/src/services/ChallengeService.js +++ b/src/services/ChallengeService.js @@ -1209,7 +1209,7 @@ async function update (currentUser, challengeId, data, isFull) { if (!_.get(challenge, 'legacy.pureV5Task') && _.isUndefined(_.get(challenge, 'legacy.directProjectId'))) { throw new errors.BadRequestError('You cannot activate the challenge as it has not been created on legacy yet. Please try again later or contact support.') } - billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'legacy.directProjectId')) + billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'projectId')) // if activating a challenge, the challenge must have a billing account id if ((!billingAccountId || billingAccountId === null) && challenge.status === constants.challengeStatuses.Draft) { @@ -1220,7 +1220,7 @@ async function update (currentUser, challengeId, data, isFull) { if (challenge.status !== constants.challengeStatuses.Active) { throw new errors.BadRequestError('You cannot mark a Draft challenge as Completed') } - billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'legacy.directProjectId')) + billingAccountId = await helper.getProjectBillingAccount(_.get(challenge, 'projectId')) } }