ti2-tourplan 1.0.70 → 1.0.72
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +42 -46
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -87,24 +87,23 @@ class BuyerPlugin {
|
|
|
87
87
|
data = data.replace(xmlOptions.dtd.name, `Request SYSTEM "${xmlOptions.dtd.name}"`);
|
|
88
88
|
let replyObj;
|
|
89
89
|
let errorStr;
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
// }
|
|
90
|
+
if (this.xmlProxyUrl) {
|
|
91
|
+
// use pyfilematch xmlproxy to avoid passing large payloads back and forth
|
|
92
|
+
try {
|
|
93
|
+
replyObj = R.path(['data'], await axios({
|
|
94
|
+
method: 'post',
|
|
95
|
+
url: `${this.xmlProxyUrl}/xmlproxy`,
|
|
96
|
+
data: {
|
|
97
|
+
url: endpoint,
|
|
98
|
+
data,
|
|
99
|
+
headers: getHeaders({ length: `${data.length}` }),
|
|
100
|
+
},
|
|
101
|
+
}));
|
|
102
|
+
} catch (err) {
|
|
103
|
+
console.log('error in calling pyfilematch xmlproxy', err);
|
|
104
|
+
errorStr = `error in calling pyfilematch xmlproxy: ${err}`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
108
107
|
if (!replyObj) {
|
|
109
108
|
// in case of error /xmlproxy, fallback to call tourplan directly
|
|
110
109
|
// and then use pyfilematch xml2json to parse the xml
|
|
@@ -463,7 +462,7 @@ class BuyerPlugin {
|
|
|
463
462
|
let serviceCodes = R.pathOr([], ['GetServicesReply', 'TPLServices', 'TPLService'], getServicesReply);
|
|
464
463
|
if (!Array.isArray(serviceCodes)) serviceCodes = [serviceCodes];
|
|
465
464
|
serviceCodes = serviceCodes.map(s => s.Code);
|
|
466
|
-
let
|
|
465
|
+
let options = [];
|
|
467
466
|
await Promise.each(serviceCodes, async serviceCode => {
|
|
468
467
|
const getOptionsModel = {
|
|
469
468
|
OptionInfoRequest: {
|
|
@@ -482,36 +481,33 @@ class BuyerPlugin {
|
|
|
482
481
|
axios,
|
|
483
482
|
xmlOptions: hostConnectXmlOptions,
|
|
484
483
|
});
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
// instead of an array
|
|
492
|
-
if (!Array.isArray(options)) options = [options];
|
|
493
|
-
console.log(`got ${options.length} options for serviceCode ${serviceCode}`);
|
|
494
|
-
return options;
|
|
495
|
-
},
|
|
496
|
-
), getOptionsReply);
|
|
497
|
-
const productsForServiceCode = await Promise.map(
|
|
498
|
-
arrayOfOptionsGroupedBySupplierId,
|
|
499
|
-
optionsGroupedBySupplierId => translateTPOption({
|
|
500
|
-
rootValue: {
|
|
501
|
-
optionsGroupedBySupplierId,
|
|
502
|
-
},
|
|
503
|
-
typeDefs: itineraryProductTypeDefs,
|
|
504
|
-
query: itineraryProductQuery,
|
|
505
|
-
}),
|
|
506
|
-
{
|
|
507
|
-
concurrency: 10,
|
|
508
|
-
},
|
|
509
|
-
);
|
|
510
|
-
products = products.concat(productsForServiceCode);
|
|
484
|
+
let thisOptions = R.pathOr([], ['OptionInfoReply', 'Option'], getOptionsReply);
|
|
485
|
+
// due to the new parser, single option will be returned as an object
|
|
486
|
+
// instead of an array
|
|
487
|
+
if (!Array.isArray(thisOptions)) thisOptions = [thisOptions];
|
|
488
|
+
console.log(`got ${thisOptions.length} options for serviceCode ${serviceCode}`);
|
|
489
|
+
options = options.concat(thisOptions);
|
|
511
490
|
});
|
|
512
|
-
if (!(
|
|
491
|
+
if (!(options && options.length)) {
|
|
513
492
|
throw new Error('No products found');
|
|
514
493
|
}
|
|
494
|
+
const arrayOfOptionsGroupedBySupplierId = R.call(R.compose(
|
|
495
|
+
R.values,
|
|
496
|
+
R.groupBy(R.path(['OptGeneral', 'SupplierId'])),
|
|
497
|
+
), options);
|
|
498
|
+
const products = await Promise.map(
|
|
499
|
+
arrayOfOptionsGroupedBySupplierId,
|
|
500
|
+
optionsGroupedBySupplierId => translateTPOption({
|
|
501
|
+
rootValue: {
|
|
502
|
+
optionsGroupedBySupplierId,
|
|
503
|
+
},
|
|
504
|
+
typeDefs: itineraryProductTypeDefs,
|
|
505
|
+
query: itineraryProductQuery,
|
|
506
|
+
}),
|
|
507
|
+
{
|
|
508
|
+
concurrency: 10,
|
|
509
|
+
},
|
|
510
|
+
);
|
|
515
511
|
return {
|
|
516
512
|
products,
|
|
517
513
|
productFields: [],
|