diff --git a/src/app.js b/src/app.js index 78be71e..8e1a3e2 100644 --- a/src/app.js +++ b/src/app.js @@ -55,8 +55,7 @@ const dataHandler = (messageSet, topic, partition) => Promise.each(messageSet, a } const m2mToken = await helper.getM2MToken() const v5Challenge = await helper.getRequest(`${config.V5_CHALLENGE_API_URL}/${challengeUuid}`, m2mToken) - // TODO : Cleanup. Pulling the billingAccountId from the payload, it's not part of the challenge object - messageJSON.payload = { billingAccountId: messageJSON.payload.billingAccountId, ...v5Challenge.body } + messageJSON.payload = { ...v5Challenge.body } } catch (err) { logger.debug('Failed to fetch challenge information') logger.logFullError(err) diff --git a/src/services/ProcessorService.js b/src/services/ProcessorService.js index 47d6a30..36d89c7 100644 --- a/src/services/ProcessorService.js +++ b/src/services/ProcessorService.js @@ -367,8 +367,8 @@ async function parsePayload (payload, m2mToken, isCreated = true, informixGroupI projectId, status: payload.status } - if (payload.billingAccountId) { - data.billingAccountId = payload.billingAccountId + if (_.get(payload, 'billing.billingAccountId')) { + data.billingAccountId = _.get(payload, 'billing.billingAccountId') } if (_.get(payload, 'legacy.forumId')) { data.forumId = payload.legacy.forumId @@ -617,7 +617,10 @@ processCreate.schema = { isAssigned: Joi.boolean().default(false), memberId: Joi.string().allow(null) }), - billingAccountId: Joi.number(), + billing: Joi.object().keys({ + billingAccountId: Joi.number(), + markup: Joi.number().min(0).max(100) + }).unknown(true), name: Joi.string().required(), description: Joi.string(), privateDescription: Joi.string(), @@ -786,7 +789,10 @@ processUpdate.schema = { isAssigned: Joi.boolean().default(false), memberId: Joi.string().allow(null) }), - billingAccountId: Joi.number(), + billing: Joi.object().keys({ + billingAccountId: Joi.number(), + markup: Joi.number().min(0).max(100) + }).unknown(true), typeId: Joi.string().required(), trackId: Joi.string().required(), name: Joi.string(), diff --git a/src/utils/metadataExtractor.js b/src/utils/metadataExtractor.js index dea646e..707e2b2 100644 --- a/src/utils/metadataExtractor.js +++ b/src/utils/metadataExtractor.js @@ -16,7 +16,7 @@ const getMeta = (metadata = [], key) => _.find(metadata, meta => meta.name === k * @param {Any} defaultValue the default value */ function extractBillingProject (challenge, defaultValue) { - return _.get(challenge, 'billingAccountId', _.get(challenge, 'billing.billingAccountId', _.toString(defaultValue))) + return _.get(challenge, 'billing.billingAccountId', _.get(challenge, 'billingAccountId', defaultValue)) } /**