-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More flexible case body helper (#81)
* Make case-body-helper much more flexible * Add paf as valid namespace
- Loading branch information
Showing
11 changed files
with
421 additions
and
223 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"reporter": [ | ||
"text" | ||
], | ||
"exclude": [ | ||
"test", | ||
"test-data" | ||
], | ||
"statements": "50", | ||
"branches": "90", | ||
"functions": "33", | ||
"lines": "50" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,80 @@ | ||
"use strict"; | ||
|
||
const ownerMapper = { dn: "DNBO" }; | ||
const { caseSchema } = require("../validation-helpers/schemas"); | ||
|
||
const sourceQueueMapper = { dn: "DNBO" }; | ||
const ownerMapper = { | ||
"bbm-res": "BBM", | ||
"bbm-dam": "BBM", | ||
"bbm-aktuellhallbarhet": "BBM", | ||
"bbm-fastighetsnytt": "BBM", | ||
"bbm-byggindustrin": "BBM", | ||
"bbm-dagensmedicin": "BBM", | ||
"bbm-dagligvarunytt": "BBM", | ||
"bbm-dagenssamhalle": "BBM", | ||
"bbm-market": "BBM", | ||
"bbm-news": "BBM", | ||
bnlo: "MittMedia", | ||
di: "Di_Backoffice_Omni", | ||
dn: "DNBO", | ||
expressen: "Expressen_Backoffice", | ||
paf: "Di_Backoffice_Omni", | ||
}; | ||
|
||
function createBackOfficeCaseBody(subject, description, namespace) { | ||
return { | ||
category: "Övriga ärenden", | ||
const sourceQueueMapper = { | ||
"bbm-res": "BBM_BackOffice", | ||
"bbm-dam": "BBM_BackOffice", | ||
"bbm-aktuellhallbarhet": "BBM_BackOffice", | ||
"bbm-fastighetsnytt": "BBM_BackOffice", | ||
"bbm-byggindustrin": "BBM_BackOffice", | ||
"bbm-dagensmedicin": "BBM_BackOffice", | ||
"bbm-dagligvarunytt": "BBM_BackOffice", | ||
"bbm-dagenssamhalle": "BBM_BackOffice", | ||
"bbm-market": "BBM_BackOffice", | ||
"bbm-news": "BBM_BackOffice", | ||
bnlo: "MittMedia_Secondline_Support", | ||
di: "Di_Second_Line", | ||
dn: "DNBO", | ||
expressen: "Expressen_Backoffice", | ||
paf: "PAF_Kundservice", | ||
}; | ||
|
||
function createBackOfficeCaseBody( | ||
subject, | ||
description, | ||
namespace, | ||
{ | ||
businessType = "BN_B2C", | ||
category = "Övriga ärenden", | ||
contact, | ||
deploymentName, | ||
externalReference, | ||
origin = "Greenfield", | ||
owner, | ||
priority = "Medium", | ||
sourceQueue, | ||
} = {} | ||
) { | ||
const caseBody = { | ||
businessType, | ||
category, | ||
description, | ||
namespace, | ||
origin: "Greenfield", | ||
owner: ownerMapper[namespace], | ||
sourceQueue: sourceQueueMapper[namespace], | ||
origin, | ||
owner: owner || ownerMapper[namespace], | ||
priority, | ||
sourceQueue: sourceQueue || sourceQueueMapper[namespace], | ||
subject, | ||
}; | ||
|
||
if (contact) caseBody.contact = contact; | ||
if (deploymentName) caseBody.deploymentName = deploymentName; | ||
if (externalReference) caseBody.externalReference = externalReference; | ||
|
||
const result = caseSchema.validate(caseBody); | ||
|
||
if (result.error) throw result.error; | ||
|
||
return caseBody; | ||
} | ||
|
||
module.exports = createBackOfficeCaseBody; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.