Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update campaignMappingUtils.ts #925

Merged
merged 2 commits into from
Jun 18, 2024
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ async function getProjectMappingBody(messageObject: any, boundaryWithProject: an
if (boundaryWithProject[key]) {
const resources: any[] = [];
const pvarIds = getPvarIds(messageObject);
if (pvarIds) {
if (pvarIds && Array.isArray(pvarIds) && pvarIds.length > 0) {
resources.push({
type: "resource",
resourceIds: pvarIds
})
}
for (const type of Object.keys(boundaryCodes)) {
if (boundaryCodes[type][key]) {
if (boundaryCodes[type][key] && Array.isArray(boundaryCodes[type][key]) && boundaryCodes[type][key].length > 0) {
resources.push({
type: type == "user" ? "staff" : type,
resourceIds: [...boundaryCodes[type][key]]
Expand Down Expand Up @@ -143,9 +143,12 @@ async function fetchAndMap(resources: any[], messageObject: any) {
const boundaryCodes: any = {};

await enrichBoundaryCodes(resources, messageObject, boundaryCodes, sheetName);
logger.info("boundaryCodes : " + JSON.stringify(boundaryCodes));
var boundaryWithProject: any = {};
await enrichBoundaryWithProject(messageObject, boundaryWithProject, boundaryCodes);
logger.info("boundaryWithProject : " + JSON.stringify(boundaryWithProject));
const projectMappingBody = await getProjectMappingBody(messageObject, boundaryWithProject, boundaryCodes);
logger.info("projectMappingBody : " + JSON.stringify(projectMappingBody));
logger.info("projectMapping started ");
const projectMappingResponse: any = await createCampaignService(projectMappingBody);
logger.info("Project Mapping Response received");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ async function validateProjectResource(requestBody: any) {
throwError("COMMON", 400, "VALIDATION_ERROR", "Enter Type In Resources");
}
if (!resourceId) {
throwError("COMMON", 400, "VALIDATION_ERROR", "Enter ResourceId In Resources");
throwError("COMMON", 400, "VALIDATION_ERROR", "Enter ResourceId In Resources of type " + type);
}
// Validate the resource ID based on its type
// await validateResourceId(type, resourceId, requestBody);
Expand Down
Loading