Skip to content

Commit 7b86e27

Browse files
committed
feat: support Project Service V5
1 parent 94f84ca commit 7b86e27

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

connect/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = {
66
// TC API related variables
77
TC_API_V3_BASE_URL: process.env.TC_API_V3_BASE_URL || 'https://api.topcoder-dev.com/v3',
88
TC_API_V4_BASE_URL: process.env.TC_API_V4_BASE_URL || 'https://api.topcoder-dev.com/v4',
9+
TC_API_V5_BASE_URL: process.env.TC_API_V5_BASE_URL || 'https://api.topcoder-dev.com/v5',
910
MESSAGE_API_BASE_URL: process.env.MESSAGE_API_BASE_URL || 'https://api.topcoder-dev.com/v5',
1011

1112
// id of the BOT user which creates post with various events in discussions

connect/service.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ const getProject = (projectId) => (
1919
M2m.getMachineToken(config.AUTH0_CLIENT_ID, config.AUTH0_CLIENT_SECRET)
2020
.then((token) => (
2121
request
22-
.get(`${config.TC_API_V4_BASE_URL}/projects/${projectId}`)
22+
.get(`${config.TC_API_V5_BASE_URL}/projects/${projectId}`)
2323
.set('accept', 'application/json')
2424
.set('authorization', `Bearer ${token}`)
2525
.then((res) => {
26-
if (!_.get(res, 'body.result.success')) {
26+
const project = res.body;
27+
if (!project) {
2728
throw new Error(`Failed to get project details of project id: ${projectId}`);
2829
}
29-
const project = _.get(res, 'body.result.content');
3030
return project;
3131
}).catch((err) => {
32-
const errorDetails = _.get(err, 'response.body.result.content.message');
32+
const errorDetails = _.get(err, 'response.body.message');
3333
throw new Error(
3434
`Failed to get project details of project id: ${projectId}.` +
3535
(errorDetails ? ' Server response: ' + errorDetails : '')
@@ -244,17 +244,17 @@ const getPhase = (projectId, phaseId) => (
244244
M2m.getMachineToken(config.AUTH0_CLIENT_ID, config.AUTH0_CLIENT_SECRET)
245245
.then((token) => (
246246
request
247-
.get(`${config.TC_API_V4_BASE_URL}/projects/${projectId}/phases/${phaseId}`)
247+
.get(`${config.TC_API_V5_BASE_URL}/projects/${projectId}/phases/${phaseId}`)
248248
.set('accept', 'application/json')
249249
.set('authorization', `Bearer ${token}`)
250250
.then((res) => {
251-
if (!_.get(res, 'body.result.success')) {
251+
const project = res.body;
252+
if (!project) {
252253
throw new Error(`Failed to get phase details of project id: ${projectId}, phase id: ${phaseId}`);
253254
}
254-
const project = _.get(res, 'body.result.content');
255255
return project;
256256
}).catch((err) => {
257-
const errorDetails = _.get(err, 'response.body.result.content.message');
257+
const errorDetails = _.get(err, 'response.body.message');
258258
throw new Error(
259259
`Failed to get phase details of project id: ${projectId}, phase id: ${phaseId}.` +
260260
(errorDetails ? ' Server response: ' + errorDetails : '')

0 commit comments

Comments
 (0)