Skip to content

Commit

Permalink
Update campaignMappingUtils.ts (#925)
Browse files Browse the repository at this point in the history
* Update campaignMappingUtils.ts

* Refactored
  • Loading branch information
ashish-egov committed Jun 18, 2024
1 parent 1ebc6c5 commit e66c912
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
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

0 comments on commit e66c912

Please sign in to comment.