Skip to content
This repository was archived by the owner on Jan 23, 2025. It is now read-only.

read BA from the challenge object #39

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
14 changes: 10 additions & 4 deletions src/services/ProcessorService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
2 changes: 1 addition & 1 deletion src/utils/metadataExtractor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

/**
Expand Down