@@ -41,7 +41,7 @@ async function getPlatforms (m2mToken) {
41
41
*/
42
42
async function getChallengeById ( m2mToken , legacyId ) {
43
43
const response = await helper . getRequest ( `${ config . V4_CHALLENGE_API_URL } /${ legacyId } ` , m2mToken )
44
- return _ . get ( response , 'body.result.content[0] ' )
44
+ return _ . get ( response , 'body.result.content' )
45
45
}
46
46
47
47
/**
@@ -78,6 +78,9 @@ async function parsePayload (payload, m2mToken, isCreated = true) {
78
78
projectId,
79
79
status : payload . status
80
80
}
81
+ if ( payload . billingAccountId ) {
82
+ data . billingAccountId = payload . billingAccountId
83
+ }
81
84
if ( _ . get ( payload , 'legacy.forumId' ) ) {
82
85
data . forumId = payload . legacy . forumId
83
86
}
@@ -144,16 +147,11 @@ async function parsePayload (payload, m2mToken, isCreated = true) {
144
147
}
145
148
146
149
// prize type can be Challenge prizes
147
- const challengePrizes = _ . filter ( payload . prizeSets , p => p . type !== constants . prizeSetTypes . ChallengePrizes )
148
- if ( challengePrizes . length > 1 ) {
150
+ const challengePrizes = _ . find ( payload . prizeSets , { type : constants . prizeSetTypes . ChallengePrizes } )
151
+ if ( ! challengePrizes ) {
149
152
throw new Error ( 'Challenge prize information is invalid.' )
150
153
}
151
- if ( challengePrizes . length === 0 ) {
152
- // learning challenge has no prizes, for safeguard
153
- data . prizes = [ 0 ]
154
- } else {
155
- data . prizes = _ . map ( challengePrizes [ 0 ] . prizes , 'value' ) . sort ( ( a , b ) => b - a )
156
- }
154
+ data . prizes = _ . map ( challengePrizes [ 0 ] . prizes , 'value' ) . sort ( ( a , b ) => b - a )
157
155
}
158
156
if ( payload . tags ) {
159
157
const techResult = await getTechnologies ( m2mToken )
@@ -245,6 +243,7 @@ processCreate.schema = {
245
243
directProjectId : Joi . number ( ) ,
246
244
forumId : Joi . number ( ) . integer ( ) . positive ( )
247
245
} ) ,
246
+ billingAccountId : Joi . number ( ) ,
248
247
name : Joi . string ( ) . required ( ) ,
249
248
description : Joi . string ( ) ,
250
249
privateDescription : Joi . string ( ) ,
@@ -338,6 +337,7 @@ processUpdate.schema = {
338
337
forumId : Joi . number ( ) . integer ( ) . positive ( ) ,
339
338
informixModified : Joi . string ( )
340
339
} ) ,
340
+ billingAccountId : Joi . number ( ) ,
341
341
typeId : Joi . string ( ) ,
342
342
name : Joi . string ( ) ,
343
343
description : Joi . string ( ) ,
0 commit comments