Skip to content

Commit

Permalink
added javascript error message for quote (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
xuelianhan007 authored Nov 11, 2024
1 parent 86a69a4 commit 063cf3d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@ spec:
(jsonStr) => {
console.log("input: " + jsonStr);
let input = JSON.parse(jsonStr);
let errorMsg = '';
let targetAPIConfigKey = '';
let matrixConfigKey = '';
let forwardDownstream = true;
if(input.quoteItem['product']['productConfiguration']['@type'] == 'UNI') {
let typeArr = ['UNI', 'ACCESS_E_LINE'];
let typeVal = input.quoteItem['product']['productConfiguration']['@type'];
if(typeVal == 'UNI') {
if(input.instantSyncQuote === true) {
targetAPIConfigKey = 'mef.sonata.api-target.quote.uni.add.sync';
matrixConfigKey = 'mef.sonata.api.matrix.quote.uni.add.sync'
} else {
targetAPIConfigKey = 'mef.sonata.api-target.quote.uni.add';
matrixConfigKey = 'mef.sonata.api.matrix.quote.uni.add'
}
} else if(input.quoteItem['product']['productConfiguration']['@type'] == 'ACCESS_E_LINE') {
} else if(typeVal == 'ACCESS_E_LINE') {
if(input.instantSyncQuote === true) {
targetAPIConfigKey = 'mef.sonata.api-target.quote.eline.add.sync';
matrixConfigKey = 'mef.sonata.api.matrix.quote.eline.add.sync'
Expand All @@ -59,14 +63,20 @@ spec:
matrixConfigKey = 'mef.sonata.api.matrix.quote.eline.add'
}
} else {
errorArr = ['api use case is not supported :'];
if (!typeArr.includes(typeVal)){
errorArr.push(`expect quoteItem[0].product.productConfiguration.@type in [ ${typeArr} ], but ${typeVal}.`);
}
errorMsg = errorArr.join(' ');
targetAPIConfigKey = 'targetKey:notFound';
}
let ret = {
quoteType: input.quoteItem['product']['productConfiguration']['@type'],
instantSyncQuote: input.instantSyncQuote,
forwardDownstream: forwardDownstream,
targetAPIConfigKey: targetAPIConfigKey,
matrixConfigKey: matrixConfigKey
matrixConfigKey: matrixConfigKey,
errorMsg: errorMsg
};
return JSON.stringify(ret);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,21 @@ spec:
(jsonStr) => {
console.log("input: " + jsonStr);
let input = JSON.parse(jsonStr);
let errorMsg = '';
let targetAPIConfigKey = '';
let matrixConfigKey = '';
let forwardDownstream = true;
if(input.quoteItem['product']['productConfiguration']['@type'] == 'UNI') {
let typeArr = ['UNI', 'ACCESS_E_LINE'];
let typeVal = input.quoteItem['product']['productConfiguration']['@type'];
if(typeVal == 'UNI') {
if(input.instantSyncQuote === true) {
targetAPIConfigKey = 'mef.sonata.api-target.quote.uni.add.sync';
matrixConfigKey = 'mef.sonata.api.matrix.quote.uni.add.sync'
} else {
targetAPIConfigKey = 'mef.sonata.api-target.quote.uni.add';
matrixConfigKey = 'mef.sonata.api.matrix.quote.uni.add'
}
} else if(input.quoteItem['product']['productConfiguration']['@type'] == 'ACCESS_E_LINE') {
} else if(typeVal == 'ACCESS_E_LINE') {
if(input.instantSyncQuote === true) {
targetAPIConfigKey = 'mef.sonata.api-target.quote.eline.add.sync';
matrixConfigKey = 'mef.sonata.api.matrix.quote.eline.add.sync'
Expand All @@ -59,14 +63,20 @@ spec:
matrixConfigKey = 'mef.sonata.api.matrix.quote.eline.add'
}
} else {
errorArr = ['api use case is not supported :'];
if (!typeArr.includes(typeVal)){
errorArr.push(`expect quoteItem[0].product.productConfiguration.@type in [ ${typeArr} ], but ${typeVal}.`);
}
errorMsg = errorArr.join(' ');
targetAPIConfigKey = 'targetKey:notFound';
}
let ret = {
quoteType: input.quoteItem['product']['productConfiguration']['@type'],
instantSyncQuote: input.instantSyncQuote,
forwardDownstream: forwardDownstream,
targetAPIConfigKey: targetAPIConfigKey,
matrixConfigKey: matrixConfigKey
matrixConfigKey: matrixConfigKey,
errorMsg: errorMsg
};
return JSON.stringify(ret);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ spec:
- classpath:/mef-sonata/mapping-matrix/mapping.matrix.inventory.eline.list.yaml
- classpath:/mef-sonata/template-upgrade/release.1.5.6.yaml
- classpath:/mef-sonata/template-upgrade/release.1.5.7.yaml
- classpath:/mef-sonata/template-upgrade/release.1.5.8.yaml


templateUpgradePaths:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
kind: kraken.product.template-upgrade
apiVersion: v1
metadata:
key: kraken.product.template-upgrade.1.5.8
name: V1.5.8
labels:
productSpec: grace
productVersion: V1.5.8
publishDate: 2024-11-08 18:18
description: |
Added error message in javascript for quote
version: 2

0 comments on commit 063cf3d

Please sign in to comment.