Skip to content

Commit 869abbb

Browse files
committed
Update to include challenge-api-version header in challenge API requests
1 parent 88b229e commit 869abbb

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

config/constants/development.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ module.exports = {
1313
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
1414
MEMBER_API_URL: `${DEV_API_HOSTNAME}/v5/members`,
1515
CHALLENGE_API_URL: `${DEV_API_HOSTNAME}/v5/challenges`,
16+
CHALLENGE_API_VERSION: '1.1.0',
1617
CHALLENGE_TIMELINE_TEMPLATES_URL: `${DEV_API_HOSTNAME}/v5/timeline-templates`,
1718
CHALLENGE_TYPES_URL: `${DEV_API_HOSTNAME}/v5/challenge-types`,
1819
CHALLENGE_TRACKS_URL: `${DEV_API_HOSTNAME}/v5/challenge-tracks`,

config/constants/production.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ module.exports = {
1212
COMMUNITY_APP_URL: `https://www.${DOMAIN}`,
1313
MEMBER_API_URL: `${PROD_API_HOSTNAME}/v5/members`,
1414
CHALLENGE_API_URL: `${PROD_API_HOSTNAME}/v5/challenges`,
15+
CHALLENGE_API_VERSION: '1.1.0',
1516
CHALLENGE_TIMELINE_TEMPLATES_URL: `${PROD_API_HOSTNAME}/v5/timeline-templates`,
1617
CHALLENGE_TYPES_URL: `${PROD_API_HOSTNAME}/v5/challenge-types`,
1718
CHALLENGE_TRACKS_URL: `${PROD_API_HOSTNAME}/v5/challenge-tracks`,

src/services/challenges.js

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { updateChallengePhaseBeforeSendRequest, convertChallengePhaseFromSeconds
55
import { GROUPS_DROPDOWN_PER_PAGE, UPDATE_SKILLS_V5_API_URL } from '../config/constants'
66
const {
77
CHALLENGE_API_URL,
8+
CHALLENGE_API_VERSION,
89
CHALLENGE_TYPES_URL,
910
CHALLENGE_TRACKS_URL,
1011
CHALLENGE_TIMELINE_TEMPLATES_URL,
@@ -97,7 +98,11 @@ export async function fetchChallengePhases () {
9798
* @returns {Promise<*>}
9899
*/
99100
export async function fetchChallenge (challengeId) {
100-
const response = await axiosInstance.get(`${CHALLENGE_API_URL}/${challengeId}`)
101+
const response = await axiosInstance.get(`${CHALLENGE_API_URL}/${challengeId}`, {
102+
headers: {
103+
'challenge-api-version': CHALLENGE_API_VERSION
104+
}
105+
})
101106
return normalizeChallengeDataFromAPI(_.get(response, 'data'))
102107
}
103108

@@ -107,7 +112,11 @@ export async function fetchChallenge (challengeId) {
107112
* @returns {Promise<*>} challenge data
108113
*/
109114
export function createChallenge (challenge) {
110-
return axiosInstance.post(CHALLENGE_API_URL, updateChallengePhaseBeforeSendRequest(challenge)).then(response => {
115+
return axiosInstance.post(CHALLENGE_API_URL, updateChallengePhaseBeforeSendRequest(challenge), {
116+
headers: {
117+
'challenge-api-version': CHALLENGE_API_VERSION
118+
}
119+
}).then(response => {
111120
return normalizeChallengeDataFromAPI(_.get(response, 'data'))
112121
})
113122
}
@@ -119,7 +128,11 @@ export function createChallenge (challenge) {
119128
* @returns {Promise<*>} challenge data
120129
*/
121130
export function updateChallenge (challengeId, challenge) {
122-
return axiosInstance.put(`${CHALLENGE_API_URL}/${challengeId}`, updateChallengePhaseBeforeSendRequest(challenge)).then(response => {
131+
return axiosInstance.put(`${CHALLENGE_API_URL}/${challengeId}`, updateChallengePhaseBeforeSendRequest(challenge), {
132+
headers: {
133+
'challenge-api-version': CHALLENGE_API_VERSION
134+
}
135+
}).then(response => {
123136
return normalizeChallengeDataFromAPI(_.get(response, 'data'))
124137
})
125138
}
@@ -133,7 +146,11 @@ export function updateChallenge (challengeId, challenge) {
133146
* @returns {Promise<*>} attachments data
134147
*/
135148
export function createAttachments (challengeId, attachments) {
136-
return axiosInstance.post(`${CHALLENGE_API_URL}/${challengeId}/attachments`, attachments)
149+
return axiosInstance.post(`${CHALLENGE_API_URL}/${challengeId}/attachments`, attachments, {
150+
headers: {
151+
'challenge-api-version': CHALLENGE_API_VERSION
152+
}
153+
})
137154
}
138155

139156
/**
@@ -145,7 +162,11 @@ export function createAttachments (challengeId, attachments) {
145162
* @returns {Promise<void>}
146163
*/
147164
export function removeAttachment (challengeId, attachmentId) {
148-
return axiosInstance.delete(`${CHALLENGE_API_URL}/${challengeId}/attachments/${attachmentId}`)
165+
return axiosInstance.delete(`${CHALLENGE_API_URL}/${challengeId}/attachments/${attachmentId}`, {
166+
headers: {
167+
'challenge-api-version': CHALLENGE_API_VERSION
168+
}
169+
})
149170
}
150171

151172
/**
@@ -158,7 +179,11 @@ export function fetchChallenges (filters, params) {
158179
...filters,
159180
...params
160181
}
161-
return axiosInstance.get(`${CHALLENGE_API_URL}?${qs.stringify(query, { encode: false })}`).then(response => {
182+
return axiosInstance.get(`${CHALLENGE_API_URL}?${qs.stringify(query, { encode: false })}`, {
183+
headers: {
184+
'challenge-api-version': CHALLENGE_API_VERSION
185+
}
186+
}).then(response => {
162187
// normalize challenge data in the list of challenges for consistency with data of a single challenge details page
163188
response.data = response.data.map(normalizeChallengeDataFromAPI)
164189
return response
@@ -171,7 +196,11 @@ export function fetchChallenges (filters, params) {
171196
* @param params
172197
*/
173198
export function patchChallenge (challengeId, params) {
174-
return axiosInstance.patch(`${CHALLENGE_API_URL}/${challengeId}`, updateChallengePhaseBeforeSendRequest(params)).then(rs => {
199+
return axiosInstance.patch(`${CHALLENGE_API_URL}/${challengeId}`, updateChallengePhaseBeforeSendRequest(params), {
200+
headers: {
201+
'challenge-api-version': CHALLENGE_API_VERSION
202+
}
203+
}).then(rs => {
175204
return normalizeChallengeDataFromAPI(_.get(rs, 'data'))
176205
})
177206
}
@@ -181,7 +210,11 @@ export function patchChallenge (challengeId, params) {
181210
* @param challengeId
182211
*/
183212
export function deleteChallenge (challengeId) {
184-
return axiosInstance.delete(`${CHALLENGE_API_URL}/${challengeId}`)
213+
return axiosInstance.delete(`${CHALLENGE_API_URL}/${challengeId}`, {
214+
headers: {
215+
'challenge-api-version': CHALLENGE_API_VERSION
216+
}
217+
})
185218
}
186219

187220
/**

0 commit comments

Comments
 (0)