ti2-tourplan 1.0.70 → 1.0.71

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.
Files changed (2) hide show
  1. package/index.js +25 -28
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -463,7 +463,7 @@ class BuyerPlugin {
463
463
  let serviceCodes = R.pathOr([], ['GetServicesReply', 'TPLServices', 'TPLService'], getServicesReply);
464
464
  if (!Array.isArray(serviceCodes)) serviceCodes = [serviceCodes];
465
465
  serviceCodes = serviceCodes.map(s => s.Code);
466
- let products = [];
466
+ let options = [];
467
467
  await Promise.each(serviceCodes, async serviceCode => {
468
468
  const getOptionsModel = {
469
469
  OptionInfoRequest: {
@@ -482,36 +482,33 @@ class BuyerPlugin {
482
482
  axios,
483
483
  xmlOptions: hostConnectXmlOptions,
484
484
  });
485
- const arrayOfOptionsGroupedBySupplierId = R.call(R.compose(
486
- R.values,
487
- R.groupBy(R.path(['OptGeneral', 'SupplierId'])),
488
- root => {
489
- let options = R.pathOr([], ['OptionInfoReply', 'Option'], root);
490
- // due to the new parser, single option will be returned as an object
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);
485
+ let thisOptions = R.pathOr([], ['OptionInfoReply', 'Option'], getOptionsReply);
486
+ // due to the new parser, single option will be returned as an object
487
+ // instead of an array
488
+ if (!Array.isArray(thisOptions)) thisOptions = [thisOptions];
489
+ console.log(`got ${thisOptions.length} options for serviceCode ${serviceCode}`);
490
+ options = options.concat(thisOptions);
511
491
  });
512
- if (!(products && products.length)) {
492
+ if (!(options && options.length)) {
513
493
  throw new Error('No products found');
514
494
  }
495
+ const arrayOfOptionsGroupedBySupplierId = R.call(R.compose(
496
+ R.values,
497
+ R.groupBy(R.path(['OptGeneral', 'SupplierId'])),
498
+ ), options);
499
+ const products = await Promise.map(
500
+ arrayOfOptionsGroupedBySupplierId,
501
+ optionsGroupedBySupplierId => translateTPOption({
502
+ rootValue: {
503
+ optionsGroupedBySupplierId,
504
+ },
505
+ typeDefs: itineraryProductTypeDefs,
506
+ query: itineraryProductQuery,
507
+ }),
508
+ {
509
+ concurrency: 10,
510
+ },
511
+ );
515
512
  return {
516
513
  products,
517
514
  productFields: [],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ti2-tourplan",
3
- "version": "1.0.70",
3
+ "version": "1.0.71",
4
4
  "description": "Tourplan's TI2 Plugin",
5
5
  "main": "index.js",
6
6
  "scripts": {